Skip to content

Commit

Permalink
Merge pull request #6184 from ministryofjustice/dependabot/bundler/ru…
Browse files Browse the repository at this point in the history
…bocop-performance-1.20.1

build(deps-dev): bump rubocop-performance from 1.19.1 to 1.20.1
  • Loading branch information
colinbruce authored Jan 9, 2024
2 parents 493aaea + f166f05 commit ecdf0e8
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 39 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/forms/base_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/forms/chances_of_successes/success_prospect_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/forms/partners/offline_accounts_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/forms/proceedings/scope_limitations_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/forms/providers/regular_transaction_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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?

Expand Down
2 changes: 1 addition & 1 deletion app/forms/savings_amounts/offline_accounts_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/forms/savings_amounts/savings_amounts_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/models/base_aggregated_cash_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/binary_choice_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/models/legal_aid_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/bank_transaction_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/services/flow/merits_loop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

{
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/services/reports/mis/application_detail_csv_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/views/providers/means/other_assets/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/partials/_revealing_checkbox.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
Expand All @@ -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" %>
Expand Down
2 changes: 1 addition & 1 deletion spec/support/pundit_matcher.rb
Original file line number Diff line number Diff line change
@@ -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|
Expand Down

0 comments on commit ecdf0e8

Please sign in to comment.