Class: Roodi::Checks::NpathComplexityMethodCheck
- Inherits:
-
NpathComplexityCheck
- Object
- Check
- NpathComplexityCheck
- Roodi::Checks::NpathComplexityMethodCheck
- Defined in:
- lib/roodi/checks/npath_complexity_method_check.rb
Overview
Checks NPATH complexity of a method against a specified limit.
Constant Summary collapse
- DEFAULT_COMPLEXITY =
8
Constants inherited from NpathComplexityCheck
Roodi::Checks::NpathComplexityCheck::ADDING_NODE_TYPES, Roodi::Checks::NpathComplexityCheck::COMPLEXITY_NODE_TYPES, Roodi::Checks::NpathComplexityCheck::MULTIPLYING_NODE_TYPES
Constants inherited from Check
Instance Attribute Summary
Attributes inherited from NpathComplexityCheck
Instance Method Summary collapse
- #evaluate_end_defn(node) ⇒ Object
- #evaluate_start_defn(node) ⇒ Object
-
#initialize ⇒ NpathComplexityMethodCheck
constructor
A new instance of NpathComplexityMethodCheck.
- #interesting_nodes ⇒ Object
Methods inherited from NpathComplexityCheck
#evalute_start_case, #evalute_start_for, #evalute_start_if, #evalute_start_rescue, #evalute_start_until, #evalute_start_while
Methods inherited from Check
#add_error, #end_file, #errors, #evaluate_end, #evaluate_node, #evaluate_node_end, #evaluate_node_start, #evaluate_start, make, #position, #start_file
Constructor Details
#initialize ⇒ NpathComplexityMethodCheck
Returns a new instance of NpathComplexityMethodCheck.
10 11 12 |
# File 'lib/roodi/checks/npath_complexity_method_check.rb', line 10 def initialize super(DEFAULT_COMPLEXITY) end |
Instance Method Details
#evaluate_end_defn(node) ⇒ Object
23 24 25 |
# File 'lib/roodi/checks/npath_complexity_method_check.rb', line 23 def evaluate_end_defn(node) add_error "Method name \"#{@method_name}\" n-path complexity is #{@current_value}. It should be #{@complexity} or less." unless @current_value <= @complexity end |
#evaluate_start_defn(node) ⇒ Object
18 19 20 21 |
# File 'lib/roodi/checks/npath_complexity_method_check.rb', line 18 def evaluate_start_defn(node) @method_name = @node[1] push_value end |
#interesting_nodes ⇒ Object
14 15 16 |
# File 'lib/roodi/checks/npath_complexity_method_check.rb', line 14 def interesting_nodes [:defn] + COMPLEXITY_NODE_TYPES end |