Sha256: 44320f276f8e7fb619ab97ed60757cce8f6e8807d8c068c15f6c1fe313804f83

Contents?: true

Size: 826 Bytes

Versions: 7

Compression:

Stored size: 826 Bytes

Contents

# typed: true
# frozen_string_literal: true

require "parser/source/map"

module Packwerk
  class Offense
    extend T::Sig
    extend T::Helpers

    attr_reader :location, :file, :message

    sig do
      params(file: String, message: String, location: T.nilable(Node::Location))
        .void
    end
    def initialize(file:, message:, location: nil)
      @location = location
      @file = file
      @message = message
    end

    sig { params(style: OutputStyle).returns(String) }
    def to_s(style = OutputStyles::Plain.new)
      if location
        <<~EOS
          #{style.filename}#{file}#{style.reset}:#{location.line}:#{location.column}
          #{@message}
        EOS
      else
        <<~EOS
          #{style.filename}#{file}#{style.reset}
          #{@message}
        EOS
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
packwerk-2.1.0 lib/packwerk/offense.rb
packwerk-2.0.0 lib/packwerk/offense.rb
packwerk-1.4.0 lib/packwerk/offense.rb
packwerk-1.3.2 lib/packwerk/offense.rb
packwerk-1.3.1 lib/packwerk/offense.rb
packwerk-1.3.0 lib/packwerk/offense.rb
packwerk-1.2.0 lib/packwerk/offense.rb