Ruby 如何正确设置rubocop案例缩进
如何让rubo cop接受以下正确的案例选择:Ruby 如何正确设置rubocop案例缩进,ruby,rubocop,Ruby,Rubocop,如何让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: Enforc
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'
我做错了什么?我该如何修复它
- 缩进深度与大小写一样深
- 将条件表达式的结果赋给变量时, 保持其分支的常规对齐
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
也许是这样,但我们希望它像在OP中显示的一样,我知道应该可以像这样设置:,我只是想知道如何使用当前版本的rubocop。那么你为什么不在问题中问这个问题?:'-)由于该问题始于2013年,且
indentwhenrelative
已重命名为EnforcedStyle
,因此该选项很可能不再有效。正如@jonas054所指出的,我无法让它工作。