如何让 rubo-cop 接受以下案例选择的正确内容:
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
关于ruby - 如何正确设置 rubocop 大小写缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48786060/