lib/packwerk/parse_run.rb in packwerk-2.1.1 vs lib/packwerk/parse_run.rb in packwerk-2.2.0
- old
+ new
@@ -12,26 +12,26 @@
T.proc.params(path: String).returns(T::Array[Offense])
end
sig do
params(
- absolute_files: T::Array[String],
+ absolute_file_set: FilesForProcessing::AbsoluteFileSet,
configuration: Configuration,
progress_formatter: Formatters::ProgressFormatter,
offenses_formatter: OffensesFormatter,
).void
end
def initialize(
- absolute_files:,
+ absolute_file_set:,
configuration:,
progress_formatter: Formatters::ProgressFormatter.new(StringIO.new),
offenses_formatter: Formatters::OffensesFormatter.new
)
@configuration = configuration
@progress_formatter = progress_formatter
@offenses_formatter = offenses_formatter
- @absolute_files = absolute_files
+ @absolute_file_set = absolute_file_set
end
sig { returns(Result) }
def detect_stale_violations
offense_collection = find_offenses
@@ -71,11 +71,11 @@
private
sig { params(show_errors: T::Boolean).returns(OffenseCollection) }
def find_offenses(show_errors: false)
offense_collection = OffenseCollection.new(@configuration.root_path)
- @progress_formatter.started(@absolute_files)
+ @progress_formatter.started(@absolute_file_set)
run_context = Packwerk::RunContext.from_configuration(@configuration)
all_offenses = T.let([], T::Array[Offense])
process_file = T.let(-> (absolute_file) do
@@ -85,11 +85,11 @@
end
end, ProcessFileProc)
execution_time = Benchmark.realtime do
all_offenses = if @configuration.parallel?
- Parallel.flat_map(@absolute_files, &process_file)
+ Parallel.flat_map(@absolute_file_set, &process_file)
else
serial_find_offenses(&process_file)
end
end
@@ -101,10 +101,10 @@
sig { params(block: ProcessFileProc).returns(T::Array[Offense]) }
def serial_find_offenses(&block)
all_offenses = T.let([], T::Array[Offense])
begin
- @absolute_files.each do |absolute_file|
+ @absolute_file_set.each do |absolute_file|
offenses = block.call(absolute_file)
all_offenses.concat(offenses)
end
rescue Interrupt
@progress_formatter.interrupted