Sha256: d9509effc702f579cb5fab85708504c6af40ff6d55e817f5d34ff5dd17ba8756

Contents?: true

Size: 871 Bytes

Versions: 3

Compression:

Stored size: 871 Bytes

Contents

require 'simplabs/excellent/checks/line_count_check'

module Simplabs

  module Excellent

    module Checks

      # This check reports methods which have more lines than the threshold. Methods with a large number of lines are hard to read and understand
      # and often an indicator for badly designed code as well.
      #
      # ==== Applies to
      #
      # * methods
      class MethodLineCountCheck < LineCountCheck

        DEFAULT_THRESHOLD = 20

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

        protected

          def warning_args(context) #:nodoc:
            [context, '{{method}} has {{count}} lines.', { :method => context.full_name, :count => context.line_count + 1 }]
          end

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
excellent-1.7.2 lib/simplabs/excellent/checks/method_line_count_check.rb
excellent-1.7.1 lib/simplabs/excellent/checks/method_line_count_check.rb
excellent-1.7.0 lib/simplabs/excellent/checks/method_line_count_check.rb