check method

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

Implementation

@override
void check(
  DcqRegistry registry,
) {
  registry.addBinaryExpression((node) {
    final operator = node.operator.lexeme;
    if (operator != '==' && operator != '!=') return;

    if (node.leftOperand is NullLiteral || node.rightOperand is NullLiteral) {
      return;
    }

    final leftType = node.leftOperand.staticType;
    final rightType = node.rightOperand.staticType;

    if (_isCollectionType(leftType) || _isCollectionType(rightType)) {
      if (_isConstExpression(node.leftOperand) &&
          _isConstExpression(node.rightOperand)) {
        return;
      }
      reportAtNode(node);
    }
  });
}