Sha256: 450020b9e5d2fa5b2935564fa212a7107ea5d0163ae52348ef19c4999846d8b2

Contents?: true

Size: 1.03 KB

Versions: 50

Compression:

Stored size: 1.03 KB

Contents

module Danger
  class Violation
    attr_accessor :message, :sticky, :file, :line

    def initialize(message, sticky, file = nil, line = nil)
      self.message = message
      self.sticky = sticky
      self.file = file
      self.line = line
    end

    def ==(other)
      return false if other.nil?
      return false unless other.kind_of? self.class

      other.message == message &&
        other.sticky == sticky &&
        other.file == file &&
        other.line == line
    end

    def hash
      h = 1
      h = h * 31 + message.hash
      h = h * 13 + sticky.hash
      h = h * 17 + file.hash
      h = h * 17 + line.hash
      h
    end

    def eql?(other)
      return self == other
    end

    # @return [Boolean] returns true if is a file or line, false otherwise
    def inline?
      file || line
    end

    def to_s
      extra = []
      extra << "sticky: #{sticky}"
      extra << "file: #{file}" if file
      extra << "line: #{line}" if line

      "Violation #{message} { #{extra.join ', '.freeze} }"
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
danger-6.3.1 lib/danger/danger_core/messages/violation.rb
danger-6.3.0 lib/danger/danger_core/messages/violation.rb
danger-6.2.2 lib/danger/danger_core/messages/violation.rb
danger-6.2.1 lib/danger/danger_core/messages/violation.rb
danger-6.2.0 lib/danger/danger_core/messages/violation.rb
danger-6.1.0 lib/danger/danger_core/messages/violation.rb
danger-6.0.9 lib/danger/danger_core/messages/violation.rb
danger-6.0.8 lib/danger/danger_core/messages/violation.rb
danger-6.0.7 lib/danger/danger_core/messages/violation.rb
danger-6.0.6 lib/danger/danger_core/messages/violation.rb
danger-6.0.5 lib/danger/danger_core/messages/violation.rb
danger-6.0.4 lib/danger/danger_core/messages/violation.rb
danger-6.0.3 lib/danger/danger_core/messages/violation.rb
danger-6.0.2 lib/danger/danger_core/messages/violation.rb
danger-6.0.1 lib/danger/danger_core/messages/violation.rb
danger-6.0.0 lib/danger/danger_core/messages/violation.rb
danger-5.16.1 lib/danger/danger_core/messages/violation.rb
danger-5.16.0 lib/danger/danger_core/messages/violation.rb
danger-5.15.0 lib/danger/danger_core/messages/violation.rb
danger-5.14.0 lib/danger/danger_core/messages/violation.rb