validateAll method

Future<ValidationReport> validateAll(
  1. String projectsDir, {
  2. Logger? progressLogger,
})

Validate all projects in a directory

Implementation

Future<ValidationReport> validateAll(
  String projectsDir, {
  Logger? progressLogger,
}) async {
  final log = progressLogger ?? logger;
  log?.info('Validating projects in: $projectsDir');

  final entries = <ValidationEntry>[];
  final dirs = fileSystem.listDirectory(projectsDir);

  // Sort for deterministic order
  dirs.sort();

  for (final dir in dirs) {
    if (fileSystem.isDirectory(dir)) {
      final hasExpected = fileSystem.exists(
        fileSystem.join(dir, 'expected_findings.json'),
      );
      if (!hasExpected) continue;

      final name = dir.split('/').last;
      log?.info('Validating: $name');
      try {
        final entry = await validateProject(dir);
        entries.add(entry);
        log?.success(
          '$name: accuracy=${(entry.accuracy * 100).toStringAsFixed(1)}% '
          'TP=${entry.truePositives.length} FP=${entry.falsePositives.length} '
          'FN=${entry.falseNegatives.length}',
        );
      } catch (e) {
        log?.error('$name failed: $e');
      }
    }
  }

  return ValidationReport(entries: entries, generatedAt: DateTime.now());
}