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 secure storage write without IOSOptions
if (methodName == 'write') {
final Expression? target = node.target;
if (target != null &&
_secureStorageTargets.contains(extractTargetName(target))) {
bool hasIOSOptions = false;
for (final Expression arg in node.argumentList.arguments) {
if (arg is NamedExpression) {
if (arg.name.label.name == 'iOptions' ||
arg.name.label.name == 'aOptions') {
hasIOSOptions = true;
break;
}
}
}
if (!hasIOSOptions) {
reporter.atNode(node);
}
}
}
});
}