The following issues were found

src/mongo/db/pipeline/document_source_match_test.cpp
1 issues
syntax error
Error

Line: 59

              
constexpr auto kExplain = ExplainOptions::Verbosity::kQueryPlanner;

TEST_F(DocumentSourceMatchTest, RedactSafePortion) {
    auto expCtx = getExpCtx();
    auto assertExpectedRedactSafePortion = [&expCtx](string input, string safePortion) {
        try {
            auto match = DocumentSourceMatch::create(fromjson(input), expCtx);
            ASSERT_BSONOBJ_EQ(match->redactSafePortion(), fromjson(safePortion));

            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_merge_cursors_test.cpp
1 issues
syntax error
Error

Line: 124

                  boost::intrusive_ptr<ExpressionContext> _expCtx;
};

TEST_F(DocumentSourceMergeCursorsTest, ShouldRejectNonArray) {
    auto spec = BSON("$mergeCursors" << 2);
    ASSERT_THROWS_CODE(DocumentSourceMergeCursors::createFromBson(spec.firstElement(), getExpCtx()),
                       AssertionException,
                       17026);
}

            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_merge_test.cpp
1 issues
syntax error
Error

Line: 97

                  }
};

TEST_F(DocumentSourceMergeTest, CorrectlyParsesIfMergeSpecIsString) {
    const auto& defaultDb = getExpCtx()->ns.db();
    const auto& targetColl = "target_collection";
    auto spec = BSON("$merge" << targetColl);
    auto mergeStage = createMergeStage(spec);
    ASSERT(mergeStage);

            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_mock_test.cpp
1 issues
syntax error
Error

Line: 52

                  ASSERT(source->getNext().isEOF());
}

TEST_F(DocumentSourceMockTest, ShouldBeConstructableFromInitializerListOfDocuments) {
    auto source =
        DocumentSourceMock::createForTest({Document{{"a", 1}}, Document{{"a", 2}}}, getExpCtx());
    ASSERT_DOCUMENT_EQ(source->getNext().getDocument(), (Document{{"a", 1}}));
    ASSERT_DOCUMENT_EQ(source->getNext().getDocument(), (Document{{"a", 2}}));
    ASSERT(source->getNext().isEOF());

            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_out.cpp
1 issues
There is an unknown macro here somewhere. Configuration is required. If DESTRUCTOR_GUARD is a macro then please configure it.
Error

Line: 58

                                       AllowedWithApiStrict::kAlways);

DocumentSourceOut::~DocumentSourceOut() {
    DESTRUCTOR_GUARD(
        // Make sure we drop the temp collection if anything goes wrong. Errors are ignored
        // here because nothing can be done about them. Additionally, if this fails and the
        // collection is left behind, it will be cleaned up next time the server is started.
        if (_tempNs.size()) {
            auto cleanupClient =

            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_out_test.cpp
1 issues
syntax error
Error

Line: 86

                  }
};

TEST_F(DocumentSourceOutTest, FailsToParseIncorrectType) {
    BSONObj spec = BSON("$out" << 1);
    ASSERT_THROWS_CODE(createOutStage(spec), AssertionException, 16990);

    spec = BSON("$out" << BSONArray());
    ASSERT_THROWS_CODE(createOutStage(spec), AssertionException, 16990);

            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_plan_cache_stats_test.cpp
1 issues
syntax error
Error

Line: 80

                  std::vector<BSONObj> _planCacheStats;
};

TEST_F(DocumentSourcePlanCacheStatsTest, ShouldFailToParseIfSpecIsNotObject) {
    const auto specObj = fromjson("{$planCacheStats: 1}");
    ASSERT_THROWS_CODE(
        DocumentSourcePlanCacheStats::createFromBson(specObj.firstElement(), getExpCtx()),
        AssertionException,
        ErrorCodes::FailedToParse);

            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_project_test.cpp
1 issues
syntax error
Error

Line: 63

              using ProjectStageTest = AggregationContextFixture;
using UnsetTest = AggregationContextFixture;

TEST_F(ProjectStageTest, InclusionProjectionShouldRemoveUnspecifiedFields) {
    auto project = DocumentSourceProject::create(
        BSON("a" << true << "c" << BSON("d" << true)), getExpCtx(), "$project"_sd);
    auto source = DocumentSourceMock::createForTest("{_id: 0, a: 1, b: 1, c: {d: 1}}", getExpCtx());
    project->setSource(source.get());
    // The first result exists and is as expected.

            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_queue_test.cpp
1 issues
syntax error
Error

Line: 56

                  ASSERT(queueStage1->getNext().isEOF());
}

TEST_F(QueueStageTest, QueueStageDeserializationFails) {
    auto queueDoc = BSON("$queue" << BSONObj());
    ASSERT_THROWS_CODE(DocumentSourceQueue::createFromBson(queueDoc.firstElement(), getExpCtx()),
                       AssertionException,
                       5858201);


            

Reported by Cppcheck.

src/mongo/db/pipeline/document_source_redact_test.cpp
1 issues
syntax error
Error

Line: 64

                  ASSERT(dynamic_cast<DocumentSourceMatch*>(pipeline.front().get()));
}

TEST_F(DocumentSourceRedactTest, ShouldPropagatePauses) {
    auto redactSpec = BSON("$redact"
                           << "$$KEEP");
    auto redact = DocumentSourceRedact::createFromBson(redactSpec.firstElement(), getExpCtx());
    auto mock =
        DocumentSourceMock::createForTest({Document{{"_id", 0}},

            

Reported by Cppcheck.