run method

  1. @override
void run(
  1. CustomLintResolver resolver,
  2. ErrorReporter reporter,
  3. CustomLintContext context
)

Emits lints for a given file.

run will only be invoked with files respecting filesToAnalyze

Implementation

@override
void run(
  CustomLintResolver resolver,
  ErrorReporter reporter,
  CustomLintContext context,
) {
  final isTestFile = BaseAnalyzer.isTestFile(resolver.path);

  if (!_bothFiles) {
    if (_testOnly && !isTestFile) return;
    if (!_testOnly && isTestFile) return;
  }

  context.registry.addCompilationUnit((node) {
    final issues = analyzer.analyzeWithResolver(node, resolver);
    for (final issue in issues) {
      reporter.atOffset(
        offset: issue.offset,
        length: issue.length,
        errorCode: code,
      );
    }
  });
}