Class Roodi::Checks::CyclomaticComplexityCheck
In: lib/roodi/checks/cyclomatic_complexity_check.rb
Parent: Roodi::Checks::Check

Methods

Constants

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

Public Class methods

[Source]

# File lib/roodi/checks/cyclomatic_complexity_check.rb, line 8
      def initialize(complexity)
        super()
        @complexity = complexity
        @count = 0
        @counting = 0
      end

Protected Instance methods

[Source]

# File lib/roodi/checks/cyclomatic_complexity_check.rb, line 23
      def count_complexity(node)
        count_branches(node) + 1
      end

[Source]

# File lib/roodi/checks/cyclomatic_complexity_check.rb, line 32
      def decrease_depth
        @counting = @counting - 1
        if @counting <= 0
          @counting = 0
          evaluate_matching_end
        end
      end

[Source]

# File lib/roodi/checks/cyclomatic_complexity_check.rb, line 27
      def increase_depth
        @count = 1 unless counting?
        @counting = @counting + 1
      end

[Validate]