class RuboCop::Cop::Style::WhenThen
end
when 2 then ‘bar’
when 1 then ‘baz’
case foo
# good
end
when 2; ‘bar’
when 1; ‘baz’
case foo
# bad
@example
This cop checks for when; uses in case expressions.
def autocorrect(node)
def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.begin, ' then') end end
def on_when(node)
def on_when(node) return if node.multiline? || node.then? || !node.body add_offense(node, location: :begin) end