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

False positive for Lint/UnusedMethodArgument when passing an error message to NotImplementedError #10504

Closed
mishina2228 opened this issue Apr 5, 2022 · 0 comments · Fixed by #10505
Labels

Comments

@mishina2228
Copy link
Contributor

When passing an error message to NotImplementedError,
even if IgnoreNotImplementedMethods is set to be true,
RuboCop complains with Lint/UnusedMethodArgument.

def do_something(unused)
  raise NotImplementedError, 'Not implemented yet'
end

Expected behavior

No offenses detected.

Actual behavior

$ rubocop --debug example.rb
For /tmp: Default configuration from /home/owner/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/rubocop-1.26.1/config/default.yml
Use parallel by default.
Running parallel inspection
Loading cache from /home/owner/.cache/rubocop_cache/5e04273777e1ec6067245135980a93eda5924838/6d7a3b621ca1730e04accd938619e4bdab66cfb1/4099d08316b4e9eec2a24b7d3cc969713274d4be
Inspecting 1 file
Scanning /tmp/example.rb
Loading cache from /home/owner/.cache/rubocop_cache/5e04273777e1ec6067245135980a93eda5924838/6d7a3b621ca1730e04accd938619e4bdab66cfb1/4099d08316b4e9eec2a24b7d3cc969713274d4be
W

Offenses:

example.rb:3:18: W: [Correctable] Lint/UnusedMethodArgument: Unused method argument - unused. If it's necessary, use _ or _unused as an argument name to indicate that it won't be used. You can also write as do_something(*) if you want the method to accept any arguments but don't care about them.
def do_something(unused)
                 ^^^^^^

1 file inspected, 1 offense detected, 1 offense auto-correctable
Finished in 0.10515446698991582 seconds

Steps to reproduce the problem

Here's a minimal example.rb file that shows the problem:

# frozen_string_literal: true

def do_something(unused)
  raise NotImplementedError, 'Not implemented yet'
end

RuboCop version

$ rubocop -V
1.26.1 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 3.1.0 x86_64-linux)
@koic koic added the bug label Apr 5, 2022
koic added a commit to koic/rubocop that referenced this issue Apr 5, 2022
Fixes rubocop#10504.

This PR fixes a false positive for `Lint/UnusedMethodArgument`
when using `raise NotImplementedError` with optional arguments.
bbatsov pushed a commit that referenced this issue Apr 6, 2022
Fixes #10504.

This PR fixes a false positive for `Lint/UnusedMethodArgument`
when using `raise NotImplementedError` with optional arguments.
denisdefreyne added a commit to nanoc/nanoc that referenced this issue May 8, 2022
This was fixed in Rubocop 1.27.0: rubocop/rubocop#10504
denisdefreyne added a commit to nanoc/nanoc that referenced this issue May 8, 2022
This was fixed in Rubocop 1.27.0: rubocop/rubocop#10504
denisdefreyne added a commit to nanoc/nanoc that referenced this issue May 8, 2022
This was fixed in Rubocop 1.27.0: rubocop/rubocop#10504
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