Sha256: 80227fdd51d12afa5da6cf608ca6d66807499f7dcd63d167e7824e1ed5c7b834

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 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:
          threshold = options[:threshold] || DEFAULT_THRESHOLD
          super([:defn, :defs], threshold)
        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

12 entries across 12 versions & 2 rubygems

Version Path
simplabs-excellent-1.2.1 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.2.2 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.3.0 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.3.1 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.4.0 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.4.1 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.4.2 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.5.0 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.5.1 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.5.2 lib/simplabs/excellent/checks/flog_method_check.rb
simplabs-excellent-1.5.3 lib/simplabs/excellent/checks/flog_method_check.rb
excellent-1.5.4 lib/simplabs/excellent/checks/flog_method_check.rb