check method

  1. @override
void check(
  1. DcqRegistry registry
)

Implementation

@override
void check(
  DcqRegistry registry,
) {
  registry.addBinaryExpression((node) {
    final left = node.leftOperand;
    if (left is! MethodInvocation) return;
    if (left.methodName.name != 'compareTo') return;

    final right = node.rightOperand;
    if (right is! IntegerLiteral) return;
    if (right.value != 0) return;
    if (node.operator.lexeme != '==' && node.operator.lexeme != '!=') return;

    reportAtNode(node);
  });
}