Class: RuboCop::Cop::Legion::Framework::NoUnusedArgDisable
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Legion::Framework::NoUnusedArgDisable
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/legion/framework/no_unused_arg_disable.rb
Overview
Bans disabling Lint/UnusedMethodArgument with an inline directive.
An unused kwarg is a real offense, not something to hide — a ** /
**opts splat already swallows extras, so the arg should be dropped;
if it is genuinely optional, change ** to **opts and read
opts[:key]. RuboCop's own RedundantCopDisableDirective never flags
this because the offense is genuine, so the directive stays invisible.
Autocorrect removes the directive so the real Lint/UnusedMethodArgument
offense resurfaces and must be fixed properly. It never edits the method
signature — dropping a load-bearing public kwarg is a human decision.
A blanket "disable all" directive is intentionally out of scope; only
directives that name Lint/UnusedMethodArgument explicitly are flagged.
Constant Summary collapse
- MSG =
'Do not disable `Lint/UnusedMethodArgument`. Drop the unused arg ' \ '(a `**`/`**opts` splat already swallows it) or change `**` to ' \ '`**opts` and read `opts[:key]`.'
- TARGET =
'Lint/UnusedMethodArgument'- DIRECTIVE =
Matches a disable / todo / enable directive and captures the cop list.
/#\s*rubocop:(?:disable|todo|enable)\s+(?<cops>[^#]+)/
Instance Method Summary collapse
Instance Method Details
#on_new_investigation ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rubocop/cop/legion/framework/no_unused_arg_disable.rb', line 47 def on_new_investigation processed_source.comments.each do |comment| match = DIRECTIVE.match(comment.text) next unless match cops = match[:cops].split(',').map(&:strip) next unless cops.include?(TARGET) register(comment, cops) end end |