Bump RuboCop to 1.92.1 and its plugins to their latest versions
What does this MR do?
Bumps RuboCop to 1.92.1 and every pinned plugin to its latest release. The version bump comes in a separate release MR.
The main reason is https://github.com/rubocop/rubocop/commit/5245f3186 (RuboCop 1.82.1). Without it, --parallel misses its own result cache and the housekeeper:generate-rubocop-todos job in gitlab-org/gitlab times out.
Closes #93 (closed)
Issue #93 (closed) proposed bumping the plugins separately. Nothing forces that: the old plugin pins work with RuboCop 1.92.1. We bumped them together on purpose, so there is one release and one gitlab-org/gitlab dry run instead of two. gitlab-org/gitlab!265850 (merged) shows the combined impact.
Version changes
| Gem | From | To |
|---|---|---|
| rubocop | 1.81.7 | 1.92.1 |
| rubocop-capybara | 2.21.0 | 3.1.0 |
| rubocop-factory_bot | 2.26.1 | 2.28.0 |
| rubocop-graphql | 1.5.4 | 1.8.0 |
| rubocop-performance | 1.23.1 | 1.27.0 |
| rubocop-rails | 2.29.1 | 2.38.0 |
| rubocop-rspec | 3.4.0 | 3.10.2 |
| rubocop-rspec_rails | 2.30.0 | 2.33.0 |
All support Ruby 3.1. BUNDLED WITH stays at 2.6.9.
Config and cop changes
plugins:instead ofrequire:. The new plugin versions warn onrequire:, and that warning failsspec/yml_spec.rb.- Our RSpec cops load only from
rubocop-rspec.yml. Theyrequire 'rubocop-rspec', and version 3.10 no longer loads its defaults on require. Every config that loaded our custom cops therefore ran rubocop-rspec's cops without their config, and they crashed (config['RSpec']['Language']isnil). They now load throughlib/gitlab/styles/rubocop/rspec, which onlyrubocop-rspec.ymlrequires. on_itblock. It's aliased next to the existingon_numblockaliases, forInternalAffairs/ItblockHandler..rubocop.yml. It loadsrubocop-internal_affairsas a plugin.Performance/BigDecimalWithNumericArgument. We no longer enable it, in a separate commit. Upstream disabled it in https://github.com/rubocop/rubocop-performance/pull/521 because its suggestions can make code slower.
Impact on downstream projects
New pending cops stay off with NewCops: disable.
Breaking: configs other than rubocop-rspec.yml and rubocop-default.yml no longer enable RSpec cops. Projects that inherit only those configs and want RSpec cops should add rubocop-rspec.yml. rubocop-default.yml and rubocop-rspec.yml enable the same cops as before.
Newly running
Lint/CopDirectiveSyntaxCapybara/AssertStyle,Capybara/FindAllFirst,Capybara/RedundantWithinFind,Capybara/SpecificActionsCapybara/RSpec/HaveContent,Capybara/RSpec/NegationMatcherAfterVisit,Capybara/RSpec/HaveSelector,Capybara/RSpec/PredicateMatcher,Capybara/RSpec/MatchStyle,Capybara/RSpec/NegationMatcher,Capybara/RSpec/SpecificMatcherGraphQL/DefaultForOptionalArgument,GraphQL/MethodShadowedByResolverMethod,GraphQL/NullabilityMismatch,GraphQL/UselessMethodOption
Renamed or split
- Moved under
Capybara/RSpec/:CurrentPathExpectation,NegationMatcher,SpecificMatcher,VisibilityMatcher. - Split:
Capybara/MatchStyleintoCapybara/AssertStyleandCapybara/RSpec/MatchStyle. - rubocop-capybara 3.0 removed its migration config, so an old name in a config or TODO file fails the run with
Error: unrecognized cop or department.
Removed
Capybara/ClickLinkOrButtonStyleStyle/DoubleCopDisableDirective
Disabled
Performance/BigDecimalWithNumericArgument
Changed defaults
- rubocop-rails 2.38 prefixes its default
Include/Excludepaths with**/, so Rails cops also match nested paths such asee/app/**andgems/*/app/**. - RuboCop 1.91 reports Security cops as
warningand Metrics cops asrefactor. Failure status is unchanged, but report output differs.
How to validate
bundle exec rspec: 609 examples, 0 failures.bundle exec rubocop: no offenses, no warnings.- Dry-run MR in
gitlab-org/gitlab(tested with !292 (merged)'s head on top of this MR): gitlab-org/gitlab!265850 (merged)