run method

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

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,
) {
  context.registry.addExpressionStatement((node) {
    final expression = node.expression;

    if (expression is AssignmentExpression) {
      return;
    }
    final type = expression.staticType;
    if (type == null || type is VoidType || type is NeverType) {
      return;
    }
    if (_checker.isSuperTypeOf(type)) {
      reporter.atNode(expression, code);
    }
  });
}