Skip to content

Commit

Permalink
[Fix #10504] Fix a false positive for Lint/UnusedMethodArgument
Browse files Browse the repository at this point in the history
Fixes #10504.

This PR fixes a false positive for `Lint/UnusedMethodArgument`
when using `raise NotImplementedError` with optional arguments.
  • Loading branch information
koic authored and bbatsov committed Apr 6, 2022
1 parent 7e148bf commit 253297e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#10504](https://github.com/rubocop/rubocop/issues/10504): Fix a false positive for `Lint/UnusedMethodArgument` when using `raise NotImplementedError` with optional arguments. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/unused_method_argument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class UnusedMethodArgument < Base

# @!method not_implemented?(node)
def_node_matcher :not_implemented?, <<~PATTERN
{(send nil? :raise (const {nil? cbase} :NotImplementedError))
{(send nil? :raise (const {nil? cbase} :NotImplementedError) ...)
(send nil? :fail ...)}
PATTERN

Expand Down
8 changes: 8 additions & 0 deletions spec/rubocop/cop/lint/unused_method_argument_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,14 @@ def method(arg)
RUBY
end

it 'accepts a method with a single unused parameter & raises NotImplementedError, message' do
expect_no_offenses(<<~RUBY)
def method(arg)
raise NotImplementedError, message
end
RUBY
end

it 'accepts a method with a single unused parameter & raises ::NotImplementedError' do
expect_no_offenses(<<~RUBY)
def method(arg)
Expand Down

0 comments on commit 253297e

Please sign in to comment.