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/MultilineWhenThen breaks some single line case statements #7635
Labels
Comments
The given code and the auto-corrected code are the same. Can you show me a reproducible given code? |
🤦♂ Let me find the correct example code |
Alright I've updated to show that RuboCop just nukes the first |
Hi, this is still an issue with RuboCop 0.82.0 I have a working reduced test case Original file# frozen_string_literal: true
def bar
[]
end
def foo(arg)
case arg
when 'one' then [1]
when 'two' then bar ||
[3]
when 'three' then [4]
end
end
puts foo('one') Run Original File
RuboCop output
RuboCop autofix (safe)
Fixed file# frozen_string_literal: true
def bar
[]
end
def foo(arg)
case arg
when 'one' then [1]
when 'two' bar ||
[3]
when 'three' then [4]
end
end
puts foo('one') Run fixed file
|
8 tasks
koic
added a commit
to koic/rubocop
that referenced
this issue
Apr 19, 2020
Fixes rubocop#7635 This PR fixes a false positive for `Style/MultilineWhenThen` when `then` required for a body of `when` is used.
bbatsov
pushed a commit
that referenced
this issue
Apr 20, 2020
Fixes #7635 This PR fixes a false positive for `Style/MultilineWhenThen` when `then` required for a body of `when` is used.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
Style/MultilineWhenThen should detect multiline when statements with a then, but should not detect strange compact when/then statements.
Actual behavior
Given a compact case statement like this rubocop alerts Style/MultilineWhenThen:
This will autocorrect to:
RuboCop version
The text was updated successfully, but these errors were encountered: