Skip to content

Autoload the deprecated IgnoredMethods and IgnoredPattern aliases - #15588

Merged
koic merged 1 commit into
rubocop:masterfrom
SeanLF:autoload-deprecated-mixin-aliases
Aug 21, 2026
Merged

koic merged 1 commit into
rubocop:masterfrom
SeanLF:autoload-deprecated-mixin-aliases

Conversation

@SeanLF

@SeanLF SeanLF commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

RuboCop::Cop::IgnoredMethods and RuboCop::Cop::IgnoredPattern — the deprecated aliases added in #10829 "in order to not break extensions" — are unreachable after a bare require "rubocop" since cops became lazily loaded in #14983:

$ docker run --rm ruby:3.4 sh -c 'gem install rubocop -v 1.89.0 --no-document -q >/dev/null && ruby -e "require \"rubocop\"; puts RuboCop::Cop::IgnoredMethods"'
-e:1:in '<main>': uninitialized constant RuboCop::Cop::IgnoredMethods (NameError)

The same command with -v 1.88.2 prints RuboCop::Cop::AllowedMethods. The aliases are defined inside allowed_methods.rb / allowed_pattern.rb, so they only ever resolved as a side effect of eager cop loading; mixin.rb has never registered them.

The spec lives in lazy_loading_spec.rb and asserts through a fresh ruby -Ilib process, since the constants resolve trivially once the suite has loaded cops.

Happy to make this a removal instead if you would rather retire the aliases.


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.

… aliases

Since cops are loaded lazily, nothing requires allowed_methods.rb or
allowed_pattern.rb at load time, so the deprecated aliases defined there are
unreachable after a bare `require "rubocop"`. They previously resolved only as
a side effect of eager cop loading; mixin.rb has never registered them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@SeanLF
SeanLF marked this pull request as ready for review August 20, 2026 19:52
@koic
koic merged commit bf197bf into rubocop:master Aug 21, 2026
22 checks passed
@SeanLF
SeanLF deleted the autoload-deprecated-mixin-aliases branch August 21, 2026 13:31
@BrewTestBot BrewTestBot mentioned this pull request Sep 7, 2026
1 task done
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.

2 participants