Sha256: 401729b0a75918cae58d1cafbb7a736a6ba7a0f5a901c32769e4342f8692575e
Contents?: true
Size: 981 Bytes
Versions: 2
Compression:
Stored size: 981 Bytes
Contents
require 'roodi/checks/check' module Roodi module Checks class CyclomaticComplexityCheck < Check COMPLEXITY_NODE_TYPES = [:if, :while, :until, :for, :rescue, :case, :when, :and, :or] def initialize(complexity) super() @complexity = complexity @count = 0 @counting = 0 end COMPLEXITY_NODE_TYPES.each do |type| define_method "evaluate_start_#{type}" do |node| @count = @count + 1 if counting? end end protected def count_complexity(node) count_branches(node) + 1 end def increase_depth @count = 1 unless counting? @counting = @counting + 1 end def decrease_depth @counting = @counting - 1 if @counting <= 0 @counting = 0 evaluate_matching_end end end private def counting? @counting > 0 end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
roodi1.9-2.0.1 | lib/roodi/checks/cyclomatic_complexity_check.rb |
roodi-2.1.0 | lib/roodi/checks/cyclomatic_complexity_check.rb |