Migrate rubocop-rspec/rails/capybara/factory_bot from require: to plugins: (ECOMM-11818) - #54
Draft
tahoemph wants to merge 1 commit into
Draft
Migrate rubocop-rspec/rails/capybara/factory_bot from require: to plugins: (ECOMM-11818)#54tahoemph wants to merge 1 commit into
tahoemph wants to merge 1 commit into
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RuboCop 1.72+ deprecated using the legacy
require:key to load extension gems that support the newer lint_rollerplugins:protocol. For rubocop-rspec, rubocop-rails, rubocop-capybara, and rubocop-factory_bot, staying onrequire: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 withNoMethodErrorthe 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.ymlandold-default.yml:require:→plugins:for rubocop-rspec, rubocop-rspec_rails, rubocop-rails, rubocop-capybara. Also addsrubocop-factory_botas 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 supportplugins: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/AssociationStyleandRSpec/Dialectboth raisedNoMethodErroron nil config). After switching toplugins: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/AmbiguousClickfire correctly with their proper messages/EnforcedStyle.FactoryBot/AssociationStylefires correctly ("Use implicit style to define associations").plugins:" deprecation warnings.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.rbto 3.0.0; publishing to RubyGems and tagging the release will need to be done manually by someone withgem pushaccess once this merges.Non-blocking note
config/default.ymlships Dutchie's ownDutchie/LaunchDarklyDefaultscop, 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 rspecpassesbundle exec rubocopagainst a repo using this config no longer emitsplugins:deprecation warnings and no cops crash