lib/packwerk/run_context.rb in packwerk-2.2.1 vs lib/packwerk/run_context.rb in packwerk-2.2.2
- old
+ new
@@ -69,10 +69,11 @@
@cache_directory = cache_directory
@config_path = config_path
@file_processor = T.let(nil, T.nilable(FileProcessor))
@context_provider = T.let(nil, T.nilable(ConstantDiscovery))
+ @package_set = T.let(nil, T.nilable(PackageSet))
# We need to initialize this before we fork the process, see https://github.com/Shopify/packwerk/issues/182
@cache = T.let(
Cache.new(enable_cache: @cache_enabled, cache_directory: @cache_directory, config_path: @config_path), Cache
)
end
@@ -88,10 +89,15 @@
reference_checker = ReferenceChecking::ReferenceChecker.new(@checkers)
processed_file.offenses + references.flat_map { |reference| reference_checker.call(reference) }
end
+ sig { returns(PackageSet) }
+ def package_set
+ @package_set ||= ::Packwerk::PackageSet.load_all_from(@root_path, package_pathspec: @package_paths)
+ end
+
private
sig { returns(FileProcessor) }
def file_processor
@file_processor ||= FileProcessor.new(node_processor_factory: node_processor_factory, cache: @cache)
@@ -119,14 +125,9 @@
ConstantResolver.new(
root_path: @root_path,
load_paths: @load_paths,
inflector: @inflector,
)
- end
-
- sig { returns(PackageSet) }
- def package_set
- ::Packwerk::PackageSet.load_all_from(@root_path, package_pathspec: @package_paths)
end
sig { returns(T::Array[ConstantNameInspector]) }
def constant_name_inspectors
[