-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add AST::InPatternNode
node
#183
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR adds `AST::InPatternNode` node. It aims to make access to `in` pattern node of the pattern matching syntax convenient and readable. For example, pattern matching syntax AST can use `in_pattern.body` and prevents the following error: ```console NoMethodError: undefined method `body' for s(:in_pattern, s(:array_pattern, s(:match_var, :a)), nil, s(:int, 1)):RuboCop::AST::Node ```
koic
force-pushed
the
add_ast_in_pattern_node
branch
from
May 10, 2021 02:29
c93f20a
to
05b3f40
Compare
@marcandre @bbatsov I'd like to use this PR's feature in rubocop/rubocop#9825. Can you review, merge, and release? |
8 tasks
The change looks good to me. I'll do a release now. |
Done. |
@bbatsov Thank you! |
koic
added a commit
to koic/rubocop
that referenced
this pull request
May 26, 2021
This PR adds new `Lint/EmptyInPattern` cop for Ruby 2.7's pattern matching. It checks for the presence of `in` branches without a body. ```ruby # bad case condition in [a] do_something in [a, b] end # good case condition in [a] do_something in [a, b] nil end # good - AllowComments: true (default) case condition in [a] do_something in [a, b] # noop end # bad - AllowComments: false case condition in [a] do_something in [a, b] # noop end ``` This cop is similar to `Lint/EmptyWhen`, but with different supported syntax and Ruby version (requires 2.7 or higher). And this PR use rubocop/rubocop-ast#183 feature, so it requires RuboCop AST 1.6.0 or higher.
Oh, this fell through the cracks, sorry 😅 Don't hesitate to ping me after 1 or 2 days |
bbatsov
pushed a commit
to rubocop/rubocop
that referenced
this pull request
May 27, 2021
This PR adds new `Lint/EmptyInPattern` cop for Ruby 2.7's pattern matching. It checks for the presence of `in` branches without a body. ```ruby # bad case condition in [a] do_something in [a, b] end # good case condition in [a] do_something in [a, b] nil end # good - AllowComments: true (default) case condition in [a] do_something in [a, b] # noop end # bad - AllowComments: false case condition in [a] do_something in [a, b] # noop end ``` This cop is similar to `Lint/EmptyWhen`, but with different supported syntax and Ruby version (requires 2.7 or higher). And this PR use rubocop/rubocop-ast#183 feature, so it requires RuboCop AST 1.6.0 or higher.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds
AST::InPatternNode
node.It aims to make access to
in
pattern node of the pattern matching syntax convenient and readable.For example, pattern matching syntax AST can use
in_pattern.body
and prevents the following error: