Sha256: 3b56e586603597cee14ac16d1453a35d35564c60c6574898dfc9e8fb66bf27e0

Contents?: true

Size: 846 Bytes

Versions: 3

Compression:

Stored size: 846 Bytes

Contents

# typed: true
# frozen_string_literal: true

module Packwerk
  module ReferenceChecking
    class ReferenceChecker
      extend T::Sig

      def initialize(checkers)
        @checkers = checkers
      end

      sig do
        params(
          reference: T.any(Packwerk::Reference, Packwerk::Offense)
        ).returns(T::Array[Packwerk::Offense])
      end
      def call(reference)
        return [reference] if reference.is_a?(Packwerk::Offense)

        @checkers.each_with_object([]) do |checker, violations|
          next unless checker.invalid_reference?(reference)
          offense = Packwerk::ReferenceOffense.new(
            location: reference.source_location,
            reference: reference,
            violation_type: checker.violation_type
          )
          violations << offense
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
packwerk-2.1.0 lib/packwerk/reference_checking/reference_checker.rb
packwerk-2.0.0 lib/packwerk/reference_checking/reference_checker.rb
packwerk-1.4.0 lib/packwerk/reference_checking/reference_checker.rb