analyzeWithProgress method
Analyzes all files with progress reporting.
Returns an AggregatedReport with project-wide metrics.
Implementation
Future<AggregatedReport> analyzeWithProgress({
AnalysisProgressCallback? onProgress,
}) async {
final files = discoverFiles();
final aggregator = MetricsAggregator(thresholds: config.thresholds);
if (files.isEmpty) {
return aggregator.generateReport();
}
// Process files in chunks for memory efficiency
final chunks = _chunkList(files, config.chunkSize);
var completed = 0;
for (final chunk in chunks) {
// Process chunk with limited concurrency
final results = await _processChunkParallel(
chunk,
onProgress: (file) {
completed++;
onProgress?.call(completed, files.length, file);
},
);
// Aggregate results
for (final result in results) {
if (result.isSuccess && result.fileResult != null) {
aggregator.addPrecomputedResult(
result.path,
result.fileResult!,
result.functions,
);
}
}
// Yield to allow GC between chunks
await Future<void>.delayed(Duration.zero);
}
return aggregator.generateReport();
}