Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint/RedundantCopDisableDirective doesn't run if other test is disabled on the command line #11204

Closed
furiousdavid opened this issue Nov 26, 2022 · 0 comments · Fixed by #11318
Labels

Comments

@furiousdavid
Copy link

Passing --except Layout/LineLength to rubocop also seems to disable the check for Lint/RedundantCopDisableDirective

Expected behavior

$ cat test.rb 
# frozen_string_literal: true

# sample for bug report
class Foo
  def bar # rubocop:disable Style/EmptyMethod
  end
end


$ rubocop --debug test.rb 
For /home/klobad/Documents/FormKeep/github/formkeep: Default configuration from /home/klobad/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.39.0/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /home/klobad/Documents/FormKeep/github/formkeep/test.rb
Loading cache from /home/klobad/.cache/rubocop_cache/0b06607358ac7b70cd9f357781448c84c00cea38/6d7a3b621ca1730e04accd938619e4bdab66cfb1/9870e83daf2842de6c7a90ae3e7cfda716aa2300
W

Offenses:

test.rb:5:11: W: [Correctable] Lint/RedundantCopDisableDirective: Unnecessary disabling of Style/EmptyMethod.
  def bar # rubocop:disable Style/EmptyMethod
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense autocorrectable
Finished in 0.0879353420168627 seconds

Actual behavior

$ rubocop  --debug --except Layout/LineLength test.rb 
For /home/klobad/Documents/FormKeep/github/formkeep: Default configuration from /home/klobad/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-1.39.0/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /home/klobad/Documents/FormKeep/github/formkeep/test.rb
Loading cache from /home/klobad/.cache/rubocop_cache/0b06607358ac7b70cd9f357781448c84c00cea38/e6f1404efc7309d647c24ff845e2475472ce11fc/9870e83daf2842de6c7a90ae3e7cfda716aa2300
.

1 file inspected, no offenses detected
Finished in 0.08694695797748864 seconds

Steps to reproduce the problem

add the --except Layout/LineLength parameter to the command line.

RuboCop version

$ bundle exec rubocop -V
1.39.0 (using Parser 3.1.3.0, rubocop-ast 1.23.0, running on ruby 3.1.2) [x86_64-linux]
@koic koic added the bug label Dec 22, 2022
koic added a commit to koic/rubocop that referenced this issue Dec 22, 2022
…eDirective`

Fixes rubocop#11204.

This PR fixes a false negative for `Lint/RedundantCopDisableDirective`
when using `--except` command line option.
bbatsov pushed a commit that referenced this issue Dec 23, 2022
…ive`

Fixes #11204.

This PR fixes a false negative for `Lint/RedundantCopDisableDirective`
when using `--except` command line option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants