From 5428bd25892707bab2f3cb1c1a3ed6da7acc1219 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 21 Oct 2022 12:03:13 +0000 Subject: [PATCH 1/3] config/default: Upstream cop disables since this is the central place - In `github/github` when we bumped this gem and bumped the version of RuboCop and turned off `DisabledByDefault`, there were some cops that RuboCop had detected offenses for that weren't declared in here as explicitly disabled. - Let's set `Enabled: false` for the new cops, so that this gem's config is the source of truth and downstream consumers don't diverge too much. --- config/default.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/config/default.yml b/config/default.yml index d7883ce..7aef6c8 100644 --- a/config/default.yml +++ b/config/default.yml @@ -454,6 +454,15 @@ Lint/EmptyConditionalBody: Lint/EmptyEnsure: Enabled: true +Lint/EmptyExpression: + Enabled: false + +Lint/EmptyFile: + Enabled: false + +Lint/EmptyWhen: + Enabled: false + Lint/EmptyInterpolation: Enabled: true @@ -607,6 +616,9 @@ Lint/RegexpAsCondition: Lint/RequireParentheses: Enabled: true +Lint/RequireRangeParentheses: + Enabled: false + Lint/RequireRelativeSelfPath: Enabled: false @@ -1129,6 +1141,9 @@ Style/EmptyCaseCondition: Style/EmptyElse: Enabled: false +Style/EmptyHeredoc: + Enabled: false + Style/EmptyLambdaParameter: Enabled: false @@ -1273,6 +1288,9 @@ Style/LambdaCall: Style/LineEndConcatenation: Enabled: false +Style/MagicCommentFormat: + Enabled: false + Style/MapCompactWithConditionalBlock: Enabled: false From 90e921a579f959eceded18791bdf87e813107620 Mon Sep 17 00:00:00 2001 From: Ben Sheldon Date: Fri, 28 Oct 2022 10:17:54 -0700 Subject: [PATCH 2/3] Pin versions, add Dependabot rules, update rubocop versions and create pending files --- .github/dependabot.yml | 7 +++++ .rubocop.yml | 1 + CONTRIBUTING.md | 19 ++++++++++++++ Gemfile.lock | 52 +++++++++++++++++++------------------ config/default.yml | 3 +++ config/default_pending.yml | 6 +++++ config/rails.yml | 3 +++ config/rails_cops.yml | 9 ------- config/rails_pending.yml | 20 ++++++++++++++ lib/rubocop-github-rails.rb | 2 -- rubocop-github.gemspec | 6 ++--- 11 files changed, 89 insertions(+), 39 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 config/default_pending.yml create mode 100644 config/rails_pending.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bdb77e0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: bundler + directory: '/' + versioning-strategy: increase + schedule: + interval: weekly diff --git a/.rubocop.yml b/.rubocop.yml index 9c49771..afe2d02 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,6 @@ inherit_from: - ./config/default.yml + - ./config/rails.yml Naming/FileName: Enabled: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a69b7d2..fcab75d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,6 +29,25 @@ If the Cop is **only applicable for GitHub**, then this is the right place to pr ## For Maintainers +### Updating Rubocop Dependencies + +Rubocop regularly releases new versions with new cops. We want to keep up to date with the latest Rubocop releases, and keep these rules and styleguide in sync to reduce burden on consumers of this gem. + +- Run `bundle update rubocop rubocop-performance rubocop-rails` to update the dependencies within this repository. Major updates will require updating the `.gemspec` file because of the pinned version constraints. +- Run `bundle exec rubocop`, and copy the output of newly introduced rules into `config/default_pending.yml` and `config/rails_pending.yml`. They should look like this: + + ```sh + Lint/DuplicateMagicComment: # new in 1.37 + Enabled: true + Style/OperatorMethodCall: # new in 1.37 + Enabled: true + Style/RedundantStringEscape: # new in 1.37 + Enabled: true + ``` + +- Run `bundle exec rubocop` again to ensure that it runs cleanly without any pending cops. Also run `bundle exec rake` to run the tests. +- Work through the pending cops, and copy them to `config/{default,rails}.yml` with an explicity `Enabled: true` or `Enabled: false` depending on your decision as to whether they should be part of our standard ruleset. + ### Releasing a new version 1. Update `rubocop-github.gemspec` with the next version number diff --git a/Gemfile.lock b/Gemfile.lock index e597b51..7395888 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,20 +2,20 @@ PATH remote: . specs: rubocop-github (0.19.0) - rubocop (>= 1.0.0) - rubocop-performance - rubocop-rails + rubocop (~> 1.37) + rubocop-performance (~> 1.15) + rubocop-rails (~> 2.17) GEM remote: https://rubygems.org/ specs: - actionview (7.0.3) - activesupport (= 7.0.3) + actionview (7.0.4) + activesupport (= 7.0.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activesupport (7.0.3) + activesupport (7.0.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -24,22 +24,23 @@ GEM builder (3.2.4) concurrent-ruby (1.1.10) crass (1.0.6) - erubi (1.10.0) - i18n (1.10.0) + erubi (1.11.0) + i18n (1.12.0) concurrent-ruby (~> 1.0) - loofah (2.18.0) + json (2.6.2) + loofah (2.19.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) - minitest (5.16.1) - nokogiri (1.13.6-arm64-darwin) + minitest (5.16.3) + nokogiri (1.13.9-arm64-darwin) racc (~> 1.4) - nokogiri (1.13.6-x86_64-darwin) + nokogiri (1.13.9-x86_64-darwin) racc (~> 1.4) parallel (1.22.1) - parser (3.1.2.0) + parser (3.1.2.1) ast (~> 2.4.1) racc (1.6.0) - rack (2.2.3.1) + rack (3.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) @@ -47,30 +48,31 @@ GEM loofah (~> 2.3) rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.5.0) + regexp_parser (2.6.0) rexml (3.2.5) - rubocop (1.31.0) + rubocop (1.37.1) + json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.18.0, < 2.0) + rubocop-ast (>= 1.23.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.18.0) + rubocop-ast (1.23.0) parser (>= 3.1.1.0) - rubocop-performance (1.14.2) + rubocop-performance (1.15.0) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.15.1) + rubocop-rails (2.17.2) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) + rubocop (>= 1.33.0, < 2.0) ruby-progressbar (1.11.0) - tzinfo (2.0.4) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) - unicode-display_width (2.2.0) + unicode-display_width (2.3.0) PLATFORMS arm64-darwin-21 @@ -84,4 +86,4 @@ DEPENDENCIES rubocop-github! BUNDLED WITH - 2.2.33 + 2.3.24 diff --git a/config/default.yml b/config/default.yml index 6b46b22..0a3672c 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1,3 +1,6 @@ +inherit_from: + - ./default_pending.yml + require: - rubocop-github - rubocop-performance diff --git a/config/default_pending.yml b/config/default_pending.yml new file mode 100644 index 0000000..ee85c60 --- /dev/null +++ b/config/default_pending.yml @@ -0,0 +1,6 @@ +Lint/DuplicateMagicComment: # new in 1.37 + Enabled: false +Style/OperatorMethodCall: # new in 1.37 + Enabled: false +Style/RedundantStringEscape: # new in 1.37 + Enabled: false diff --git a/config/rails.yml b/config/rails.yml index 81ef8a4..b7b8d6e 100644 --- a/config/rails.yml +++ b/config/rails.yml @@ -1,3 +1,6 @@ +inherit_from: + - ./rails_pending.yml + require: - rubocop-github-rails - rubocop-rails diff --git a/config/rails_cops.yml b/config/rails_cops.yml index 1443e4b..d0d0a34 100644 --- a/config/rails_cops.yml +++ b/config/rails_cops.yml @@ -22,15 +22,6 @@ GitHub/RailsControllerRenderShorthand: Include: - 'app/controllers/**/*.rb' -GitHub/RailsRenderInline: - Enabled: pending - StyleGuide: https://github.com/github/rubocop-github/blob/main/guides/rails-controller-render-inline.md - Include: - - 'app/controllers/**/*.rb' - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' - GitHub/RailsRenderObjectCollection: Enabled: pending diff --git a/config/rails_pending.yml b/config/rails_pending.yml new file mode 100644 index 0000000..b3abb0b --- /dev/null +++ b/config/rails_pending.yml @@ -0,0 +1,20 @@ +Rails/ActionControllerFlashBeforeRender: # new in 2.16 + Enabled: false +Rails/ActionOrder: # new in 2.17 + Enabled: false +Rails/ActiveSupportOnLoad: # new in 2.16 + Enabled: false +Rails/FreezeTime: # new in 2.16 + Enabled: false +Rails/IgnoredColumnsAssignment: # new in 2.17 + Enabled: false +Rails/RootPathnameMethods: # new in 2.16 + Enabled: false +Rails/ToSWithArgument: # new in 2.16 + Enabled: false +Rails/TopLevelHashWithIndifferentAccess: # new in 2.16 + Enabled: false +Rails/WhereMissing: # new in 2.16 + Enabled: false +Rails/WhereNotWithMultipleConditions: # new in 2.17 + Enabled: false diff --git a/lib/rubocop-github-rails.rb b/lib/rubocop-github-rails.rb index 02aa6ad..887b1df 100644 --- a/lib/rubocop-github-rails.rb +++ b/lib/rubocop-github-rails.rb @@ -6,12 +6,10 @@ RuboCop::GitHub::Inject.rails_defaults! -require "rubocop/cop/github/rails_application_record" require "rubocop/cop/github/rails_controller_render_action_symbol" require "rubocop/cop/github/rails_controller_render_literal" require "rubocop/cop/github/rails_controller_render_paths_exist" require "rubocop/cop/github/rails_controller_render_shorthand" -require "rubocop/cop/github/rails_render_inline" require "rubocop/cop/github/rails_render_object_collection" require "rubocop/cop/github/rails_view_render_literal" require "rubocop/cop/github/rails_view_render_paths_exist" diff --git a/rubocop-github.gemspec b/rubocop-github.gemspec index 7b243dd..c6d1e41 100644 --- a/rubocop-github.gemspec +++ b/rubocop-github.gemspec @@ -10,9 +10,9 @@ Gem::Specification.new do |s| s.files = Dir["README.md", "STYLEGUIDE.md", "LICENSE", "config/*.yml", "lib/**/*.rb", "guides/*.md"] - s.add_dependency "rubocop", ">= 1.0.0" - s.add_dependency "rubocop-performance" - s.add_dependency "rubocop-rails" + s.add_dependency "rubocop", "~> 1.37" + s.add_dependency "rubocop-performance", "~> 1.15" + s.add_dependency "rubocop-rails", "~> 2.17" s.add_development_dependency "actionview" s.add_development_dependency "minitest" From d959dddf041812457cb93b0c42b2d087b6c35cc9 Mon Sep 17 00:00:00 2001 From: Ben Sheldon Date: Fri, 28 Oct 2022 11:04:20 -0700 Subject: [PATCH 3/3] Update version constraint from `~>` to `>=` --- Gemfile.lock | 6 +++--- rubocop-github.gemspec | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7395888..ccf0bb2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,9 +2,9 @@ PATH remote: . specs: rubocop-github (0.19.0) - rubocop (~> 1.37) - rubocop-performance (~> 1.15) - rubocop-rails (~> 2.17) + rubocop (>= 1.37) + rubocop-performance (>= 1.15) + rubocop-rails (>= 2.17) GEM remote: https://rubygems.org/ diff --git a/rubocop-github.gemspec b/rubocop-github.gemspec index c6d1e41..d289687 100644 --- a/rubocop-github.gemspec +++ b/rubocop-github.gemspec @@ -10,9 +10,9 @@ Gem::Specification.new do |s| s.files = Dir["README.md", "STYLEGUIDE.md", "LICENSE", "config/*.yml", "lib/**/*.rb", "guides/*.md"] - s.add_dependency "rubocop", "~> 1.37" - s.add_dependency "rubocop-performance", "~> 1.15" - s.add_dependency "rubocop-rails", "~> 2.17" + s.add_dependency "rubocop", ">= 1.37" + s.add_dependency "rubocop-performance", ">= 1.15" + s.add_dependency "rubocop-rails", ">= 2.17" s.add_development_dependency "actionview" s.add_development_dependency "minitest"