-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
base: master
Are you sure you want to change the base?
Conversation
CI failures are unrelated to this PR but due to rubocop/rubocop#13719. |
Yeah, I think v1.38.0 is a bit too recent for us to set as a hard requirement. Postponing the use of |
`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.
5c87552
to
51b8675
Compare
The CI failures are fixed in #2026. |
@bquorning I updated the PR to skip Other than |
Thank you! I'll rebase once it's been merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -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})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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
There was a problem hiding this comment.
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 😄
we can update that together with bumping the dependency in the gemspec. |
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.rubocop-ast v1.38.0 is needed for
any_block
. I added it to the gemspec in this PR but if you'd prefer to handle it later, I can remove theany_block
changes.