lib/packwerk/run_context.rb in packwerk-1.3.2 vs lib/packwerk/run_context.rb in packwerk-1.4.0

- old
+ new

@@ -2,10 +2,11 @@ # frozen_string_literal: true require "constant_resolver" module Packwerk + # Holds the context of a Packwerk run across multiple files. class RunContext extend T::Sig attr_reader( :root_path, @@ -15,12 +16,12 @@ :custom_associations, :checker_classes, ) DEFAULT_CHECKERS = [ - ::Packwerk::DependencyChecker, - ::Packwerk::PrivacyChecker, + ::Packwerk::ReferenceChecking::Checkers::DependencyChecker, + ::Packwerk::ReferenceChecking::Checkers::PrivacyChecker, ] class << self def from_configuration(configuration) inflector = ::Packwerk::Inflector.from_file(configuration.inflections_file) @@ -48,13 +49,16 @@ @inflector = inflector @custom_associations = custom_associations @checker_classes = checker_classes end - sig { params(file: String).returns(T::Array[T.nilable(::Packwerk::Offense)]) } + sig { params(file: String).returns(T::Array[Packwerk::Offense]) } def process_file(file:) - file_processor.call(file) + references = file_processor.call(file) + + reference_checker = ReferenceChecking::ReferenceChecker.new(checkers) + references.flat_map { |reference| reference_checker.call(reference) } end private sig { returns(FileProcessor) } @@ -64,11 +68,10 @@ sig { returns(NodeProcessorFactory) } def node_processor_factory NodeProcessorFactory.new( context_provider: context_provider, - checkers: checkers, root_path: root_path, constant_name_inspectors: constant_name_inspectors ) end @@ -92,10 +95,10 @@ sig { returns(PackageSet) } def package_set ::Packwerk::PackageSet.load_all_from(root_path, package_pathspec: package_paths) end - sig { returns(T::Array[Checker]) } + sig { returns(T::Array[ReferenceChecking::Checkers::Checker]) } def checkers checker_classes.map(&:new) end sig { returns(T::Array[ConstantNameInspector]) }