diff --git a/Gemfile.lock b/Gemfile.lock index f9f03e1ee8..2c39c520a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -641,9 +641,9 @@ GEM rubocop-rails (= 2.23.0) rubocop-rake (= 0.6.0) rubocop-rspec (= 2.25.0) - rubocop-performance (1.19.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) + rubocop-performance (1.20.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) rubocop-rails (2.23.0) activesupport (>= 4.2.0) rack (>= 1.1) diff --git a/app/controllers/admin/legal_aid_applications/submissions_controller.rb b/app/controllers/admin/legal_aid_applications/submissions_controller.rb index 3c728f19c3..cb1fc754d4 100644 --- a/app/controllers/admin/legal_aid_applications/submissions_controller.rb +++ b/app/controllers/admin/legal_aid_applications/submissions_controller.rb @@ -55,7 +55,7 @@ def download_data(attribute) # :nocov: def download_report(attribute) - report = legal_aid_application.send("#{attribute}_report") + report = legal_aid_application.send(:"#{attribute}_report") send_data report.document.download, status: 200, type: "application/pdf", diff --git a/app/forms/base_form.rb b/app/forms/base_form.rb index 8ad2b07fb6..b1e9221e3e 100644 --- a/app/forms/base_form.rb +++ b/app/forms/base_form.rb @@ -35,7 +35,7 @@ def locally_assigned def normalizes(name, with:) before_validation do - send("#{name}=", with.call(send(name))) + send(:"#{name}=", with.call(send(name))) end end end diff --git a/app/forms/chances_of_successes/success_prospect_form.rb b/app/forms/chances_of_successes/success_prospect_form.rb index d5831f40ec..acacfd41f2 100644 --- a/app/forms/chances_of_successes/success_prospect_form.rb +++ b/app/forms/chances_of_successes/success_prospect_form.rb @@ -56,12 +56,12 @@ def extrapolate_details return unless success_prospect_details_expandable? field = "success_prospect_details_#{success_prospect}" - __send__("#{field}=", success_prospect_details) + __send__(:"#{field}=", success_prospect_details) attributes[field] = success_prospect_details end def success_prospect_details_expandable? - success_prospect_details.present? && __send__("success_prospect_details_#{success_prospect}").nil? + success_prospect_details.present? && __send__(:"success_prospect_details_#{success_prospect}").nil? end end end diff --git a/app/forms/partners/offline_accounts_form.rb b/app/forms/partners/offline_accounts_form.rb index 7f1e5f07bb..0328f6caa7 100644 --- a/app/forms/partners/offline_accounts_form.rb +++ b/app/forms/partners/offline_accounts_form.rb @@ -52,7 +52,7 @@ def empty_unchecked_values check_box_attribute = :"check_box_#{attribute}" if send(check_box_attribute).blank? attributes[attribute] = nil - send("#{attribute}=", nil) + send(:"#{attribute}=", nil) end end end diff --git a/app/forms/proceedings/scope_limitations_form.rb b/app/forms/proceedings/scope_limitations_form.rb index 9393706658..4915dc4e8b 100644 --- a/app/forms/proceedings/scope_limitations_form.rb +++ b/app/forms/proceedings/scope_limitations_form.rb @@ -69,7 +69,7 @@ def save(params) def update_scope_attributes(params) params.each do |key, value| - __send__("#{key}=", value) + __send__(:"#{key}=", value) end end @@ -80,7 +80,7 @@ def update_populated_dates end def populate_inputted_date(code) - __send__("hearing_date_#{code}=", date_fields(code).form_date) if scope_codes.include? code + __send__(:"hearing_date_#{code}=", date_fields(code).form_date) if scope_codes.include? code end def date_fields(code, value = nil) diff --git a/app/forms/providers/application_merits_task/client_offered_undertakings_form.rb b/app/forms/providers/application_merits_task/client_offered_undertakings_form.rb index 41d8da348d..7c438337be 100644 --- a/app/forms/providers/application_merits_task/client_offered_undertakings_form.rb +++ b/app/forms/providers/application_merits_task/client_offered_undertakings_form.rb @@ -35,12 +35,12 @@ def extrapolate_additional_information return unless additional_information_expandable? field = "additional_information_#{offered}" - __send__("#{field}=", additional_information) + __send__(:"#{field}=", additional_information) attributes[field] = additional_information end def additional_information_expandable? - additional_information.present? && __send__("additional_information_#{offered}").nil? + additional_information.present? && __send__(:"additional_information_#{offered}").nil? end def exclude_from_model diff --git a/app/forms/providers/application_merits_task/domestic_abuse_summary_form.rb b/app/forms/providers/application_merits_task/domestic_abuse_summary_form.rb index 3ef5db5b9a..a76534ff54 100644 --- a/app/forms/providers/application_merits_task/domestic_abuse_summary_form.rb +++ b/app/forms/providers/application_merits_task/domestic_abuse_summary_form.rb @@ -41,7 +41,7 @@ def initialize(*args) def police_notified_presence return if police_notified.blank? - value = __send__("police_notified_details_#{police_notified}") + value = __send__(:"police_notified_details_#{police_notified}") return if value.present? || draft? translation_path = "activemodel.errors.models.opponent.attributes.police_notified_details_#{police_notified}.blank" @@ -51,7 +51,7 @@ def police_notified_presence def interpolate_police_notified_details return unless [true, false, "true", "false"].include?(police_notified) - value = __send__("police_notified_details_#{police_notified}") + value = __send__(:"police_notified_details_#{police_notified}") @police_notified_details = value&.empty? ? nil : value attributes["police_notified_details"] = @police_notified_details end @@ -61,7 +61,7 @@ def extrapolate_police_notified_details return unless police_notified_details_expandable? field = "police_notified_details_#{police_notified}" - __send__("#{field}=", police_notified_details) + __send__(:"#{field}=", police_notified_details) attributes[field] = police_notified_details end @@ -74,7 +74,7 @@ def clear_bail_details end def police_notified_details_expandable? - police_notified_details.present? && __send__("police_notified_details_#{police_notified}").nil? + police_notified_details.present? && __send__(:"police_notified_details_#{police_notified}").nil? end end end diff --git a/app/forms/providers/regular_transaction_form.rb b/app/forms/providers/regular_transaction_form.rb index 5978b2f0c2..bd8d256e16 100644 --- a/app/forms/providers/regular_transaction_form.rb +++ b/app/forms/providers/regular_transaction_form.rb @@ -102,8 +102,8 @@ def existing_transaction_type_ids def assign_regular_transaction_attributes regular_transactions.each do |transaction| transaction_type = transaction.transaction_type - public_send("#{transaction_type.name}_amount=", transaction.amount) - public_send("#{transaction_type.name}_frequency=", transaction.frequency) + public_send(:"#{transaction_type.name}_amount=", transaction.amount) + public_send(:"#{transaction_type.name}_frequency=", transaction.frequency) end end @@ -162,8 +162,8 @@ def transaction_types def all_regular_transactions_valid regular_transactions.each do |transaction| transaction_type = transaction.transaction_type - transaction.amount = public_send("#{transaction_type.name}_amount") - transaction.frequency = public_send("#{transaction_type.name}_frequency") + transaction.amount = public_send(:"#{transaction_type.name}_amount") + transaction.frequency = public_send(:"#{transaction_type.name}_frequency") next if transaction.valid? diff --git a/app/forms/savings_amounts/offline_accounts_form.rb b/app/forms/savings_amounts/offline_accounts_form.rb index 32aafbd314..c92b0f6f37 100644 --- a/app/forms/savings_amounts/offline_accounts_form.rb +++ b/app/forms/savings_amounts/offline_accounts_form.rb @@ -66,7 +66,7 @@ def empty_unchecked_values check_box_attribute = :"check_box_#{attribute}" if send(check_box_attribute).blank? attributes[attribute] = nil - send("#{attribute}=", nil) + send(:"#{attribute}=", nil) end end end diff --git a/app/forms/savings_amounts/savings_amounts_form.rb b/app/forms/savings_amounts/savings_amounts_form.rb index e4ebfcc50a..655c62e7a1 100644 --- a/app/forms/savings_amounts/savings_amounts_form.rb +++ b/app/forms/savings_amounts/savings_amounts_form.rb @@ -58,7 +58,7 @@ def empty_unchecked_values check_box_attribute = :"check_box_#{attribute}" if send(check_box_attribute).blank? attributes[attribute] = nil - send("#{attribute}=", nil) + send(:"#{attribute}=", nil) end end end diff --git a/app/models/base_aggregated_cash_transaction.rb b/app/models/base_aggregated_cash_transaction.rb index c09b00b6e5..128413e663 100644 --- a/app/models/base_aggregated_cash_transaction.rb +++ b/app/models/base_aggregated_cash_transaction.rb @@ -47,7 +47,7 @@ def populate_attribute(model, trx) checkbox_method = "check_box_#{trx.transaction_type.name}=" model.__send__(value_method, trx.amount) model.__send__(checkbox_method, "true") - model.__send__("month#{trx.month_number}=", trx.transaction_date) + model.__send__(:"month#{trx.month_number}=", trx.transaction_date) end def find_by(legal_aid_application_id:, owner:) @@ -84,12 +84,12 @@ def month_name(month_number) private def transaction_date(month_number) - __send__("month#{month_number}") + __send__(:"month#{month_number}") end def update_cash_attributes(params) params.each do |key, value| - __send__("#{key}=", value) + __send__(:"#{key}=", value) end end diff --git a/app/models/concerns/binary_choice_form.rb b/app/models/concerns/binary_choice_form.rb index b0434ec4f8..6a4a0c078b 100644 --- a/app/models/concerns/binary_choice_form.rb +++ b/app/models/concerns/binary_choice_form.rb @@ -12,7 +12,7 @@ def call(journey:, radio_buttons_input_name:, action: :show, form_params: nil, e end def define_input_conditional(input_name, form_params) - define_method "#{input_name}?" do + define_method :"#{input_name}?" do form_params[input_name] == "true" end end diff --git a/app/models/legal_aid_application.rb b/app/models/legal_aid_application.rb index d1e1192869..983978f314 100644 --- a/app/models/legal_aid_application.rb +++ b/app/models/legal_aid_application.rb @@ -276,7 +276,7 @@ def parent_transaction_types def uncategorised_transactions?(type) bank_trx = bank_transactions_by_type(type) cash_trx = cash_transactions_by_type(type) - parent_transaction_types.__send__("#{type}s").each do |transaction_type| + parent_transaction_types.__send__(:"#{type}s").each do |transaction_type| uncategorised_transactions_errors(transaction_type) unless any_transactions_selected?(transaction_type, bank_trx, cash_trx) end errors.present? @@ -492,7 +492,7 @@ def policy_disregards? end def transactions_total_by_type(transaction_type, category_id) - __send__("#{transaction_type}_transactions").amounts.fetch(category_id, 0) + __send__(:"#{transaction_type}_transactions").amounts.fetch(category_id, 0) end def hmrc_employment_income? @@ -574,7 +574,7 @@ def bank_transactions_by_type(type) end def cash_transactions_by_type(type) - cash_transactions.__send__("#{type}s").order(transaction_date: :desc).by_parent_transaction_type + cash_transactions.__send__(:"#{type}s").order(transaction_date: :desc).by_parent_transaction_type end def any_transactions_selected?(transaction_type, bank_trx, cash_trx) diff --git a/app/presenters/bank_transaction_presenter.rb b/app/presenters/bank_transaction_presenter.rb index f7c1fc4726..6b2d0f6ded 100644 --- a/app/presenters/bank_transaction_presenter.rb +++ b/app/presenters/bank_transaction_presenter.rb @@ -33,7 +33,7 @@ def initialize(item, remarks) def build_transaction_hash values = {} - CELLS.map { |k| values[k.to_sym] = send("transaction_#{k}") } + CELLS.map { |k| values[k.to_sym] = send(:"transaction_#{k}") } values end diff --git a/app/services/flow/merits_loop.rb b/app/services/flow/merits_loop.rb index 52b165689d..76044a327b 100644 --- a/app/services/flow/merits_loop.rb +++ b/app/services/flow/merits_loop.rb @@ -49,7 +49,7 @@ def convert_task_to_flow_name(task) end def not_started_tasks - @not_started_tasks ||= grouped_tasks.map { |task| + @not_started_tasks ||= grouped_tasks.filter_map do |task| next unless task.state == :not_started { @@ -58,7 +58,7 @@ def not_started_tasks url: I18n.t(task.name, scope: "providers.merits_task_lists.show.urls"), state: task.state, } - }&.compact + end end def grouped_tasks diff --git a/app/services/reports/mis/application_detail_csv_line.rb b/app/services/reports/mis/application_detail_csv_line.rb index 3280e9c654..449a1bf368 100644 --- a/app/services/reports/mis/application_detail_csv_line.rb +++ b/app/services/reports/mis/application_detail_csv_line.rb @@ -419,7 +419,7 @@ def employment_concatenation end def convert_employment_type_to_string(value) - value.humanize if laa.applicant.send("#{value}?") + value.humanize if laa.applicant.send(:"#{value}?") end def gateway_evidence_count diff --git a/app/views/providers/means/other_assets/_second_home_conditional_checkbox.html.erb b/app/views/providers/means/other_assets/_second_home_conditional_checkbox.html.erb index 25deca6dee..ff1df24959 100644 --- a/app/views/providers/means/other_assets/_second_home_conditional_checkbox.html.erb +++ b/app/views/providers/means/other_assets/_second_home_conditional_checkbox.html.erb @@ -1,5 +1,5 @@ <% check_box_attribute = "check_box_second_home" %> -<% @form.__send__("#{check_box_attribute}=", model.send(check_box_attribute).present? || model.any_second_home_value_present?) %> +<% @form.__send__(:"#{check_box_attribute}=", model.send(check_box_attribute).present? || model.any_second_home_value_present?) %> <%= form.govuk_check_box check_box_attribute, true, diff --git a/app/views/providers/means/other_assets/show.html.erb b/app/views/providers/means/other_assets/show.html.erb index 3ab0a21961..3ff828bf7d 100644 --- a/app/views/providers/means/other_assets/show.html.erb +++ b/app/views/providers/means/other_assets/show.html.erb @@ -35,7 +35,7 @@ <% Providers::OtherAssetsForm::SINGLE_VALUE_ATTRIBUTES.each do |attribute| %> <% check_box_attribute = "check_box_#{attribute}" %> <% value = @form.send(attribute) %> - <% @form.__send__("#{check_box_attribute}=", @form.send(check_box_attribute).present? || value.present?) %> + <% @form.__send__(:"#{check_box_attribute}=", @form.send(check_box_attribute).present? || value.present?) %> <%= form.govuk_check_box check_box_attribute, true, multiple: false, diff --git a/app/views/providers/means/savings_and_investments/show.html.erb b/app/views/providers/means/savings_and_investments/show.html.erb index e3d260036b..9931cf29cd 100644 --- a/app/views/providers/means/savings_and_investments/show.html.erb +++ b/app/views/providers/means/savings_and_investments/show.html.erb @@ -18,7 +18,7 @@ <% attributes.each_with_index do |attribute, idx| %> <% check_box_attribute = "check_box_#{attribute}" %> <% value = @form.send(attribute) %> - <% @form.__send__("#{check_box_attribute}=", @form.send(check_box_attribute).present? || value.present?) %> + <% @form.__send__(:"#{check_box_attribute}=", @form.send(check_box_attribute).present? || value.present?) %> <%= form.govuk_check_box check_box_attribute.to_sym, true, multiple: false, diff --git a/app/views/shared/partials/_revealing_checkbox.html.erb b/app/views/shared/partials/_revealing_checkbox.html.erb index 64e3fba1f5..807c2fb822 100644 --- a/app/views/shared/partials/_revealing_checkbox.html.erb +++ b/app/views/shared/partials/_revealing_checkbox.html.erb @@ -1,5 +1,5 @@ <% field_name = "check_box_#{name}" - model.__send__("#{field_name}=", model.send(field_name).present?) + model.__send__(:"#{field_name}=", model.send(field_name).present?) error_class = nil %> <%= form.govuk_check_box field_name, true, "", link_errors: true, multiple: false, label: { text: controller_t("check_box_#{name}") } do %> @@ -13,7 +13,7 @@ <% end %> <%= form.govuk_text_field "#{name}#{number}", label: { text: model.period(number) }, - value: gds_number_to_currency(model.__send__("#{name}#{number}"), unit: ""), + value: gds_number_to_currency(model.__send__(:"#{name}#{number}"), unit: ""), prefix_text: defined?(input_prefix) ? input_prefix : nil, form_group: { classes: error_class }, width: "one-third" %> diff --git a/spec/support/pundit_matcher.rb b/spec/support/pundit_matcher.rb index a07a2e0bd0..304198305a 100644 --- a/spec/support/pundit_matcher.rb +++ b/spec/support/pundit_matcher.rb @@ -1,6 +1,6 @@ RSpec::Matchers.define :permit do |action| match do |policy| - policy.public_send("#{action}?") + policy.public_send(:"#{action}?") end failure_message_when_negated do |policy|