Skip to content

[Cop lazy loading] Fix application of MigrationFileSkippable to all cops#1619

Open
lovro-bikic wants to merge 1 commit into
rubocop:masterfrom
lovro-bikic:fix-migration-file-skippable
Open

[Cop lazy loading] Fix application of MigrationFileSkippable to all cops#1619
lovro-bikic wants to merge 1 commit into
rubocop:masterfrom
lovro-bikic:fix-migration-file-skippable

Conversation

@lovro-bikic
Copy link
Copy Markdown
Contributor

@lovro-bikic lovro-bikic commented May 13, 2026

Fixes MigrationFileSkippable module so it prepends to RuboCop::Cop::Base instead of prepending to each individual cop class.

MigrationFileSkippable is meant to be applied to all cops, but this currently isn't the case if there are plugins loaded after rubocop-rails. For example, if your RuboCop config is:

# .rubocop.yml
plugins:
  - rubocop-rails
  - rubocop-rspec

rubocop-rails will be required before rubocop-rspec, and when RuboCop::Cop::Registry.all.each runs, MigrationFileSkippable won't be prepended to rubocop-rspec cops because they haven't been added to the registry yet.

This PR changes the implementation so that this module is instead prepended to RuboCop::Cop::Base, thereby making it automatically available to all cops, regardless of when they're loaded.

This PR is also a part of the cop lazy-loading proposal: rubocop/rubocop#14983. Not using Registry.all is a prerequisite for lazy-loading to work with this gem.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • If this is a new cop, consider making a corresponding update to the Rails Style Guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant