Parent

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Lint::EndAlignment

This cop checks whether the end keywords are aligned properly.

Two modes are supported through the AlignWith configuration parameter. If it's set to `keyword` (which is the default), the `end` shall be aligned with the start of the keyword (if, def, etc.). If it's set to `variable` the `end` shall be aligned with the left-hand-side of the variable assignment, if there is one.

@example

variable = if true
           end

Constants

MSG

Public Instance Methods

on_class(node) click to toggle source
# File lib/rubocop/cop/lint/end_alignment.rb, line 24
def on_class(node)
  check(node)
end
on_if(node) click to toggle source
# File lib/rubocop/cop/lint/end_alignment.rb, line 32
def on_if(node)
  check(node) if node.loc.respond_to?(:end)
end
on_module(node) click to toggle source
# File lib/rubocop/cop/lint/end_alignment.rb, line 28
def on_module(node)
  check(node)
end
on_send(node) click to toggle source
# File lib/rubocop/cop/lint/end_alignment.rb, line 44
def on_send(node)
  super

  receiver, method_name, *args = *node
  return unless visibility_and_def_on_same_line?(receiver, method_name,
                                                 args)

  expr = node.loc.expression
  method_def = args.first
  range = Parser::Source::Range.new(expr.source_buffer,
                                    expr.begin_pos,
                                    method_def.loc.keyword.end_pos)
  check_offset(method_def, range.source,
               method_def.loc.keyword.begin_pos - expr.begin_pos)
  ignore_node(method_def) # Don't check the same `end` again.
end
on_until(node) click to toggle source
# File lib/rubocop/cop/lint/end_alignment.rb, line 40
def on_until(node)
  check(node)
end
on_while(node) click to toggle source
# File lib/rubocop/cop/lint/end_alignment.rb, line 36
def on_while(node)
  check(node)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.