Sha256: 2b127a1bbc2aea5d5948a2770291f32bb20d4b0f066a4c9890d4776a1cd28f62

Contents?: true

Size: 1010 Bytes

Versions: 4

Compression:

Stored size: 1010 Bytes

Contents

# typed: true
# frozen_string_literal: true

require "packwerk/violation_type"
require "packwerk/checker"

module Packwerk
  class DependencyChecker
    include Checker

    def violation_type
      ViolationType::Dependency
    end

    def invalid_reference?(reference, reference_lister)
      return unless reference.source_package
      return unless reference.source_package.enforce_dependencies?
      return if reference.source_package.dependency?(reference.constant.package)
      return if reference_lister.listed?(reference, violation_type: violation_type)
      true
    end

    def message_for(reference)
      "Dependency violation: #{reference.constant.name} belongs to '#{reference.constant.package}', but " \
        "'#{reference.source_package}' does not specify a dependency on " \
        "'#{reference.constant.package}'.\n" \
        "Are we missing an abstraction?\n" \
        "Is the code making the reference, and the referenced constant, in the right packages?\n"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
packwerk-1.1.1 lib/packwerk/dependency_checker.rb
packwerk-1.1.0 lib/packwerk/dependency_checker.rb
packwerk-1.0.2 lib/packwerk/dependency_checker.rb
packwerk-1.0.1 lib/packwerk/dependency_checker.rb