Class: Roodi::Checks::NpathComplexityCheck

Inherits:
Check
  • Object
show all
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

NpathComplexityMethodCheck

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

Check::NODE_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#complexityObject

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