Sha256: f91d3d5ebd943df776f17109ca381b830f9875a2d44973eafc3fc5953e5e8d4c

Contents?: true

Size: 994 Bytes

Versions: 11

Compression:

Stored size: 994 Bytes

Contents

# typed: strict
# frozen_string_literal: true

require "parser/source/map"

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

    sig { returns(T.nilable(Node::Location)) }
    attr_reader :location

    sig { returns(String) }
    attr_reader :file

    sig { returns(String) }
    attr_reader :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)
      location = self.location
      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

11 entries across 11 versions & 1 rubygems

Version Path
packwerk-3.2.2 lib/packwerk/offense.rb
packwerk-3.2.1 lib/packwerk/offense.rb
packwerk-3.2.0 lib/packwerk/offense.rb
packwerk-3.1.0 lib/packwerk/offense.rb
packwerk-3.0.1 lib/packwerk/offense.rb
packwerk-3.0.0 lib/packwerk/offense.rb
packwerk-2.3.0 lib/packwerk/offense.rb
packwerk-2.2.2 lib/packwerk/offense.rb
packwerk-2.2.1 lib/packwerk/offense.rb
packwerk-2.2.0 lib/packwerk/offense.rb
packwerk-2.1.1 lib/packwerk/offense.rb