class RuboCop::Cop::Style::MultilineWhenThen

def on_when(node)

def on_when(node)
  # Without `then`, there's no offense
  return unless node.then?
  # Single line usage of `then` is not an offense
  return if !node.children.last.nil? && !node.multiline?
  # Requires `then` for write `when` and its body on the same line.
  return if require_then?(node)
  # For arrays and hashes there's no offense
  return if accept_node_type?(node.body)
  range = node.loc.begin
  add_offense(range) do |corrector|
    corrector.remove(
      range_with_surrounding_space(range: range, side: :left, newlines: false)
    )
  end
end