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 #10881] Fix Style/SoleNestedConditional
to properly wrap block
and csend
nodes when necessary
#10886
Conversation
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
if foo && (bar&.baz quux) |
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.
It would be more better to correct as follows.
if foo && (bar&.baz quux) | |
if foo && bar&.baz(quux) |
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.
I agree, but this is the existing autocorrection for send
nodes I'm just extending it to csend
and block
nodes as well to prevent syntax errors from autocorrection.
Would you be good with accepting this as-is and improving autocorrection in a future PR?
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.
OK, I think we can do it separately. It would be useful to leave a FIXME
comment.
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.
Added!
if foo && (ok? bar do | ||
do_something | ||
end) | ||
end |
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.
Ditto :-)
if foo && (ok? bar do | |
do_something | |
end) | |
end | |
if foo && ok?(bar) do | |
do_something | |
end | |
end |
…p `block` and `csend` nodes when necessary.
37dfae6
to
64cdfad
Compare
Thanks! |
Style/SoleNestedConditional
adds parentheses aroundsend
nodes that have unparenthesized arguments, but this wasn't being done forcsend
orblock
nodes, so this change fixes that.Fixes #10881.
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.