Class: Roodi::Checks::CoreMethodOverrideCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/roodi/checks/core_method_override_check.rb

Overview

Checks a class to make sure it doesn’t override core methods on Object.

An example is when the ‘class’ method of a class is overriden. This causes code that tests the class of an object to fail.

Constant Summary

Constants inherited from Check

Roodi::Checks::Check::NODE_TYPES

Instance Method Summary collapse

Methods inherited from Check

#add_error, #end_file, #errors, #evaluate_end, #evaluate_node, #evaluate_node_end, #evaluate_node_start, #initialize, make, #position, #start_file

Constructor Details

This class inherits a constructor from Roodi::Checks::Check

Instance Method Details

#evaluate_start(node) ⇒ Object



15
16
17
18
19
# File 'lib/roodi/checks/core_method_override_check.rb', line 15

def evaluate_start(node)
  [ :class ].each do |core_name|
    add_error("Class overrides method '#{core_name}'.") if node[1] == core_name
  end
end

#interesting_nodesObject



11
12
13
# File 'lib/roodi/checks/core_method_override_check.rb', line 11

def interesting_nodes
  [:defn]
end