Sha256: 032fdfe75ade41db5b8b05921a62cbf954d8d9adf6c32c1e2895dd3ec8972cfd

Contents?: true

Size: 717 Bytes

Versions: 7

Compression:

Stored size: 717 Bytes

Contents

require "virtus"
require "rubycritic/core/location"

module Rubycritic

  class Smell
    include Virtus.model

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

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

    def has_multiple_locations?
      locations.length > 1
    end

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

    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

7 entries across 7 versions & 1 rubygems

Version Path
rubycritic-1.1.1 lib/rubycritic/core/smell.rb
rubycritic-1.1.0 lib/rubycritic/core/smell.rb
rubycritic-1.0.2 lib/rubycritic/core/smell.rb
rubycritic-1.0.1 lib/rubycritic/core/smell.rb
rubycritic-1.0.0 lib/rubycritic/core/smell.rb
rubycritic-0.0.16 lib/rubycritic/core/smell.rb
rubycritic-0.0.15 lib/rubycritic/core/smell.rb