Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use node groups in node patterns to replace unions of types #2025

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(send _ :to $(send nil? :eql {boolean int float sym nil}))
(send _ :to $(send nil? :eql {boolean numeric sym nil}))

This needs to be checked though, and the doc above needs to be adjusted.

I don’t mind leaving this out

Copy link
Member Author

@dvandersluis dvandersluis Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numeric is more than int and float (also rational and complex), so up to you if you want to change behaviour. I was only making equivalent changes 😄

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
Loading