Skip to content

Migrate rubocop-rspec/rails/capybara/factory_bot from require: to plugins: (ECOMM-11818) - #54

Draft
tahoemph wants to merge 1 commit into
masterfrom
eng/rubocop-plugins-migration/ECOMM-11818
Draft

Migrate rubocop-rspec/rails/capybara/factory_bot from require: to plugins: (ECOMM-11818)#54
tahoemph wants to merge 1 commit into
masterfrom
eng/rubocop-plugins-migration/ECOMM-11818

Conversation

@tahoemph

Copy link
Copy Markdown
Member

Summary

RuboCop 1.72+ deprecated using the legacy require: key to load extension gems that support the newer lint_roller plugins: protocol. For rubocop-rspec, rubocop-rails, rubocop-capybara, and rubocop-factory_bot, staying on require: under a recent RuboCop means the extension's own default config (EnforcedStyle, SupportedStyles, MaxAmount, etc.) silently stops merging in — the cops still register and run, but crash with NoMethodError the moment they read a config value that was never populated.

This was discovered while upgrading Armageddon to Ruby 3.4.5 / RuboCop 1.79.0 (ECOMM-11506), which exposed 8 crashing cops (Capybara/RSpec/PredicateMatcher, Capybara/NegationMatcher, Capybara/ClickLinkOrButtonStyle, FactoryBot/ExcessiveCreateList, FactoryBot/AssociationStyle, FactoryBot/ConsistentParenthesesStyle, FactoryBot/CreateList, FactoryBot/FactoryNameStyle). Armageddon added a stopgap manually supplying each cop's upstream defaults; that stopgap can be removed once Armageddon bumps to this release.

Changes

  • config/default.yml and old-default.yml: require:plugins: for rubocop-rspec, rubocop-rspec_rails, rubocop-rails, rubocop-capybara. Also adds rubocop-factory_bot as an explicit plugin entry — it was previously only pulled in transitively through rubocop-rspec, which is exactly the kind of implicit dependency the plugin protocol no longer merges config for.
  • Dutchie-Style.gemspec / Gemfile: bumped dependency floors to the versions that actually implement the lint_roller plugin protocol — rubocop ~> 1.81 (driven by rubocop-capybara 3.0's own floor), rubocop-rspec/rubocop-capybara ~> 3.0, rubocop-rails ~> 2.32, rubocop-factory_bot ~> 2.28, rubocop-rspec_rails ~> 2.31 (first version depending on lint_roller). Older RuboCop (pre-1.81) and these older extension gem versions don't support plugins: at all, so this is a breaking change for any consumer pinned below those floors — hence the major version bump to 3.0.0.
  • lib/Dutchie/Style/version.rb: bumped to 3.0.0.

Verification

Reproduced the crash against RuboCop 1.79.0 with the old require:-based config (FactoryBot/AssociationStyle and RSpec/Dialect both raised NoMethodError on nil config). After switching to plugins: and bumping the gem floors, re-ran the same fixtures against the newly locked versions (RuboCop 1.88.2, rubocop-rspec 3.10.2, rubocop-capybara 3.0.0, rubocop-factory_bot 2.28.0, rubocop-rails 2.36.0) and confirmed:

  • Capybara/RSpec/NegationMatcher, Capybara/RSpec/HaveSelector, Capybara/AmbiguousClick fire correctly with their proper messages/EnforcedStyle.
  • FactoryBot/AssociationStyle fires correctly ("Use implicit style to define associations").
  • No more crashes / no more "specify plugins:" deprecation warnings.
  • Existing gem test suite (bundle exec rspec) still passes (21 examples, 0 failures).

Release

No CHANGELOG or automated release/tag/publish workflow currently exists in this repo (the old tag-on-merge GitHub Action was removed at some point). This PR bumps version.rb to 3.0.0; publishing to RubyGems and tagging the release will need to be done manually by someone with gem push access once this merges.

Non-blocking note

config/default.yml ships Dutchie's own Dutchie/LaunchDarklyDefaults cop, which duplicates a cop Armageddon maintains locally as part of a separate initiative (ECOMM-6142). Not in scope here, just flagging for awareness.

Test plan

  • bundle exec rspec passes
  • Consuming repo (e.g. Armageddon on RuboCop 1.79+) can drop its FactoryBot/Capybara cop-default stopgap after bumping to this release
  • bundle exec rubocop against a repo using this config no longer emits plugins: deprecation warnings and no cops crash

…o plugins: ECOMM-11818

Under RuboCop 1.72+, extension gems loaded via the legacy `require:` key no
longer get their own default config (EnforcedStyle, SupportedStyles, etc.)
merged in, since those gems now only support the lint_roller `plugins:`
protocol. This left cops like Capybara/RSpec/PredicateMatcher and
FactoryBot/AssociationStyle crashing with NoMethodError on nil config values,
surfaced while upgrading Armageddon to RuboCop 1.79.0.

Switches both default.yml and config/default.yml to `plugins:`, adds the
previously-transitive rubocop-factory_bot as an explicit plugin entry, and
bumps the gem's own dependency floors to the versions that actually implement
the plugin protocol (rubocop ~> 1.81, rubocop-rspec/-capybara ~> 3.0,
rubocop-rails ~> 2.32, rubocop-factory_bot ~> 2.28, rubocop-rspec_rails ~> 2.31).
@tahoemph tahoemph added the vaped Created by Bilda in a VAPE environment label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vaped Created by Bilda in a VAPE environment

Development

Successfully merging this pull request may close these issues.

1 participant