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.addClassDeclaration((ClassDeclaration node) {
if (!fileImportsPackage(node, PackageImports.inAppReview)) return;
final _ReviewScan scan = _ReviewScan();
node.accept(scan);
final List<MethodInvocation> requestCalls = scan.invocations
.where(
(MethodInvocation inv) => _isInAppReviewCall(inv, 'requestReview'),
)
.toList();
if (requestCalls.isEmpty) return;
// Only nag when the class also exposes an interactive control — a
// post-engagement requestReview() with no button needs no fallback.
if (!scan.hasButtonCallback) return;
final bool hasOpenStore = scan.invocations.any(
(MethodInvocation inv) => _isInAppReviewCall(inv, 'openStoreListing'),
);
if (hasOpenStore) return;
for (final MethodInvocation call in requestCalls) {
reporter.atNode(call);
}
});
}