Sha256: 9e7eb12c7eb5c89954335823900b59143760addec211a64e453193c55339ca85
Contents?: true
Size: 736 Bytes
Versions: 2
Compression:
Stored size: 736 Bytes
Contents
require 'simplabs/excellent/checks/base' module Simplabs module Excellent module Checks class CyclomaticComplexityCheck < Base COMPLEXITY_NODE_TYPES = [:if, :while, :until, :for, :rescue, :case, :when, :and, :or] def initialize(threshold) super() @threshold = threshold end protected def count_complexity(node) count_branches(node) + 1 end private def count_branches(node) count = 0 count = count + 1 if COMPLEXITY_NODE_TYPES.include? node.node_type node.children.each { |child| count += count_branches(child) } count end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simplabs-excellent-1.0.0 | lib/simplabs/excellent/checks/cyclomatic_complexity_check.rb |
simplabs-excellent-1.0.1 | lib/simplabs/excellent/checks/cyclomatic_complexity_check.rb |