Sha256: b27bff4c950e58106f15ac8852e65190cd2c7fa132f68e2594d0a5c884196bfd

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require 'simplabs/excellent/checks/flog_check'

module Simplabs

  module Excellent

    module Checks

      # This check reports methods with a Flog metric score that is higher than the threshold. The Flog metric is very similar to the cyclomatic complexity
      # measure but also takes Ruby specific statements into account. For example, calls to metaprogramming methods such as +define_method+ or
      # +class_eval+ are weighted higher than regular method calls.
      #
      # Excellent does not calculate the score exactly the same way as Flog does, so scores may vary. For Flog also see
      # http://github.com/seattlerb/flog.
      #
      # ==== Applies to
      #
      # * methods
      class FlogMethodCheck < FlogCheck

        DEFAULT_THRESHOLD = 30

        def initialize(options = {}) #:nodoc:
          options[:threshold] ||= DEFAULT_THRESHOLD
          super([Parsing::MethodContext, Parsing::SingletonMethodContext], options)
        end

        protected

          def warning_args(context) #:nodoc:
            [context, '{{method}} has flog score of {{score}}.', { :method => context.full_name, :score => context.flog_score }]
          end

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
excellent-2.1.1 lib/simplabs/excellent/checks/flog_method_check.rb
excellent-2.1.0 lib/simplabs/excellent/checks/flog_method_check.rb
excellent-2.0.1 lib/simplabs/excellent/checks/flog_method_check.rb
excellent-2.0.0 lib/simplabs/excellent/checks/flog_method_check.rb