From d6629ee1299f913c7172a5d97b18b0f25620538d Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Mon, 22 Apr 2024 12:07:08 +0100 Subject: [PATCH 1/2] Update script/update-rubocop-config.rb Handle custom comments which might explain why an option is disabled. --- .ruby-style.yml | 6 ++++-- script/update-rubocop-config.rb | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.ruby-style.yml b/.ruby-style.yml index 19888f745a..7853a84acc 100644 --- a/.ruby-style.yml +++ b/.ruby-style.yml @@ -143,8 +143,9 @@ Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterMagicComment: Enabled: true +# Prefer EmptyLinesAroundRescuedExceptions instead Layout/EmptyLineAfterMultilineCondition: - Enabled: false # we prefer EmptyLinesAroundRescuedExceptions instead + Enabled: false Layout/EmptyLineBetweenDefs: Enabled: true @@ -170,8 +171,9 @@ Layout/EmptyLinesAroundBlockBody: Layout/EmptyLinesAroundClassBody: Enabled: true +# Prefer EmptyLinesAroundRescuedExceptions instead Layout/EmptyLinesAroundExceptionHandlingKeywords: - Enabled: false # we prefer EmptyLinesAroundRescuedExceptions instead + Enabled: false Layout/EmptyLinesAroundMethodBody: Enabled: true diff --git a/script/update-rubocop-config.rb b/script/update-rubocop-config.rb index 9443dd59ee..395da2633a 100755 --- a/script/update-rubocop-config.rb +++ b/script/update-rubocop-config.rb @@ -79,7 +79,7 @@ def groupings_from_config(config) cops_from_config(config).map { |c| c.split('/').first }.uniq end -def write_config(config) +def write_config(config, comments) yaml = config.sort.to_h.to_yaml # add lines between cops @@ -98,9 +98,30 @@ def write_config(config) yaml.sub!(g + '/', '#' * 20 + " #{g} " + '#' * 20 + "\n\n#{g}/") end + comments.each do |cop, comment_lines| + yaml.gsub!(/^(#{cop}:)/, "#{comment_lines.join("\n")}\n\\1") + end + File.write(CONFIG_FILE, yaml) end -write_config(merge_config(default_config, current_config)) +def cop_comments + comments = {} + current_section = [] + + File.readlines(CONFIG_FILE).each do |line| + if line.match?('^(# .*|#)$') + current_section << line.strip + elsif !current_section.empty? && line.match?(/^\w/) + cop_name = line.split(':').first + comments[cop_name] = current_section + current_section = [] + end + end + + comments +end + +write_config(merge_config(default_config, current_config), cop_comments) puts "RuboCop configuration at #{File.expand_path(CONFIG_FILE)} has been updated" puts "Please manually check cops which have been renamed" From 23b364a2b253271bc29a847c09cf01d8276489f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 04:58:09 +0000 Subject: [PATCH 2/2] Build(deps-dev): Bump rubocop from 1.63.5 to 1.64.0 Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.5 to 1.64.0. - [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.63.5...v1.64.0) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .ruby-style.yml | 6 ++++++ Gemfile | 2 +- Gemfile.lock | 12 +++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.ruby-style.yml b/.ruby-style.yml index 7853a84acc..91cc1ad038 100644 --- a/.ruby-style.yml +++ b/.ruby-style.yml @@ -2130,6 +2130,9 @@ Style/Semicolon: Style/Send: Enabled: false +Style/SendWithLiteralMethodName: + Enabled: false + Style/SignalException: Enabled: true EnforcedStyle: only_raise @@ -2200,6 +2203,9 @@ Style/Strip: Style/StructInheritance: Enabled: true +Style/SuperArguments: + Enabled: false + Style/SuperWithArgsParentheses: Enabled: false diff --git a/Gemfile b/Gemfile index 75d5157df7..c7b5ad1bbf 100644 --- a/Gemfile +++ b/Gemfile @@ -198,7 +198,7 @@ group :development do gem 'net-ssh-gateway', '>= 1.1.0', '< 3.0.0' gem 'launchy', '< 3.1.0' gem 'web-console', '>= 3.3.0' - gem 'rubocop', '~> 1.63.5', require: false + gem 'rubocop', '~> 1.64.0', require: false gem 'rubocop-performance', require: false gem 'rubocop-rails', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 841310e429..8c9fe3ae7c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -387,7 +387,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (5.0.5) - racc (1.7.3) + racc (1.8.0) rack (2.2.9) rack-test (2.1.0) rack (>= 1.3) @@ -435,7 +435,7 @@ GEM redis (4.8.1) redlock (1.3.2) redis (>= 3.0.0, < 6.0) - regexp_parser (2.9.1) + regexp_parser (2.9.2) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) @@ -443,7 +443,8 @@ GEM request_store (1.5.1) rack (>= 1.4) retriable (3.1.2) - rexml (3.2.6) + rexml (3.2.8) + strscan (>= 3.0.9) rolify (6.0.1) rotp (6.3.0) rspec-activemodel-mocks (1.2.0) @@ -467,7 +468,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - rubocop (1.63.5) + rubocop (1.64.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -527,6 +528,7 @@ GEM sprockets (>= 3.0.0) statistics2 (0.54) stripe (5.55.0) + strscan (3.1.0) syck (1.4.1) syslog_protocol (0.9.2) text (1.3.1) @@ -646,7 +648,7 @@ DEPENDENCIES rolify (~> 6.0.1) rspec-activemodel-mocks (~> 1.2.0) rspec-rails (~> 6.1.2) - rubocop (~> 1.63.5) + rubocop (~> 1.64.0) rubocop-performance rubocop-rails ruby-msg (~> 1.5.0)!