class RuboCop::Cop::Lint::EmptyWhen

This cop checks for the presence of `when` branches without a body.

@example

# bad

case foo
when bar then 1
when baz then # nothing
end

@example

# good

case foo
when bar then 1
when baz then 2
end

Constants

MSG

Public Instance Methods

on_case(node) click to toggle source
# File lib/rubocop/cop/lint/empty_when.rb, line 28
def on_case(node)
  node.each_when do |when_node|
    next if when_node.body

    add_offense(when_node, location: when_node.source_range)
  end
end