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.addBinaryExpression((BinaryExpression node) {
if (node.operator.type != TokenType.EQ_EQ &&
node.operator.type != TokenType.BANG_EQ) {
return;
}
final DartType? leftType = node.leftOperand.staticType;
final DartType? rightType = node.rightOperand.staticType;
// Allow null checks - comparing collection to null is valid
if (leftType == null || rightType == null) {
return;
}
// Only report if both sides are collections (actual collection comparison)
if (_isCollectionType(leftType) && _isCollectionType(rightType)) {
reporter.atNode(node);
}
});
}