Skip to content

Commit

Permalink
Merge pull request rubocop#13179 from Earlopain/node-matcher-directir…
Browse files Browse the repository at this point in the history
…y-error

Fix an error for `InternalAffairs/NodeMatcherDirective` when no second argument
  • Loading branch information
koic authored Sep 2, 2024
2 parents 4bb7cba + fd4f4d7 commit 9a38b11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class NodeMatcherDirective < Base
PATTERN

def on_send(node)
return if node.arguments.none?
return unless node.arguments.count == 2
return unless valid_method_name?(node)

actual_name = node.first_argument.value.to_s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ class MyCop
RUBY
end

it 'registers no offense without second argument' do
expect_no_offenses(<<~RUBY)
#{method} :foo?
RUBY
end

context 'when using class methods' do
it 'registers an offense when the directive is missing' do
expect_offense(<<~RUBY, method: method)
Expand Down

0 comments on commit 9a38b11

Please sign in to comment.