Class: Roodi::Checks::NpathComplexityCheck
- Defined in:
- lib/roodi/checks/npath_complexity_check.rb
Overview
Checks NPATH complexity of a node
NPATH counts acyclic execution paths in a piece of code. Here is an article by Brian A. Nejmeh that explains it in more detail: www.accessmylibrary.com/article-1G1-6242192/npath-measure-execution-path.html
Direct Known Subclasses
Constant Summary collapse
- MULTIPLYING_NODE_TYPES =
, :when, :and, :or
[:if, :while, :until, :for, :case]
- ADDING_NODE_TYPES =
[:rescue]
- COMPLEXITY_NODE_TYPES =
MULTIPLYING_NODE_TYPES + ADDING_NODE_TYPES
Constants inherited from Check
Instance Attribute Summary collapse
-
#complexity ⇒ Object
Returns the value of attribute complexity.
Instance Method Summary collapse
- #evalute_start_case(node) ⇒ Object
- #evalute_start_for(node) ⇒ Object
- #evalute_start_if(node) ⇒ Object
- #evalute_start_rescue(node) ⇒ Object
- #evalute_start_until(node) ⇒ Object
- #evalute_start_while(node) ⇒ Object
-
#initialize(complexity) ⇒ NpathComplexityCheck
constructor
A new instance of NpathComplexityCheck.
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(complexity) ⇒ NpathComplexityCheck
Returns a new instance of NpathComplexityCheck.
18 19 20 21 22 23 |
# File 'lib/roodi/checks/npath_complexity_check.rb', line 18 def initialize(complexity) super() @complexity = complexity @value_stack = [] @current_value = 1 end |
Instance Attribute Details
#complexity ⇒ Object
Returns the value of attribute complexity.
16 17 18 |
# File 'lib/roodi/checks/npath_complexity_check.rb', line 16 def complexity @complexity end |
Instance Method Details
#evalute_start_case(node) ⇒ Object
41 42 43 |
# File 'lib/roodi/checks/npath_complexity_check.rb', line 41 def evalute_start_case(node) push_value end |
#evalute_start_for(node) ⇒ Object
37 38 39 |
# File 'lib/roodi/checks/npath_complexity_check.rb', line 37 def evalute_start_for(node) push_value end |
#evalute_start_if(node) ⇒ Object
25 26 27 |
# File 'lib/roodi/checks/npath_complexity_check.rb', line 25 def evalute_start_if(node) push_value end |
#evalute_start_rescue(node) ⇒ Object
45 46 47 |
# File 'lib/roodi/checks/npath_complexity_check.rb', line 45 def evalute_start_rescue(node) push_value end |
#evalute_start_until(node) ⇒ Object
33 34 35 |
# File 'lib/roodi/checks/npath_complexity_check.rb', line 33 def evalute_start_until(node) push_value end |
#evalute_start_while(node) ⇒ Object
29 30 31 |
# File 'lib/roodi/checks/npath_complexity_check.rb', line 29 def evalute_start_while(node) push_value end |