class RubbyCop::Cop::Layout::IndentationConsistency

This cops checks for inconsistent indentation.

@example

class A
  def test
    puts 'hello'
     puts 'world'
  end
end

Constants

MSG

Public Instance Methods

on_begin(node) click to toggle source
# File lib/rubbycop/cop/layout/indentation_consistency.rb, line 23
def on_begin(node)
  check(node)
end
on_kwbegin(node) click to toggle source
# File lib/rubbycop/cop/layout/indentation_consistency.rb, line 27
def on_kwbegin(node)
  check(node)
end

Private Instance Methods

check(node) click to toggle source
# File lib/rubbycop/cop/layout/indentation_consistency.rb, line 33
def check(node)
  children_to_check = [[]]
  node.children.each do |child|
    # Modifier nodes have special indentation and will be checked by
    # the AccessModifierIndentation cop. This cop uses them as dividers
    # in rails mode. Then consistency is checked only within each
    # section delimited by a modifier node.
    if modifier_node?(child)
      children_to_check << [] if style == :rails
    else
      children_to_check.last << child
    end
  end
  children_to_check.each { |group| check_alignment(group) }
end