如何正确设置 rubocop 大小写缩进
How to set rubocop case indentation correctly
如何让 rubo-cop 接受以下情况 select:
variable = case some_other_variable
when 'some value' then 'some result'
when 'some other value' then 'some other result'
when 'one more value' then 'one more result'
end
我的 .rubocop.yml
:
目前有这个
CaseIndentation:
EnforcedStyle: end
IndentOneStep: true
但是一直报这样的错误:
C: Layout/CaseIndentation: Indent when one step more than end.
when 'some value' then 'some result'
我做错了什么,我该如何解决?
它说
- Indent when as deep as case
- When assigning the result of a conditional expression to a variable,
preserve the usual alignment of its branches
所以它可能对 Rubocop 有效:
variable = case some_other_variable
when 'some value' then 'some result'
when 'some other value' then 'some other result'
when 'one more value' then 'one more result'
end
或者这样
variable =
case some_other_variable
when 'some value' then 'some result'
when 'some other value' then 'some other result'
when 'one more value' then 'one more result'
end
如何让 rubo-cop 接受以下情况 select:
variable = case some_other_variable
when 'some value' then 'some result'
when 'some other value' then 'some other result'
when 'one more value' then 'one more result'
end
我的 .rubocop.yml
:
CaseIndentation:
EnforcedStyle: end
IndentOneStep: true
但是一直报这样的错误:
C: Layout/CaseIndentation: Indent when one step more than end.
when 'some value' then 'some result'
我做错了什么,我该如何解决?
它说
- Indent when as deep as case
- When assigning the result of a conditional expression to a variable, preserve the usual alignment of its branches
所以它可能对 Rubocop 有效:
variable = case some_other_variable
when 'some value' then 'some result'
when 'some other value' then 'some other result'
when 'one more value' then 'one more result'
end
或者这样
variable =
case some_other_variable
when 'some value' then 'some result'
when 'some other value' then 'some other result'
when 'one more value' then 'one more result'
end