Sha256: b8a7aa861aad4e0315bb628c45e318b96bd93a0e39e470804f6afd0ae6a446a3

Contents?: true

Size: 863 Bytes

Versions: 8

Compression:

Stored size: 863 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 has_multiple_locations?
      locations.length > 1
    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

8 entries across 8 versions & 1 rubygems

Version Path
rubycritic-0.0.12 lib/rubycritic/smell.rb
rubycritic-0.0.11 lib/rubycritic/smell.rb
rubycritic-0.0.10 lib/rubycritic/smell.rb
rubycritic-0.0.9 lib/rubycritic/smell.rb
rubycritic-0.0.8 lib/rubycritic/smell.rb
rubycritic-0.0.7 lib/rubycritic/smell.rb
rubycritic-0.0.6 lib/rubycritic/smell.rb
rubycritic-0.0.5 lib/rubycritic/smell.rb