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>[];

  // Source-side empties are caught here too — an empty source string
  // is almost always a mistake (the dev forgot to fill it in).
  for (final entry in project.source.entries) {
    if (entry.value.isEmpty) {
      issues.add(
        Issue(
          severity: defaultSeverity,
          ruleName: name,
          message: 'Source value for key `${entry.key}` is empty.',
          key: entry.key,
          file: project.source.sourcePath,
          line: project.source.entryLines[entry.key],
          hint:
              'An empty source string renders as a blank in the UI. '
              'Fill in the canonical English string or delete the key.',
        ),
      );
    }
  }

  for (final entry in project.translations.entries) {
    final locale = entry.key;
    final arb = entry.value;
    for (final translation in arb.entries) {
      if (translation.value.isEmpty) {
        issues.add(
          Issue(
            severity: defaultSeverity,
            ruleName: name,
            message:
                'Empty translation value for key '
                '`${translation.key}`.',
            locale: locale,
            key: translation.key,
            file: arb.sourcePath,
            line: arb.entryLines[translation.key],
            hint:
                'Translate the key or remove the entry — an empty '
                'string renders as a blank in the UI. `dialect translate` '
                'can fill in missing translations.',
          ),
        );
      }
    }
  }

  return issues;
}