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,
) async {
  final resolved = await resolver.getResolvedUnitResult();

  context.registry.addFunctionDeclaration((node) {
    final annotation = getFirebaseRulesAnnotation(resolved);
    // This isn't a rules file
    if (annotation == null) return;

    final functions = annotation
        .getField('functions')
        ?.toListValue()
        ?.map((e) => e.toFunctionValue()!.name);
    if (functions == null) {
      reporter.deprecatedReportErrorForNode(_code, node);
      return;
    }

    if (functions.contains(node.name.toString())) return;

    reporter.deprecatedReportErrorForToken(_code, node.name);
  });
}