report method

  1. @override
Future<void> report(
  1. Iterable<UnusedFilesFileReport> records, {
  2. Iterable<void> summary = const [],
  3. UnusedFilesReportParams? additionalParams,
})
override

Implementation

@override
Future<void> report(
  Iterable<UnusedFilesFileReport> records, {
  Iterable<void> summary = const [],
  UnusedFilesReportParams? additionalParams,
}) async {
  if (records.isEmpty) {
    if (additionalParams?.congratulate ?? true) {
      output.writeln('${okPen('✔')} no unused files found!');
    }

    return;
  }

  final sortedRecords = records.toList()
    ..sort((a, b) => a.relativePath.compareTo(b.relativePath));

  for (final analysisRecord in sortedRecords) {
    output.writeln(
      '${warningPen('⚠')} unused file: ${analysisRecord.path}',
    );
  }

  final filesCount = alarmPen(sortedRecords.length);

  final outputRecord = (additionalParams?.deleteUnusedFiles ?? false)
      ? '${okPen('✔')} $filesCount files were successfully deleted'
      : '${alarmPen('✖')} total unused files - $filesCount';

  output
    ..writeln('')
    ..writeln(outputRecord);
}