runWithReporter method

  1. @override
void runWithReporter(
  1. SaropaDiagnosticReporter reporter,
  2. SaropaContext context
)
override

Override this method to implement your lint rule.

Use context to register callbacks for AST node types:

context.addMethodInvocation((node) {
  if (condition) {
    reporter.atNode(node);
  }
});

Implementation

@override
void runWithReporter(
  SaropaDiagnosticReporter reporter,
  SaropaContext context,
) {
  context.addMethodInvocation((MethodInvocation node) {
    if (!_isAuthenticateCall(node)) return;
    if (!fileImportsPackage(node, PackageImports.localAuth)) return;

    // Already biometric-only — nothing to flag.
    final Expression? bioOnly = _namedArgValue(node, 'biometricOnly');
    if (bioOnly is BooleanLiteral && bioOnly.value == true) return;
    if (bioOnly != null) return; // explicitly set to something — respect it

    if (!_inSensitiveContext(node)) return;
    reporter.atNode(node.methodName);
  });
}