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-5.6.2 lib/danger/danger_core/messages/violation.rb
danger-5.6.1 lib/danger/danger_core/messages/violation.rb
danger-5.6.0 lib/danger/danger_core/messages/violation.rb
danger-5.5.13 lib/danger/danger_core/messages/violation.rb
danger-5.5.12 lib/danger/danger_core/messages/violation.rb
danger-5.5.11 lib/danger/danger_core/messages/violation.rb
danger-5.5.10 lib/danger/danger_core/messages/violation.rb
danger-5.5.9 lib/danger/danger_core/messages/violation.rb
danger-5.5.8 lib/danger/danger_core/messages/violation.rb
danger-5.5.7 lib/danger/danger_core/messages/violation.rb