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

False autocorrection when merging "exclude?" in outer conditional #9174

Closed
fynsta opened this issue Dec 6, 2020 · 0 comments · Fixed by #9178
Closed

False autocorrection when merging "exclude?" in outer conditional #9174

fynsta opened this issue Dec 6, 2020 · 0 comments · Fixed by #9178
Labels

Comments

@fynsta
Copy link
Contributor

fynsta commented Dec 6, 2020

When running rubocop -a on the following code, it autocorrects it to something syntactically wrong.

if condition
     array << device if (deviceArray1 + deviceArray2 + deviceArray3).exclude? device
end

Result:

if condition && (deviceArray1 + deviceArray2 + deviceArray3).exclude? device
     array << device 
end

RuboCop even throws an error in Lint/Syntax on the newly corrected line, so it is obviously a wrong correction. The correction stems from Style/SoleNestedConditional


Expected behavior

Not to make my code syntactically wrong. Maybe add brackets?

Actual behavior

A wrong autocorrection

RuboCop version

1.5.2 (using Parser 2.7.2.0, rubocop-ast 1.3.0, running on ruby 2.6.1 x86_64-darwin19)
  - rubocop-faker 1.1.0
  - rubocop-performance 1.9.1
  - rubocop-rails 2.8.1
  - rubocop-rake 0.5.1
  - rubocop-rspec 2.0.1
@koic koic added the bug label Dec 7, 2020
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Dec 7, 2020
@koic koic closed this as completed in #9178 Dec 7, 2020
koic added a commit that referenced this issue Dec 7, 2020
[Fix #9174] Handle send nodes with unparenthesized arguments in `Style/SoleNestedConditional`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants