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
# File lib/rubocop/cop/lint/end_alignment.rb, line 24 def on_class(node) check(node) end
# File lib/rubocop/cop/lint/end_alignment.rb, line 32 def on_if(node) check(node) if node.loc.respond_to?(:end) end
# File lib/rubocop/cop/lint/end_alignment.rb, line 28 def on_module(node) check(node) end
# 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
Generated with the Darkfish Rdoc Generator 2.