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,
) {
// Check if file has permission request
final String fileSource = context.fileContent;
final bool hasPermissionRequest =
fileSource.contains('requestPermissions') ||
fileSource.contains('IOSFlutterLocalNotificationsPlugin');
if (hasPermissionRequest) {
return;
}
context.addMethodInvocation((MethodInvocation node) {
final String methodName = node.methodName.name;
if (_scheduleMethods.contains(methodName)) {
final Expression? target = node.target;
if (target != null &&
_notificationTargets.contains(extractTargetName(target))) {
reporter.atNode(node);
}
}
});
}