Sha256: 7ff856575d5bc820aa17a25fbe8fe468160d2bb797f552a290e22bdcbde85234

Contents?: true

Size: 795 Bytes

Versions: 3

Compression:

Stored size: 795 Bytes

Contents

require "virtus"
require "rubycritic/location"

module Rubycritic

  class Smell
    include Virtus.model

    attribute :context
    attribute :locations
    attribute :message
    attribute :score
    attribute :type
    attribute :status

    def pathnames
      @pathnames ||= locations.map(&:pathname).uniq
    end

    def located_in?(other_location)
      locations.any? { |location| location == other_location }
    end

    def ==(other)
      self.class == other.class && state == other.state
    end
    alias_method :eql?, :==

    def <=>(other)
      locations <=> other.locations
    end

    def to_s
      "(#{type}) #{context} #{message}"
    end

    def hash
      state.hash
    end

    protected

    def state
      [@context, @message, @score, @type]
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubycritic-0.0.4 lib/rubycritic/smell.rb
rubycritic-0.0.3 lib/rubycritic/smell.rb
rubycritic-0.0.2 lib/rubycritic/smell.rb