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

0.38.0: Style/Next autocorrection breaks files without Style/MultilineIfThen #2947

Closed
dabroz opened this issue Mar 11, 2016 · 0 comments
Closed

Comments

@dabroz
Copy link
Contributor

dabroz commented Mar 11, 2016

I know, this is quite a corner case. However I found that Style/Next autocorrection can break valid Ruby files unless Style/MultilineIfThen is also enabled.

Test case

# rubocop:disable Style/MultilineIfThen

[].each do |a|
  if a then
    puts
    puts
    puts
  end
end

Expected behavior

Either file doesn't get modified, or invalid then is removed during the transformation.

Actual behavior

[].each do |a|
  next unless a then
  puts
  puts
  puts
end

(which is invalid Ruby code)

Steps to reproduce the problem

  1. Put test case in a test.rb file
  2. Run rubocop -a

RuboCop version

0.38.0 (using Parser 2.3.0.6, running on ruby 2.2.4 x86_64-darwin14)
bbatsov added a commit that referenced this issue Mar 13, 2016
[Fix #2947] Next handles then keyword
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