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 sourceLocale = project.config.sourceLocale;

  final sourceByKey = <String, ArbEntry>{
    for (final e in project.source.entries) e.key: e,
  };

  for (final entry in project.translations.entries) {
    final locale = entry.key;
    if (locale == sourceLocale) continue;
    final arb = entry.value;
    for (final t in arb.entries) {
      final src = sourceByKey[t.key];
      if (src == null) continue; // covered by orphan/missing rules
      if (t.value != src.value) continue;
      if (t.metadata?.locked == true) continue; // reviewer accepted
      if (!_looksLikeCopy(t.value)) continue;

      issues.add(
        Issue(
          severity: defaultSeverity,
          ruleName: name,
          message: 'Translation for `${t.key}` is identical to the source.',
          locale: locale,
          key: t.key,
          file: arb.sourcePath,
          line: arb.entryLines[t.key],
          hint:
              'If this is intentional (brand name, code, untranslatable '
              'token), lock the entry via the dashboard to dismiss this '
              'warning. Otherwise translate the value.',
        ),
      );
    }
  }

  return issues;
}