Skip to content

Commit

Permalink
Fix an error for InternalAffairs/NodeMatcherDirective when no secon…
Browse files Browse the repository at this point in the history
…d argument
  • Loading branch information
Earlopain committed Sep 1, 2024
1 parent 7bb9708 commit fd4f4d7
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 fd4f4d7

Please sign in to comment.