Skip to content

Commit fd4f4d7

Browse files
committed
Fix an error for InternalAffairs/NodeMatcherDirective when no second argument
1 parent 7bb9708 commit fd4f4d7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/rubocop/cop/internal_affairs/node_matcher_directive.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class NodeMatcherDirective < Base
4545
PATTERN
4646

4747
def on_send(node)
48-
return if node.arguments.none?
48+
return unless node.arguments.count == 2
4949
return unless valid_method_name?(node)
5050

5151
actual_name = node.first_argument.value.to_s

spec/rubocop/cop/internal_affairs/node_matcher_directive_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ class MyCop
293293
RUBY
294294
end
295295

296+
it 'registers no offense without second argument' do
297+
expect_no_offenses(<<~RUBY)
298+
#{method} :foo?
299+
RUBY
300+
end
301+
296302
context 'when using class methods' do
297303
it 'registers an offense when the directive is missing' do
298304
expect_offense(<<~RUBY, method: method)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy