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 legal = (placeholderRoles.toList()..sort()).join(', ');

  for (final entry in project.source.entries) {
    final placeholders = entry.metadata?.placeholders;
    if (placeholders == null) continue;
    for (final MapEntry(key: name, value: ph) in placeholders.entries) {
      final role = ph.role;
      if (role == null || placeholderRoles.contains(role)) continue;
      issues.add(
        Issue(
          severity: defaultSeverity,
          ruleName: this.name,
          message:
              'Placeholder `$name` in `${entry.key}` declares an unknown '
              'role "$role", so it is being ignored.',
          key: entry.key,
          file: project.source.sourcePath,
          line: project.source.entryLines[entry.key],
          hint:
              'Use one of: $legal. `count` is the number a plural agrees '
              'with; `identifier` labels something ("Goal 3"); `ordinal` '
              'places it in a sequence. Drop the field to let Dialect '
              'infer from the type and name.',
        ),
      );
    }
  }

  return issues;
}