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.addMethodInvocation((MethodInvocation node) {
final String methodName = node.methodName.name;
if (!_heavyOperations.contains(methodName)) return;
// Check if already inside compute() or Isolate.run()
if (isInsideIsolate(node)) return;
// Check if in async context (likely handling network response)
if (isInAsyncContext(node)) {
reporter.atNode(node);
}
});
}