Sha256: d03469baacc118dd1dd2d84fac37e5300b0474f7ee0b67c5badf8f20f301ffbc

Contents?: true

Size: 1.24 KB

Versions: 20

Compression:

Stored size: 1.24 KB

Contents

module Simplabs

  module Excellent

    module Parsing

      module CyclomaticComplexityMeasure #:nodoc:

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

        def process_if(exp)
          add_complexity_score(1)
          super
        end

        def process_while(exp)
          add_complexity_score(1)
          super
        end

        def process_until(exp)
          add_complexity_score(1)
          super
        end

        def process_for(exp)
          add_complexity_score(1)
          super
        end

        def process_rescue(exp)
          add_complexity_score(1)
          super
        end

        def process_case(exp)
          add_complexity_score(1)
          super
        end

        def process_when(exp)
          add_complexity_score(1)
          super
        end

        def process_and(exp)
          add_complexity_score(1)
          super
        end

        def process_or(exp)
          add_complexity_score(1)
          super
        end

        def cc_score
          @cc_score + 1 rescue 1
        end

        private

          def add_complexity_score(score)
            @cc_score ||= 0
            @cc_score += score
          end

      end

    end

  end

end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
simplabs-excellent-1.2.1 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.2.2 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.3.0 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.3.1 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.4.0 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.4.1 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.4.2 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.5.0 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.5.1 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.5.2 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-2.1.1 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-2.1.0 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-2.0.1 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-2.0.0 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-1.7.2 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-1.7.1 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-1.7.0 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-1.6.0 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb
excellent-1.5.4 lib/simplabs/excellent/parsing/cyclomatic_complexity_measure.rb