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/RedundantCondition making invalid corrections #10605

Closed
tomhughes opened this issue May 7, 2022 · 0 comments · Fixed by #10606
Closed

Style/RedundantCondition making invalid corrections #10605

tomhughes opened this issue May 7, 2022 · 0 comments · Fixed by #10606
Labels

Comments

@tomhughes
Copy link

@tomhughes tomhughes commented May 7, 2022

Expected behavior

Running rubocop --auto-correct should not result in broken code.

Actual behavior

Running rubocop 1.29.0 triggers a correction from Style/RedundantCondition on this code:

if referer
  redirect_to referer
else
  redirect_to :action => :inbox
end

changing it to this:

redirect_to referer || :action => :inbox

which is incorrect and is rejected by ruby requiring it to be changed to:

redirect_to referer || { :action => :inbox }

in order to work.

Steps to reproduce the problem

See above.

RuboCop version

1.29.0 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 3.1.2 x86_64-linux)
  - rubocop-minitest 0.19.1
  - rubocop-performance 1.13.3
  - rubocop-rails 2.14.2
  - rubocop-rake 0.6.0
tomhughes added a commit to tomhughes/openstreetmap-website that referenced this issue May 7, 2022
nobuyo added a commit to nobuyo/rubocop that referenced this issue May 7, 2022
… argment for method in else branch is hash without braces
nobuyo added a commit to nobuyo/rubocop that referenced this issue May 7, 2022
… argument for method in else branch is hash without braces
@koic koic added the bug label May 7, 2022
nobuyo added a commit to nobuyo/rubocop that referenced this issue May 7, 2022
… argument for method in else branch is hash without braces
nobuyo added a commit to nobuyo/rubocop that referenced this issue May 7, 2022
… argument for method in else branch is hash without braces

Update spec/rubocop/cop/style/redundant_condition_spec.rb

Co-authored-by: Koichi ITO <koic.ito@gmail.com>
koic added a commit that referenced this issue May 7, 2022
…dant-condition-with-hash

[Fix #10605] Fix autocorrect for `Style/RedundantCondition`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants