run method

  1. @override
List<Issue> run(
  1. DialectProject project
)
override

Inspect project and return findings. May return an empty list. Should NOT throw — turn unexpected conditions into Issues so the report surfaces them rather than crashing.

Implementation

@override
List<Issue> run(DialectProject project) {
  final issues = <Issue>[];
  final sourceKeys = project.source.entries.map((e) => e.key).toSet();

  for (final entry in project.translations.entries) {
    final locale = entry.key;
    final arb = entry.value;
    final present = arb.entries.map((e) => e.key).toSet();
    for (final missing in sourceKeys.difference(present)) {
      issues.add(
        Issue(
          severity: defaultSeverity,
          ruleName: name,
          message: 'Missing translation for key `$missing`.',
          locale: locale,
          key: missing,
          file: arb.sourcePath,
          // No line — the key isn't in this file yet.
          hint:
              'Run `dialect translate` to backfill missing keys, '
              'or add the entry to ${arb.sourcePath} by hand.',
        ),
      );
    }
  }

  return issues;
}