run method
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();
final partial = project.config.partialLocales.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();
final missing = sourceKeys.difference(present);
if (partial.contains(locale)) {
final total = sourceKeys.length;
final done = total - missing.length;
final complete = missing.isEmpty;
issues.add(
Issue(
severity: IssueSeverity.info,
ruleName: name,
message: complete
? '$locale: ${_n(done)} of ${_n(total)} keys translated — '
'complete; remove `$locale` from partial_locales in '
'dialect.yaml to make it a fully checked locale.'
: '$locale: ${_n(done)} of ${_n(total)} keys translated',
locale: locale,
file: arb.sourcePath,
hint: complete
? null
: '`$locale` is listed in partial_locales, so its '
'${_n(missing.length)} missing keys are not reported '
'individually and do not fail --strict. Every other '
'rule still applies to the keys that exist.',
),
);
continue;
}
for (final key in missing) {
issues.add(
Issue(
severity: defaultSeverity,
ruleName: name,
message: 'Missing translation for key `$key`.',
locale: locale,
key: key,
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;
}