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 of require:. The new plugin versions warn on require:, and that warning fails spec/yml_spec.rb.
  • Our RSpec cops load only from rubocop-rspec.yml. They require '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'] is nil). They now load through lib/gitlab/styles/rubocop/rspec, which only rubocop-rspec.yml requires.
  • on_itblock. It's aliased next to the existing on_numblock aliases, for InternalAffairs/ItblockHandler.
  • .rubocop.yml. It loads rubocop-internal_affairs as 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/CopDirectiveSyntax
  • Capybara/AssertStyle, Capybara/FindAllFirst, Capybara/RedundantWithinFind, Capybara/SpecificActions
  • Capybara/RSpec/HaveContent, Capybara/RSpec/NegationMatcherAfterVisit, Capybara/RSpec/HaveSelector, Capybara/RSpec/PredicateMatcher, Capybara/RSpec/MatchStyle, Capybara/RSpec/NegationMatcher, Capybara/RSpec/SpecificMatcher
  • GraphQL/DefaultForOptionalArgument, GraphQL/MethodShadowedByResolverMethod, GraphQL/NullabilityMismatch, GraphQL/UselessMethodOption

Renamed or split

  • Moved under Capybara/RSpec/: CurrentPathExpectation, NegationMatcher, SpecificMatcher, VisibilityMatcher.
  • Split: Capybara/MatchStyle into Capybara/AssertStyle and Capybara/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/ClickLinkOrButtonStyle
  • Style/DoubleCopDisableDirective

Disabled

  • Performance/BigDecimalWithNumericArgument

Changed defaults

  • rubocop-rails 2.38 prefixes its default Include/Exclude paths with **/, so Rails cops also match nested paths such as ee/app/** and gems/*/app/**.
  • RuboCop 1.91 reports Security cops as warning and Metrics cops as refactor. Failure status is unchanged, but report output differs.

How to validate

Edited by Abdul Wadood

Merge request reports

Loading
Loading