Class: RuboCop::Cop::AliasMethodOrderVerifier

Inherits:
Object
  • Object
show all
Extended by:
IgnoredNode, QualifierNodeMatchers
Defined in:
lib/rubocop/cop/alias_method_order_verifier.rb

Overview

This verifies a method is defined before its alias

Constant Summary collapse

ALIAS_BEFORE_METHOD_WARNING_FMT =

Disable cop for freezing on Ruby 2.2 rubocop:disable Style/RedundantFreeze

"Won't reorder " \
'%<first_method_name>s and %<second_method_name>s because ' \
'alias for %<first_method_name>s would be declared before ' \
'its method definition.'.freeze

Constants included from QualifierNodeMatchers

QualifierNodeMatchers::QUALIFIERS

Class Method Summary collapse

Methods included from QualifierNodeMatchers

method_qualifier?, qualifiers

Class Method Details

.verify!(current_node, previous_node) ⇒ Object

rubocop:disable Style/GuardClause



22
23
24
25
26
27
28
29
30
31
# File 'lib/rubocop/cop/alias_method_order_verifier.rb', line 22

def verify!(current_node, previous_node)
  if moving_after_alias?(current_node, previous_node)
    ignore_node(current_node)
    raise_warning!(current_node.method_name, previous_node.method_name)
  end
  if moving_after_alias?(previous_node, current_node)
    ignore_node(previous_node)
    raise_warning!(previous_node.method_name, current_node.method_name)
  end
end