Sha256: 648613d89f70d99072891eab0d1be595eeb183d3a172026797419a2a220c75be

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

require 'simplabs/excellent/checks/cyclomatic_complexity_check'

module Simplabs

  module Excellent

    module Checks

      class CyclomaticComplexityMethodCheck < CyclomaticComplexityCheck

        DEFAULT_THRESHOLD = 8

        def initialize(options = {})
          complexity = options[:threshold] || DEFAULT_THRESHOLD
          super(complexity)
        end

        def interesting_nodes
          [:defn]
        end

        def evaluate(node)
          score = count_complexity(node)
          add_error('Method {{method}} has cyclomatic complexity of {{score}}.', { :method => node[1], :score => score }) unless score <= @threshold
        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_method_check.rb
simplabs-excellent-1.0.1 lib/simplabs/excellent/checks/cyclomatic_complexity_method_check.rb