class RuboCop::Cop::Style::ElseAlignment
def on_if(node, base = nil)
def on_if(node, base = nil) return if ignored_node?(node) return unless node.loc.respond_to?(:else) return if node.loc.else.nil? else_range = node.loc.else return unless begins_its_line?(else_range) check_alignment(base_range(node, base), else_range) return if else_range.source != 'elsif' # If the `else` part is actually an `elsif`, we check the `elsif` # node in case it contains an `else` within, because that `else` # should have the same alignment (base). _condition, _if_body, else_body = *node on_if(else_body, base) # The `elsif` node will get an `on_if` call from the framework later, # but we're done here, so we set it to ignored. ignore_node(else_body) end