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

  for (final entry in project.source.entries) {
    if (_validIdentifier.hasMatch(entry.key)) continue;
    issues.add(
      Issue(
        severity: defaultSeverity,
        ruleName: name,
        message:
            'Key `${entry.key}` is not a valid Dart identifier — '
            '`flutter gen-l10n` will not accept it.',
        key: entry.key,
        file: project.source.sourcePath,
        line: project.source.entryLines[entry.key],
        hint: entry.key.contains('.')
            ? 'Use flat camelCase per the convention: '
                  '`${_suggest(entry.key)}` with '
                  '`"namespace": "${entry.key.split('.').first}"` in '
                  'the `@key` block. Dotted keys break gen-l10n.'
            : 'Rename the key to flat camelCase starting with a letter, '
                  'e.g. `${_suggest(entry.key)}`.',
      ),
    );
  }

  return issues;
}