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,
) {
final path = context.filePath;
if (!ProjectContext.hasDependency(path, 'firebase_messaging')) {
return;
}
if (ProjectContext.hasDependency(path, 'flutter_local_notifications')) {
return;
}
if (context.isInTestDirectory) {
return;
}
context.addMethodInvocation((MethodInvocation node) {
final name = node.methodName.name;
if (name != 'sendMessage' && name != 'post') return;
final String source = node.toSource();
if (!_firebaseMessagingSourcePattern.hasMatch(source)) {
return;
}
reporter.atNode(node);
});
}