From 204704da06c9fb4a260d820203fb674fed96eb08 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:25:44 +0000 Subject: [PATCH 1/7] Bump rubocop from 1.66.1 to 1.71.2 Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.66.1 to 1.71.2. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.66.1...v1.71.2) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Note: Fix SafeNavigation offense detected by RuboCop 1.67.0 Remove redundant condition that became unnecessary after updating RuboCop. --- Gemfile | 2 +- Gemfile.lock | 10 +++++----- app/controllers/legislation/annotations_controller.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 65e387b36..769d0f262 100644 --- a/Gemfile +++ b/Gemfile @@ -101,7 +101,7 @@ group :development do gem "pronto-eslint", "~> 0.11.1", require: false gem "pronto-rubocop", "~> 0.11.6", require: false gem "pronto-stylelint", "~> 0.11.0", require: false - gem "rubocop", "~> 1.66.1", require: false + gem "rubocop", "~> 1.71.2", require: false gem "rubocop-capybara", "~> 2.21.0", require: false gem "rubocop-factory_bot", "~> 2.26.1", require: false gem "rubocop-performance", "~> 1.23.1", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 79d29584a..deaf13268 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -553,16 +553,16 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.66.1) + rubocop (1.71.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rubocop-ast (>= 1.32.2, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.38.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) + unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.38.1) parser (>= 3.3.1.0) rubocop-capybara (2.21.0) @@ -786,7 +786,7 @@ DEPENDENCIES rinku (~> 2.0.6) ros-apartment (~> 2.11.0) rspec-rails (~> 7.0.1) - rubocop (~> 1.66.1) + rubocop (~> 1.71.2) rubocop-capybara (~> 2.21.0) rubocop-factory_bot (~> 2.26.1) rubocop-performance (~> 1.23.1) diff --git a/app/controllers/legislation/annotations_controller.rb b/app/controllers/legislation/annotations_controller.rb index ce83d684b..ccc577320 100644 --- a/app/controllers/legislation/annotations_controller.rb +++ b/app/controllers/legislation/annotations_controller.rb @@ -101,7 +101,7 @@ class Legislation::AnnotationsController < Legislation::BaseController def convert_ranges_parameters annotation = params[:legislation_annotation] - if annotation && annotation[:ranges] && annotation[:ranges].is_a?(String) + if annotation && annotation[:ranges]&.is_a?(String) params[:legislation_annotation][:ranges] = JSON.parse(annotation[:ranges]) end rescue JSON::ParserError From ada35f51f22d0e77abfe83050cc3ce52f48e1df9 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 12 Feb 2025 17:49:38 +0100 Subject: [PATCH 2/7] Remove unnecessary EnforcedShorthandSyntax definition Rubocop 1.67.0 sets EnforcedShorthandSyntax to "either" by default, so explicitly defining it is no longer necessary. --- .rubocop.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 89542ea0d..fd0d057bf 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -719,7 +719,6 @@ Style/HashExcept: Style/HashSyntax: Enabled: true - EnforcedShorthandSyntax: either Style/HashTransformKeys: Enabled: true From 9081174dd785f4b5470121bb02976761d948eebc Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 13 Feb 2025 10:48:16 +0100 Subject: [PATCH 3/7] Add and apply Style/KeywordArgumentsMerging rubocop rule This rule was introduced in RuboCop 1.68 to encourage passing additional keyword arguments directly instead of using merge. --- .rubocop.yml | 3 +++ app/components/admin/allowed_table_actions_component.rb | 2 +- app/components/admin/table_actions_component.html.erb | 4 ++-- spec/support/matchers/have_avatar.rb | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index fd0d057bf..0f291bb99 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -743,6 +743,9 @@ Style/InvertibleUnlessCondition: :present?: :blank? :zero?: ~ +Style/KeywordArgumentsMerging: + Enabled: true + Style/LineEndConcatenation: Enabled: true diff --git a/app/components/admin/allowed_table_actions_component.rb b/app/components/admin/allowed_table_actions_component.rb index a237bde5c..53a5410c4 100644 --- a/app/components/admin/allowed_table_actions_component.rb +++ b/app/components/admin/allowed_table_actions_component.rb @@ -15,6 +15,6 @@ class Admin::AllowedTableActionsComponent < ApplicationComponent end def table_actions_component - @table_actions_component ||= Admin::TableActionsComponent.new(record, **options.merge(actions: actions)) + @table_actions_component ||= Admin::TableActionsComponent.new(record, **options, actions: actions) end end diff --git a/app/components/admin/table_actions_component.html.erb b/app/components/admin/table_actions_component.html.erb index 58c6b2763..1ccf0915e 100644 --- a/app/components/admin/table_actions_component.html.erb +++ b/app/components/admin/table_actions_component.html.erb @@ -2,10 +2,10 @@ <%= content %> <% if actions.include?(:edit) %> - <%= action(:edit, **edit_options.merge(text: edit_text, path: edit_path)) %> + <%= action(:edit, **edit_options, text: edit_text, path: edit_path) %> <% end %> <% if actions.include?(:destroy) %> - <%= action(:destroy, **destroy_options.merge(text: destroy_text, path: destroy_path)) %> + <%= action(:destroy, **destroy_options, text: destroy_text, path: destroy_path) %> <% end %> diff --git a/spec/support/matchers/have_avatar.rb b/spec/support/matchers/have_avatar.rb index f45895e84..c2a2a2289 100644 --- a/spec/support/matchers/have_avatar.rb +++ b/spec/support/matchers/have_avatar.rb @@ -1,6 +1,6 @@ RSpec::Matchers.define :have_avatar do |text, **options| match do |page| - page.has_css?("svg.initialjs-avatar", **{ exact_text: text }.merge(options)) + page.has_css?("svg.initialjs-avatar", **{ exact_text: text }, **options) end failure_message do From 4c7fe8a5d9fa25c4594e234cf3140fe5d17bcb9f Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 13 Feb 2025 15:59:59 +0100 Subject: [PATCH 4/7] Enable new rules from RuboCop 1.69 --- .rubocop.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 0f291bb99..0747bb2e7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -299,6 +299,9 @@ Lint/EmptyBlock: Lint/EmptyFile: Enabled: true +Lint/HashNewWithKeywordArgumentsAsDefault: + Enabled: true + Lint/LiteralAsCondition: Enabled: true @@ -326,6 +329,9 @@ Lint/SymbolConversion: Lint/UselessAssignment: Enabled: true +Lint/UselessDefined: + Enabled: true + Lint/Void: Enabled: true @@ -705,6 +711,9 @@ Style/ClassVars: Style/CollectionMethods: Enabled: true +Style/DigChain: + Enabled: true + Style/FileRead: Enabled: true From f4ffee37001c34af85b1ecc19078f17be99bf72e Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 13 Feb 2025 16:06:05 +0100 Subject: [PATCH 5/7] Add and apply Lint/RedundantSafeNavigation RuboCop rule We've tested the updated behavior in RuboCop 1.69, found a new offense, and corrected it. --- .rubocop.yml | 3 +++ app/controllers/legislation/annotations_controller.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0747bb2e7..2fa6f89b3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -311,6 +311,9 @@ Lint/NonAtomicFileOperation: Lint/ParenthesesAsGroupedExpression: Enabled: true +Lint/RedundantSafeNavigation: + Enabled: true + Lint/RedundantStringCoercion: Enabled: true diff --git a/app/controllers/legislation/annotations_controller.rb b/app/controllers/legislation/annotations_controller.rb index ccc577320..f7289d9ff 100644 --- a/app/controllers/legislation/annotations_controller.rb +++ b/app/controllers/legislation/annotations_controller.rb @@ -101,7 +101,7 @@ class Legislation::AnnotationsController < Legislation::BaseController def convert_ranges_parameters annotation = params[:legislation_annotation] - if annotation && annotation[:ranges]&.is_a?(String) + if annotation && annotation[:ranges].is_a?(String) params[:legislation_annotation][:ranges] = JSON.parse(annotation[:ranges]) end rescue JSON::ParserError From ba22d7fdf71c5d5e6577355861021074e716b338 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 13 Feb 2025 16:51:01 +0100 Subject: [PATCH 6/7] Enable new rules from RuboCop 1.70 --- .rubocop.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 2fa6f89b3..2ae3a44b4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -284,6 +284,9 @@ Lint/BooleanSymbol: Lint/ConstantDefinitionInBlock: Enabled: true +Lint/ConstantReassignment: + Enabled: true + Lint/DeprecatedClassMethods: Enabled: true @@ -323,6 +326,9 @@ Lint/SafeNavigationChain: Lint/ShadowingOuterLocalVariable: Enabled: true +Lint/SharedMutableDefault: + Enabled: true + Lint/SymbolConversion: Enabled: true Exclude: From 202ba3a5f87c57aa6aa926fe5648d4c04dffbb33 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 13 Feb 2025 16:58:11 +0100 Subject: [PATCH 7/7] Enable new rule from RuboCop 1.71 --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 2ae3a44b4..7034ec35f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -735,6 +735,9 @@ Style/HashConversion: Style/HashExcept: Enabled: true +Style/HashSlice: + Enabled: true + Style/HashSyntax: Enabled: true