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

Style/SoleNestedConditional autocorrects unless without parens incorrectly #9350

Closed
magneland opened this issue Jan 8, 2021 · 0 comments
Closed
Labels

Comments

@magneland
Copy link
Contributor

magneland commented Jan 8, 2021

I found a small bug when applying autocorrect.
It is exemplified using unless without parens, but with a nested modifier condition:

unless foo || bar
  do_something if baz
end

Expected behavior

Autocorrect should perform several transformations, resulting in:

if !(foo || bar) && baz
  do_something 
end

Actual behavior

The ! is in the wrong place:

if (!foo || bar) && baz
  do_something 
end

It appears that the order of transformations is wrong.

Steps to reproduce the problem

My example above should reproduce it. I have a fix PR with specs coming shortly.

RuboCop version

$ [bundle exec] rubocop -V
1.8.0 (using Parser 3.0.0.0, rubocop-ast 1.4.0, running on ruby 2.6.3 x86_64-darwin19)
  - rubocop-performance 1.9.2
  - rubocop-rspec 2.0.1
magneland added a commit to magneland/rubocop that referenced this issue Jan 8, 2021
@koic koic added the bug label Jan 8, 2021
@bbatsov bbatsov closed this as completed in ad71469 Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants