class RuboCop::Cop::Style::MultilineWhenThen
end
arg2)
when bar then do_something(arg1,
case foo
# good
end
when bar then do_something
case foo
# good
end
when bar
case foo
# good
end
when bar then
case foo
# bad
@example
in multi-line when statements.
Checks uses of the ‘then` keyword
def on_when(node)
def on_when(node) return if !node.then? || require_then?(node) range = node.loc.begin add_offense(range) do |corrector| corrector.remove(range_with_surrounding_space(range, side: :left, newlines: false)) end end
def require_then?(when_node)
def require_then?(when_node) unless when_node.conditions.first.first_line == when_node.conditions.last.last_line return true end return false unless when_node.body same_line?(when_node, when_node.body) end