The following issues were found

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

Line: 48

                                                    << "string")));
}

TEST(InternalSchemaMinItemsMatchExpression, RejectsArraysWithTooFewElements) {
    InternalSchemaMinItemsMatchExpression minItems("a", 2);

    ASSERT(!minItems.matchesBSON(BSON("a" << BSONArray())));
    ASSERT(!minItems.matchesBSON(BSON("a" << BSON_ARRAY(1))));
}

            

Reported by Cppcheck.

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

Line: 49

                  ASSERT_FALSE(minLength.matchesBSON(BSON("a" << BSON_ARRAY(1))));
}

TEST(InternalSchemaMinLengthMatchExpression, RejectsStringsWithTooFewChars) {
    InternalSchemaMinLengthMatchExpression minLength("a", 2);

    ASSERT_FALSE(minLength.matchesBSON(BSON("a"
                                            << "")));
    ASSERT_FALSE(minLength.matchesBSON(BSON("a"

            

Reported by Cppcheck.

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

Line: 48

                  ASSERT_FALSE(minProperties.matchesBSON(BSON("b" << 21)));
}

TEST(InternalSchemaMinPropertiesMatchExpression, AcceptsObjectWithAtLeastMinElements) {
    InternalSchemaMinPropertiesMatchExpression minProperties(2);

    ASSERT_TRUE(minProperties.matchesBSON(BSON("b" << 21 << "c" << BSONNULL)));
    ASSERT_TRUE(minProperties.matchesBSON(BSON("b" << 21 << "c" << 3)));
    ASSERT_TRUE(minProperties.matchesBSON(BSON("b" << 21 << "c" << 3 << "d" << 43)));

            

Reported by Cppcheck.

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

Line: 57

                  ASSERT_FALSE(objMatch.matchesBSON(BSON("a" << BSON_ARRAY(BSONNULL))));
}

TEST(InternalSchemaObjectMatchExpression, RejectsObjectsThatDontMatch) {
    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
    auto subExpr = MatchExpressionParser::parse(BSON("b" << BSON("$type"
                                                                 << "string")),
                                                expCtx);
    ASSERT_OK(subExpr.getStatus());

            

Reported by Cppcheck.

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

Line: 50

                                                              << "string")));
}

TEST(InternalSchemaRootDocEqMatchExpression, MatchesNestedObject) {
    InternalSchemaRootDocEqMatchExpression rootDocEq(BSON("a" << 1 << "b" << BSON("c" << 1)));
    ASSERT_TRUE(rootDocEq.matchesBSON(BSON("a" << 1 << "b" << BSON("c" << 1))));
    ASSERT_FALSE(rootDocEq.matchesBSON(BSON("a" << 1 << "b" << BSON("c" << 2))));
}


            

Reported by Cppcheck.

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

Line: 47

                                                            << "string")));
}

TEST(InternalSchemaUniqueItemsMatchExpression, MatchesEmptyArray) {
    InternalSchemaUniqueItemsMatchExpression uniqueItems("foo");
    ASSERT_TRUE(uniqueItems.matchesBSON(BSON("foo" << BSONArray())));
}

TEST(InternalSchemaUniqueItemsMatchExpression, MatchesOneElementArray) {

            

Reported by Cppcheck.

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

Line: 46

              
using std::unique_ptr;

TEST(InternalSchemaXorOp, MatchesNothingWhenHasNoClauses) {
    InternalSchemaXorMatchExpression internalSchemaXorOp;
    ASSERT_FALSE(internalSchemaXorOp.matchesBSON(BSONObj()));
}

TEST(InternalSchemaXorOp, MatchesSingleClause) {

            

Reported by Cppcheck.

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

Line: 61

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

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


            

Reported by Cppcheck.

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

Line: 51

                  ASSERT_BSONELT_EQ(pointer.evaluate(toTest), elt);
}

TEST(JSONPointerTest, ParseInterestingCharacterFields) {
    BSONObj obj = BSON("" << 1 << "c%d" << 2 << "e^f" << 3 << "g|h" << 4 << "i\\\\j" << 5 << "k\"l"
                          << 6 << " " << 7);
    assertPointerEvaluatesTo("/", obj, "", 1);
    assertPointerEvaluatesTo("/c%d", obj, "c%d", 2);
    assertPointerEvaluatesTo("/e^f", obj, "e^f", 3);

            

Reported by Cppcheck.

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

Line: 48

                  ASSERT_EQ(result.getStatus(), ErrorCodes::TypeMismatch);
}

TEST(JSONSchemaLogicalKeywordTest, FailsToParseAllOfIfArrayContainsInvalidSchema) {
    BSONObj schema = fromjson("{properties: {foo: {allOf: [{type: {}}]}}}");
    auto result = JSONSchemaParser::parse(new ExpressionContextForTest(), schema);
    ASSERT_EQ(result.getStatus(), ErrorCodes::TypeMismatch);
}


            

Reported by Cppcheck.