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

OneLineConditional auto-correct produces incorrect code #2950

Closed
jonas054 opened this issue Mar 12, 2016 · 0 comments
Closed

OneLineConditional auto-correct produces incorrect code #2950

jonas054 opened this issue Mar 12, 2016 · 0 comments

Comments

@jonas054
Copy link
Collaborator

In #2885, auto-correct functionality was added to Style/OneLineConditional, but it needs tweaking.
@lumeet will you take a look?

Expected behavior

if ARGV.size > 0 then puts 'a' else puts 'b' end

auto-corrected to

ARGV.size > 0 ? (puts 'a') : (puts 'b')

or possibly that no change is made in complicated cases where the AST would be changed.

Actual behavior

if ARGV.size > 0 then puts 'a' else puts 'b' end

auto-corrected to

ARGV.size > 0 ? puts 'a' : puts 'b'

which is a syntax error.

Steps to reproduce the problem

rubocop -a file.rb

RuboCop version

$ rubocop -V
0.38.0 (using Parser 2.3.0.6, running on ruby 2.3.0 x86_64-linux)

and also current master, 7d10599.

bbatsov added a commit that referenced this issue Mar 13, 2016
…ional

[Fix #2950] Fix correcting in OneLineConditional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant