class RuboCop::Cop::Style::WhenThen

This cop checks for when; uses in case expressions.

Constants

MSG

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/style/when_then.rb, line 15
def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.loc.begin, ' then')
  end
end
on_when(node) click to toggle source
# File lib/rubocop/cop/style/when_then.rb, line 9
def on_when(node)
  return if node.multiline? || node.then? || !node.body

  add_offense(node, location: :begin)
end