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;
// Check for openBox variants
if (!methodName.startsWith('openBox') &&
!methodName.startsWith('openLazyBox')) {
return;
}
// Check if target is Hive
final Expression? target = node.target;
if (target == null) return;
if (target is SimpleIdentifier && target.name == 'Hive') {
// This is a Hive.openBox call - warn about initialization
reporter.atNode(node);
}
});
}