You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def mock_node(group, policy, number)
net = case group; when 'dev' then 1; when 'prod' then 2; else 0; end
subnet = case policy; when 'varn' then 1; when 'web' then 2; else 0; end
# more method body here
end
Actual behavior
The above code fails, since Rubocop appears to expect all case statements to span multiple lines:
$ rubocop -fs
== my_file.rb ==
C: 6: 25: Indent when as deep as case.
C: 6: 44: Indent when as deep as case.
C: 7: 29: Indent when as deep as case.
C: 7: 49: Indent when as deep as case.
[snip]
RuboCop version
0.46.0 (using Parser 2.3.3.1, running on ruby 2.3.1 x86_64-linux)
The text was updated successfully, but these errors were encountered:
jayhendren
changed the title
"Indent when as deep as case" doesn't recognize single-line case statements.
Style/CaseIndentation doesn't recognize single-line case statements.
Mar 15, 2017
Yeah, something like net = {'dev' => 1, 'prod' => 2}.fetch(group, 0) would probably work just as well in this scenario. Personally, I have no strong opinions on whether or not that style is easier to read.
Drenmi
added a commit
to Drenmi/rubocop
that referenced
this issue
Mar 22, 2017
Expected behavior
I expect the following code to pass Rubocop:
Actual behavior
The above code fails, since Rubocop appears to expect all case statements to span multiple lines:
RuboCop version
The text was updated successfully, but these errors were encountered: