The following issues were found

src/mongo/db/exec/document_value/document_value_test_util_self_test.cpp
1 issues
syntax error
Error

Line: 44

                  ASSERT_DOCUMENT_EQ(Document({{"foo", "bar"_sd}}), Document({{"foo", "bar"_sd}}));
}

TEST(DocumentValueTestUtilSelfTest, DocumentNE) {
    ASSERT_DOCUMENT_NE(Document({{"foo", "bar"_sd}}), Document({{"foo", "baz"_sd}}));
}

TEST(DocumentValueTestUtilSelfTest, DocumentLT) {
    ASSERT_DOCUMENT_LT(Document({{"foo", "bar"_sd}}), Document({{"foo", "baz"_sd}}));

            

Reported by Cppcheck.

src/mongo/db/exec/document_value/value_comparator_test.cpp
1 issues
syntax error
Error

Line: 51

                  ASSERT_FALSE(ValueComparator().evaluate(val1 == val3));
}

TEST(ValueComparatorTest, EqualToEvaluatesCorrectlyWithNonSimpleCollator) {
    CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kAlwaysEqual);
    Value val1("abc"_sd);
    Value val2("def"_sd);
    ASSERT_TRUE(ValueComparator(&collator).evaluate(val1 == val2));
}

            

Reported by Cppcheck.

src/mongo/db/exec/exclusion_projection_executor_test.cpp
1 issues
syntax error
Error

Line: 89

                  return createProjectionExecutor(spec, noArrayRecursion);
}

TEST(ExclusionProjectionExecutionTest, ShouldSerializeToEquivalentProjection) {
    auto exclusion = makeExclusionProjectionWithDefaultPolicies(
        fromjson("{a: 0, b: {c: NumberLong(0), d: 0.0}, 'x.y': false, _id: NumberInt(0)}"));

    // Converts numbers to bools, converts dotted paths to nested documents. Note order of excluded
    // fields is subject to change.

            

Reported by Cppcheck.

src/mongo/db/exec/find_projection_executor_test.cpp
1 issues
syntax error
Error

Line: 98

                  }
};

TEST_F(PositionalProjectionExecutionTest, CanApplyPositionalWithInclusionProjection) {
    ASSERT_DOCUMENT_EQ(Document{fromjson("{foo: [6]}")},
                       applyPositional(fromjson("{foo: 1}"),
                                       fromjson("{foo: {$gte: 5}}"),
                                       "foo",
                                       Document{fromjson("{foo: [1,2,6,10]}")}));

            

Reported by Cppcheck.

src/mongo/db/exec/inclusion_projection_executor_test.cpp
1 issues
syntax error
Error

Line: 181

              using InclusionProjectionExecutionTestWithoutFallBackToDefault =
    BaseInclusionProjectionExecutionTest<false>;

TEST_F(InclusionProjectionExecutionTestWithoutFallBackToDefault,
       ShouldAddIncludedFieldsToDependencies) {
    auto inclusion = makeInclusionProjectionWithDefaultPolicies(
        BSON("_id" << false << "a" << true << "x.y" << true));

    DepsTracker deps;

            

Reported by Cppcheck.

src/mongo/db/exec/projection_executor_builder_test.cpp
1 issues
syntax error
Error

Line: 135

              using ProjectionExecutorTestWithFallBackToDefault = BaseProjectionExecutorTest<true>;
using ProjectionExecutorTestWithoutFallBackToDefault = BaseProjectionExecutorTest<false>;

TEST_F(ProjectionExecutorTestWithoutFallBackToDefault, CanProjectInclusionWithIdPath) {
    auto projWithId = parseWithDefaultPolicies(fromjson("{a: 1, _id: 1}"));
    auto executor = createProjectionExecutor(projWithId);
    ASSERT_DOCUMENT_EQ(Document{fromjson("{_id: 123, a: 'abc'}")},
                       executor->applyTransformation(
                           Document{fromjson("{_id: 123, a: 'abc', b: 'def', c: 'ghi'}")}));

            

Reported by Cppcheck.

src/mongo/db/exec/projection_executor_test.cpp
1 issues
syntax error
Error

Line: 78

              // Error cases.
//

TEST(ProjectionExecutorErrors, ShouldRejectDuplicateFieldNames) {
    // Include/exclude the same field twice.
    ASSERT_THROWS(makeProjectionWithDefaultPolicies(BSON("a" << true << "a" << true)),
                  AssertionException);
    ASSERT_THROWS(makeProjectionWithDefaultPolicies(BSON("a" << false << "a" << false)),
                  AssertionException);

            

Reported by Cppcheck.

src/mongo/db/exec/projection_executor_utils_test.cpp
1 issues
syntax error
Error

Line: 56

                      preImage, postImage.value_or(preImage), *matchExpr, path);
}

TEST(PositionalProjection, CorrectlyProjectsSimplePath) {
    ASSERT_DOCUMENT_EQ(Document{fromjson("{bar: 1, foo: [6]}")},
                       applyPositional(fromjson("{bar: 1, foo: {$gte: 5}}"),
                                       "foo",
                                       Document{fromjson("{bar: 1, foo: [1,2,6,10]}")}));
}

            

Reported by Cppcheck.

src/mongo/db/exec/projection_executor_wildcard_access_test.cpp
1 issues
syntax error
Error

Line: 90

              // Error cases.
//

TEST(ProjectionExecutorErrors, ShouldRejectMixOfInclusionAndComputedFields) {
    ASSERT_THROWS(makeProjectionWithDefaultIdInclusionAndNestedArrayRecursion(
                      BSON("a" << true << "b" << wrapInLiteral(1))),
                  AssertionException);

    ASSERT_THROWS(makeProjectionWithDefaultIdInclusionAndNestedArrayRecursion(

            

Reported by Cppcheck.

src/mongo/db/exec/queued_data_stage_test.cpp
1 issues
syntax error
Error

Line: 73

              //
// Basic test that we get out valid stats objects.
//
TEST_F(QueuedDataStageTest, getValidStats) {
    WorkingSet ws;
    auto expCtx = make_intrusive<ExpressionContext>(opCtx(), nullptr, kNss);
    auto mock = std::make_unique<QueuedDataStage>(expCtx.get(), &ws);
    const CommonStats* commonStats = mock->getCommonStats();
    ASSERT_EQUALS(commonStats->works, static_cast<size_t>(0));

            

Reported by Cppcheck.