-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Fix #9174] Handle send nodes with unparenthesized arguments in Style/SoleNestedConditional
#9178
Conversation
FYI - the original correction, It'd be ideal I think if there was a way to immediately queue up a follow up cop after a cop's autocorrection completes (so that logic doesn't have to be duplicated, but I couldn't find a way to do so. |
…n `Style/SoleNestedConditional`.
c574cf3
to
26c07cb
Compare
@koic fixed now, thanks! |
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
if foo && (ok? bar) |
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.
A little worrisome is that foo && ok?(bar)
is (maybe) more natural code rather than foo && (ok? bar)
for user 😅
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.
Yeah, I agree, but I couldn't get it working otherwise. If I try to correct the condition
node I get a clobbering error. Any suggestions?
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.
Unfortunately I don't have an immediate idea 💦 , but I think it can be improved later. First, I'm going to merge this PR to prevent the syntax error. Thank you for your consideration and fixing!
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 @koic!
If a condition is rewritten by
Style/SoleNestedConditional
that was an unparenthesized send node, it would be rewritten to a syntax error. This changes it to wrap the send node in parens.Fixes #9174.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.