Sha256: 9175a2d80f9e344604b97648cb252b256bea14fdbe6bf62b2a715a248903be2c

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 Bytes

Contents

$:.unshift File.dirname(__FILE__)

require 'reek/smells/smell'

module Reek
  module Smells

    # 
    # A Utility Function is any instance method that has no
    # dependency on the state of the instance.
    #
    class UtilityFunction < Smell

      #
      # Checks whether the given +method+ is a utility function.
      # Any smells found are added to the +report+; returns true in that case,
      # and false otherwise.
      #
      def self.examine(method, report)
        return false if method.name == 'initialize'
        if method.num_statements > 0 and !method.depends_on_self
          report << new(method)
          true
        end
        false
      end

      def detailed_report
        "#{@context} doesn't depend on instance state"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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