runWithReporter method
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.addMethodDeclaration((MethodDeclaration node) {
// Must be an async method returning Future
if (!node.isAbstract && node.body is! BlockFunctionBody) return;
final FunctionBody body = node.body;
if (body is! BlockFunctionBody) return;
final String bodySource = body.toSource();
if (!_cacheBodyRegex.any((re) => re.hasMatch(bodySource))) return;
if (!RegExp(r'\bawait\b').hasMatch(bodySource)) return;
// Check for in-flight dedup or lock patterns (suppression)
if (_hasDeduplication(bodySource, node)) return;
// Look for the cache-miss-then-await pattern
if (_hasCacheMissThenAwait(body.block)) {
reporter.atToken(node.name, code);
}
});
}