Class: Roodi::Checks::CyclomaticComplexityCheck

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

Overview

Cyclomatic complexity counts the number of linearly independent paths in the code. The lower the score, the better.

Read more in the inventor Thomas J. McCabe’s original research paper: www.literateprogramming.com/mccabe.pdf

Constant Summary collapse

COMPLEXITY_NODE_TYPES =
[:if, :while, :until, :for, :rescue, :case, :when, :and, :or]

Constants inherited from Check

Roodi::Checks::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

#initializeCyclomaticComplexityCheck

Returns a new instance of CyclomaticComplexityCheck.



16
17
18
19
20
# File 'lib/roodi/checks/cyclomatic_complexity_check.rb', line 16

def initialize
  super()
  @count = 0
  @counting = 0
end

Instance Attribute Details

#complexityObject

Returns the value of attribute complexity.



14
15
16
# File 'lib/roodi/checks/cyclomatic_complexity_check.rb', line 14

def complexity
  @complexity
end