diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..bdb77e0f --- /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 9c49771d..afe2d021 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 a69b7d28..fcab75d4 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 e597b511..7395888c 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 6b46b224..0a3672c7 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 00000000..ee85c603 --- /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 81ef8a4c..b7b8d6ec 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 1443e4ba..d0d0a34c 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 00000000..b3abb0b5 --- /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 02aa6adc..887b1df5 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 7b243dd4..c6d1e41c 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"