Sha256: 33133d7482484256c4f49ccba6658c9e35a24e8d0555c7f2eb5e8fa8102703f9

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 Bytes

Contents

$:.unshift File.dirname(__FILE__)

require 'reek/smells/smell'

module Reek
  module Smells

    #
    # A Long Method is any method that has a large number of lines.
    #
    # Currently +LongMethod+ reports any method with more than
    # +MAX_ALLOWED+ statements.
    #
    class LongMethod < Smell

      MAX_ALLOWED = 5

      def self.examine(method, report)
        return if method.name == 'initialize'
        num = method.num_statements
        report << new(method, num) if num > MAX_ALLOWED
      end

      def initialize(context, num)
        super(context)
        @num_stmts = num
      end

      def detailed_report
        "#{@context} has approx #{@num_stmts} statements"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reek-0.3.1 lib/reek/smells/long_method.rb