The following issues were found

src/mongo/db/matcher/expression_internal_expr_comparison_test.cpp
1 issues
syntax error
Error

Line: 45

              
const double kNaN = std::numeric_limits<double>::quiet_NaN();

TEST(InternalExprComparisonMatchExpression, DoesNotPerformTypeBracketing) {
    BSONObj operand = BSON("x" << 2);
    {
        InternalExprGTMatchExpression gt(operand.firstElement().fieldNameStringData(),
                                         operand.firstElement());
        ASSERT_FALSE(gt.matchesBSON(BSON("x" << MINKEY)));

            

Reported by Cppcheck.

src/mongo/db/matcher/expression_internal_expr_eq_test.cpp
1 issues
syntax error
Error

Line: 46

              
const double kNaN = std::numeric_limits<double>::quiet_NaN();

TEST(InternalExprEqMatchExpression, NodesWithDifferentCollationsAreNotEquivalent) {
    auto operand = BSON("a" << 5);
    CollatorInterfaceMock collator1(CollatorInterfaceMock::MockType::kReverseString);
    InternalExprEqMatchExpression eq1(operand.firstElement().fieldNameStringData(),
                                      operand.firstElement());
    eq1.setCollator(&collator1);

            

Reported by Cppcheck.

src/mongo/db/matcher/expression_leaf_test.cpp
1 issues
syntax error
Error

Line: 46

              
using std::string;

TEST(ComparisonMatchExpression, ComparisonMatchExpressionsWithUnequalCollatorsAreUnequal) {
    BSONObj operand = BSON("a" << 5);
    CollatorInterfaceMock collator1(CollatorInterfaceMock::MockType::kReverseString);
    EqualityMatchExpression eq1("a", operand["a"]);
    eq1.setCollator(&collator1);
    CollatorInterfaceMock collator2(CollatorInterfaceMock::MockType::kAlwaysEqual);

            

Reported by Cppcheck.

src/mongo/db/matcher/expression_optimize_test.cpp
1 issues
syntax error
Error

Line: 84

                  return CanonicalQuery::isValidNormalized(me.get());
}

TEST(ExpressionOptimizeTest, IsValidText) {
    // Filter inside FindCommandRequest is not used.
    auto findCommand = std::make_unique<FindCommandRequest>(nss);
    ASSERT_OK(query_request_helper::validateFindCommandRequest(*findCommand));

    // Valid: regular TEXT.

            

Reported by Cppcheck.

src/mongo/db/matcher/expression_parser.cpp
1 issues
Syntax Error: AST broken, 'if' doesn't have two operands.
Error

Line: 673

                                     str::stream() << name << " must match at least one type")};
    }

    if constexpr (std::is_same_v<T, InternalSchemaTypeExpression> ||
                  std::is_same_v<T, InternalSchemaBinDataEncryptedTypeExpression>) {
        expCtx->sbeCompatible = false;
    }
    return {std::make_unique<T>(
        name,

            

Reported by Cppcheck.

src/mongo/db/matcher/expression_parser_array_test.cpp
1 issues
syntax error
Error

Line: 47

              
using std::string;

TEST(MatchExpressionParserArrayTest, Size1) {
    BSONObj query = BSON("x" << BSON("$size" << 2));
    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
    StatusWithMatchExpression result = MatchExpressionParser::parse(query, expCtx);
    ASSERT_TRUE(result.isOK());


            

Reported by Cppcheck.

src/mongo/db/matcher/expression_parser_geo_test.cpp
1 issues
syntax error
Error

Line: 58

                  ASSERT(result.getValue()->matchesBSON(fromjson("{a: {x: 5, y:5.1}}")));
}

TEST(MatchExpressionParserGeoNear, ParseNear) {
    BSONObj query = fromjson(
        "{loc:{$near:{$maxDistance:100, "
        "$geometry:{type:\"Point\", coordinates:[0,0]}}}}");

    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());

            

Reported by Cppcheck.

src/mongo/db/matcher/expression_parser_leaf_test.cpp
1 issues
syntax error
Error

Line: 49

              using std::endl;
using std::string;

TEST(MatchExpressionParserLeafTest, NullCollation) {
    BSONObj query = BSON("x"
                         << "string");
    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
    StatusWithMatchExpression result = MatchExpressionParser::parse(query, expCtx);
    ASSERT_OK(result.getStatus());

            

Reported by Cppcheck.

src/mongo/db/matcher/expression_parser_test.cpp
1 issues
syntax error
Error

Line: 55

                  ASSERT(!result.getValue()->matchesBSON(BSON("x" << 3)));
}

TEST(MatchExpressionParserTest, Multiple1) {
    BSONObj query = BSON("x" << 5 << "y" << BSON("$gt" << 5 << "$lt" << 8));
    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
    StatusWithMatchExpression result = MatchExpressionParser::parse(query, expCtx);
    ASSERT_TRUE(result.isOK());


            

Reported by Cppcheck.

src/mongo/db/matcher/expression_parser_tree_test.cpp
1 issues
syntax error
Error

Line: 54

                  ASSERT(!result.getValue()->matchesBSON(BSON("y" << 1)));
}

TEST(MatchExpressionParserTreeTest, OREmbedded) {
    BSONObj query1 = BSON("$or" << BSON_ARRAY(BSON("x" << 1) << BSON("y" << 2)));
    BSONObj query2 = BSON("$or" << BSON_ARRAY(query1));
    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
    StatusWithMatchExpression result = MatchExpressionParser::parse(query2, expCtx);
    ASSERT_TRUE(result.isOK());

            

Reported by Cppcheck.