Class: Rubocop::Cop::Lint::EndAlignment

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/lint/end_alignment.rb

Overview

This cop checks whether the end keywords are aligned properly.

For keywords (if, def, etc.) the end is aligned with the start of the keyword.

Examples:


variable = if true
           end

Constant Summary collapse

MSG =
'end at %d, %d is not aligned with %s at %d, %d'

Constants inherited from Cop

Cop::OPERATOR_METHODS

Instance Attribute Summary

Attributes inherited from Cop

#config, #corrections, #offences, #processed_source

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, all, #autocorrect?, #convention, #cop_config, cop_name, #cop_name, cop_type, #debug?, #ignore_node, inherited, #initialize, lint?, #message, non_rails, rails?, style?, #support_autocorrect?, #warning

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#on_class(node) ⇒ Object



26
27
28
# File 'lib/rubocop/cop/lint/end_alignment.rb', line 26

def on_class(node)
  check(node)
end

#on_def(node) ⇒ Object



18
19
20
# File 'lib/rubocop/cop/lint/end_alignment.rb', line 18

def on_def(node)
  check(node)
end

#on_defs(node) ⇒ Object



22
23
24
# File 'lib/rubocop/cop/lint/end_alignment.rb', line 22

def on_defs(node)
  check(node)
end

#on_if(node) ⇒ Object



34
35
36
# File 'lib/rubocop/cop/lint/end_alignment.rb', line 34

def on_if(node)
  check(node) if node.loc.respond_to?(:end)
end

#on_module(node) ⇒ Object



30
31
32
# File 'lib/rubocop/cop/lint/end_alignment.rb', line 30

def on_module(node)
  check(node)
end

#on_until(node) ⇒ Object



42
43
44
# File 'lib/rubocop/cop/lint/end_alignment.rb', line 42

def on_until(node)
  check(node)
end

#on_while(node) ⇒ Object



38
39
40
# File 'lib/rubocop/cop/lint/end_alignment.rb', line 38

def on_while(node)
  check(node)
end