From 6cf36ec299ef68b344d147623236bdfc858ed39c Mon Sep 17 00:00:00 2001 From: brujeo Date: Tue, 28 Nov 2023 17:32:51 +0000 Subject: [PATCH] updating rubocop and fixing code style issues (#704) --- Gemfile.lock | 20 +++++++++++-------- .../flood_risk_engine/forms_controller.rb | 2 +- app/forms/flood_risk_engine/base_form.rb | 2 +- .../flood_risk_engine/application_helper.rb | 2 +- app/helpers/flood_risk_engine/email_helper.rb | 4 ++-- .../can_use_new_registration_workflow.rb | 2 +- ..._number_to_flood_risk_engine_exemptions.rb | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 795801bf..591eaba0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -245,6 +245,7 @@ GEM thor (>= 0.14, < 2.0) json (2.6.3) jwt (2.7.0) + language_server-protocol (3.17.0.3) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -286,8 +287,9 @@ GEM sawyer (~> 0.9) os_map_ref (0.5.0) parallel (1.23.0) - parser (3.2.2.1) + parser (3.2.2.4) ast (~> 2.4.1) + racc pg (1.5.4) phonelib (0.8.5) poltergeist (1.18.1) @@ -344,7 +346,7 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) rbtree3 (0.7.1) - regexp_parser (2.8.1) + regexp_parser (2.8.2) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) @@ -375,26 +377,28 @@ GEM rspec-mocks (~> 3.10) rspec-support (~> 3.10) rspec-support (3.12.0) - rubocop (1.52.0) + rubocop (1.57.2) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + parser (>= 3.2.2.4) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) rubocop-capybara (2.18.0) rubocop (~> 1.41) rubocop-factory_bot (2.23.1) rubocop (~> 1.33) - rubocop-rails (2.19.1) + rubocop-rails (2.22.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) rubocop-rspec (2.22.0) rubocop (~> 1.33) rubocop-capybara (~> 2.17) @@ -441,7 +445,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) uk_postcode (2.1.8) - unicode-display_width (2.4.2) + unicode-display_width (2.5.0) uniform_notifier (1.16.0) validates_email_format_of (1.7.2) i18n diff --git a/app/controllers/flood_risk_engine/forms_controller.rb b/app/controllers/flood_risk_engine/forms_controller.rb index 0ba37366..9f20b1f8 100644 --- a/app/controllers/flood_risk_engine/forms_controller.rb +++ b/app/controllers/flood_risk_engine/forms_controller.rb @@ -45,7 +45,7 @@ def transient_registration_attributes end def validate_token - return redirect_to(page_path("invalid")) unless find_or_initialize_transient_registration(params[:token]) + redirect_to(page_path("invalid")) unless find_or_initialize_transient_registration(params[:token]) end # rubocop:disable Naming/MemoizedInstanceVariableName diff --git a/app/forms/flood_risk_engine/base_form.rb b/app/forms/flood_risk_engine/base_form.rb index 2c815b7b..0d9743df 100644 --- a/app/forms/flood_risk_engine/base_form.rb +++ b/app/forms/flood_risk_engine/base_form.rb @@ -54,7 +54,7 @@ def submit(attributes) private def transient_registration_valid? - return if transient_registration.valid? + return true if transient_registration.valid? transient_registration.errors.each_value do |message| errors[:base] << message diff --git a/app/helpers/flood_risk_engine/application_helper.rb b/app/helpers/flood_risk_engine/application_helper.rb index 21c70eb7..05344613 100644 --- a/app/helpers/flood_risk_engine/application_helper.rb +++ b/app/helpers/flood_risk_engine/application_helper.rb @@ -37,7 +37,7 @@ def title_text end def error_title - return content_for :error_title if content_for?(:error_title) + content_for :error_title if content_for?(:error_title) end end end diff --git a/app/helpers/flood_risk_engine/email_helper.rb b/app/helpers/flood_risk_engine/email_helper.rb index 14f83188..a0df74db 100644 --- a/app/helpers/flood_risk_engine/email_helper.rb +++ b/app/helpers/flood_risk_engine/email_helper.rb @@ -4,7 +4,7 @@ module FloodRiskEngine module EmailHelper # Embed an image inline into html email - def email_image_tag(image, **options) + def email_image_tag(image, **) path = File.join("/app/assets/images", image) full_path = Rails.root.join path @@ -13,7 +13,7 @@ def email_image_tag(image, **options) full_path = File.join(Gem.loaded_specs["flood_risk_engine"].full_gem_path, path) unless File.exist? full_path attachments[image] = File.read full_path - image_tag attachments[image].url, **options + image_tag(attachments[image].url, **) end end diff --git a/app/models/concerns/flood_risk_engine/can_use_new_registration_workflow.rb b/app/models/concerns/flood_risk_engine/can_use_new_registration_workflow.rb index 4431fea2..cc1c3385 100644 --- a/app/models/concerns/flood_risk_engine/can_use_new_registration_workflow.rb +++ b/app/models/concerns/flood_risk_engine/can_use_new_registration_workflow.rb @@ -273,7 +273,7 @@ def skip_to_manual_address? end def company_address_was_manually_entered? - return if company_address.blank? + return false if company_address.blank? company_address.manual? end diff --git a/db/migrate/20160503133237_add_code_number_to_flood_risk_engine_exemptions.rb b/db/migrate/20160503133237_add_code_number_to_flood_risk_engine_exemptions.rb index 4413c350..0a84566f 100644 --- a/db/migrate/20160503133237_add_code_number_to_flood_risk_engine_exemptions.rb +++ b/db/migrate/20160503133237_add_code_number_to_flood_risk_engine_exemptions.rb @@ -6,6 +6,6 @@ def change add_index :flood_risk_engine_exemptions, :code_number, unique: true - FloodRiskEngine::Exemption.all.each(&:save) + FloodRiskEngine::Exemption.find_each(&:save) end end