The following issues were found

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

Line: 66

              // Parsing and serialization.
//

TEST_F(DocumentSourceFacetTest, ShouldRejectNonObjectSpec) {
    auto ctx = getExpCtx();
    auto spec = BSON("$facet"
                     << "string");
    ASSERT_THROWS(DocumentSourceFacet::createFromBson(spec.firstElement(), ctx),
                  AssertionException);

            

Reported by Cppcheck.

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

Line: 119

              // This provides access to getExpCtx(), but we'll use a different name for this test suite.
using FindAndModifyImageLookupTest = AggregationContextFixture;

TEST_F(FindAndModifyImageLookupTest, NoopWhenEntryDoesNotHaveNeedsRetryImageField) {
    auto imageLookup = DocumentSourceFindAndModifyImageLookup::create(getExpCtx());
    const auto sessionId = makeLogicalSessionIdForTest();
    OperationSessionInfo sessionInfo;
    sessionInfo.setSessionId(sessionId);
    sessionInfo.setTxnNumber(1);

            

Reported by Cppcheck.

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

Line: 55

                                     ErrorCodes::TypeMismatch);
}

TEST_F(DocumentSourceGeoNearTest, FailToParseIfKeyIsTheEmptyString) {
    auto stageObj = fromjson("{$geoNear: {distanceField: 'dist', near: [0, 0], key: ''}}");
    ASSERT_THROWS_CODE(DocumentSourceGeoNear::createFromBson(stageObj.firstElement(), getExpCtx()),
                       AssertionException,
                       ErrorCodes::BadValue);
}

            

Reported by Cppcheck.

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

Line: 83

              
// Tests that $graphLookup with special 'from' syntax from: {db: local, coll:
// system.tenantMigration.oplogView} can be round tripped.
TEST_F(DocumentSourceGraphLookUpTest, LookupReParseSerializedStageWithFromDBAndColl) {
    auto expCtx = getExpCtx();
    NamespaceString fromNs("local", "system.tenantMigration.oplogView");
    expCtx->setResolvedNamespaces(StringMap<ExpressionContext::ResolvedNamespace>{
        {fromNs.coll().toString(), {fromNs, std::vector<BSONObj>()}}});


            

Reported by Cppcheck.

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

Line: 73

              // This provides access to getExpCtx(), but we'll use a different name for this test suite.
using DocumentSourceGroupTest = AggregationContextFixture;

TEST_F(DocumentSourceGroupTest, ShouldBeAbleToPauseLoading) {
    auto expCtx = getExpCtx();
    expCtx->inMongos = true;  // Disallow external sort.
                              // This is the only way to do this in a debug build.
    auto&& parser = AccumulationStatement::getParser("$sum", boost::none);
    auto accumulatorArg = BSON("" << 1);

            

Reported by Cppcheck.

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

Line: 70

                  ASSERT_EQUALS(doc.metadata().getGeoNearDistance(), 0);
}

TEST_F(DocumentSourceInternalGeoNearDistanceTest, SphericalDistanceBetweenTwoPoints) {
    BSONObj computeGeoSpec = fromjson(R"(
        { $_internalComputeGeoNearDistance: {
            near: {
                type: "Point",
                coordinates: [0, 1]

            

Reported by Cppcheck.

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

Line: 84

                  }
};

TEST_F(DocumentSourceInternalShardFilterTest, ShouldOptimizeAwayIfUnshardedCollection) {
    Pipeline::SourceContainer container;
    auto mock = DocumentSourceMock::createForTest({"{a: 1}", "{a: 2}"}, getExpCtx());

    container.push_back(mock);
    container.push_back(new DocumentSourceInternalShardFilter(

            

Reported by Cppcheck.

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

Line: 62

                                    fromjson("{'control.max.a': {$_internalExprGt: 1}}"));
}

TEST_F(InternalUnpackBucketPredicateMappingOptimizationTest,
       OptimizeMapsGTEPredicatesOnControlField) {
    auto pipeline =
        Pipeline::parse(makeVector(fromjson("{$_internalUnpackBucket: {exclude: [], timeField: "
                                            "'time', bucketMaxSpanSeconds: 3600}}"),
                                   fromjson("{$match: {a: {$gte: 1}}}")),

            

Reported by Cppcheck.

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

Line: 68

                  ASSERT_BSONOBJ_EQ(groupSpec, serialized[1]);
}

TEST_F(InternalUnpackBucketBuildProjectToInternalizeTest,
       BuildsIncludeProjectForProjectDependencies) {
    auto unpackSpec = fromjson(
        "{$_internalUnpackBucket: { exclude: [], timeField: 'foo', bucketMaxSpanSeconds: 3600}}");
    auto projectSpec = fromjson("{$project: {_id: true, x: {f: '$y'}}}");
    auto pipeline = Pipeline::parse(makeVector(unpackSpec, projectSpec), getExpCtx());

            

Reported by Cppcheck.

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

Line: 68

                                    serializedArray[0].getDocument().toBson());
}

TEST_F(InternalUnpackBucketExtractProjectForPushdownTest, ExtractsEntireProjectOnMetaField) {
    auto unpack = DocumentSourceInternalUnpackBucket::createFromBsonInternal(
        fromjson("{$_internalUnpackBucket: { exclude: [], timeField: 'foo', metaField: 'myMeta', "
                 "bucketMaxSpanSeconds: 3600}}")
            .firstElement(),
        getExpCtx());

            

Reported by Cppcheck.