Skip to content

Commit

Permalink
Use node groups in node patterns to replace unions of types
Browse files Browse the repository at this point in the history
`rubocop-ast` defines some node groups (https://github.com/rubocop/rubocop-ast/blob/85bfe84/lib/rubocop/ast/node.rb#L89-L116) that can be used in place of a union of node types.
  • Loading branch information
dvandersluis committed Jan 27, 2025
1 parent 6ddeea4 commit 51b8675
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/be_eq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BeEq < Base

# @!method eq_type_with_identity?(node)
def_node_matcher :eq_type_with_identity?, <<~PATTERN
(send nil? :eq {true false nil})
(send nil? :eq {boolean nil})
PATTERN

def on_send(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/be_eql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BeEql < Base

# @!method eql_type_with_identity(node)
def_node_matcher :eql_type_with_identity, <<~PATTERN
(send _ :to $(send nil? :eql {true false int float sym nil}))
(send _ :to $(send nil? :eql {boolean int float sym nil}))
PATTERN

def on_send(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/predicate_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def check_inflected(node)

# @!method be_bool?(node)
def_node_matcher :be_bool?, <<~PATTERN
(send nil? {:be :eq :eql :equal} {true false})
(send nil? {:be :eq :eql :equal} boolean)
PATTERN

# @!method be_boolthy?(node)
Expand Down

0 comments on commit 51b8675

Please sign in to comment.