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 sourceHashes = computeSourceHashes(project.source);
  final issues = <Issue>[];

  for (final entry in project.translations.entries) {
    final locale = entry.key;
    final arb = entry.value;
    for (final e in arb.entries) {
      if (!isStaleEntry(e, sourceHashes)) continue;
      final locked = e.metadata?.locked ?? false;
      issues.add(
        Issue(
          severity: IssueSeverity.warning,
          ruleName: name,
          message:
              'Translation for `${e.key}` is stale — the English source '
              'changed since it was translated.',
          locale: locale,
          key: e.key,
          file: arb.sourcePath,
          line: arb.entryLines[e.key],
          hint: locked
              ? 'A human locked this. Unlock + re-translate, or re-lock it '
                    'against the new source in `dialect serve` if it still '
                    'reads correctly.'
              : 'Run `dialect translate` to refresh it, or lock it in '
                    '`dialect serve` if it is still correct as-is.',
        ),
      );
    }
  }
  return issues;
}