class Rubocop::Cop::Style::CaseIndentation

This cop checks whether the *when*s of a case expression are indented as deep as its case keyword.

It will register a separate offence for each misaligned when.

Constants

MSG

Public Instance Methods

on_case(case_node) click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/case_indentation.rb, line 13
def on_case(case_node)
  _condition, *whens, _else = *case_node

  case_column = case_node.location.keyword.column

  whens.each do |when_node|
    pos = when_node.loc.keyword
    add_offence(:convention, pos, MSG) if pos.column != case_column
  end

  super
end