The following issues were found

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

Line: 58

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

TEST_F(AddFieldsTest, ShouldKeepUnspecifiedFieldsReplaceExistingFieldsAndAddNewFields) {
    auto addFields =
        DocumentSourceAddFields::create(BSON("e" << 2 << "b" << BSON("c" << 3)), getExpCtx());
    auto mock = DocumentSourceMock::createForTest(
        Document{{"a", 1}, {"b", Document{{"c", 1}}}, {"d", 1}}, getExpCtx());
    addFields->setSource(mock.get());

            

Reported by Cppcheck.

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

Line: 109

                  }
};

TEST_F(BucketAutoTests, ReturnsNoBucketsWhenSourceIsEmpty) {
    auto bucketAutoSpec = fromjson("{$bucketAuto : {groupBy : '$x', buckets: 1}}");
    auto results = getResults(bucketAutoSpec, {});
    ASSERT_EQUALS(results.size(), 0UL);
}


            

Reported by Cppcheck.

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

Line: 98

                  }
};

TEST_F(BucketReturnsGroupAndSort,
       BucketWithAllConstantsAndGroupByConstIsCorrectlyOptimizedAfterSwitch) {
    const auto spec = fromjson(
        "{$bucket : {groupBy : {$const : 6}, boundaries : [ 1, 5, 8 ], default : 'other'}}");

    auto expectedGroupWithOpt = Value(fromjson("{_id: {$const: 5}, count: {$sum: {$const: 1}}}"));

            

Reported by Cppcheck.

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

Line: 89

                  }
};

TEST_F(DocumentSourceChangeStreamAddPostImageTest,
       CannotCreateStageFromBsonWithUnrecognizedFullDocumentMode) {
    auto expCtx = getExpCtx();
    auto spec = BSON("$changeStream: " << BSON("fullDocument"
                                               << "banana"));
    ASSERT_THROWS_CODE(

            

Reported by Cppcheck.

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

Line: 522

                  }
};

TEST_F(ChangeStreamStageTest, ShouldRejectNonObjectArg) {
    auto expCtx = getExpCtx();

    ASSERT_THROWS_CODE(DSChangeStream::createFromBson(
                           BSON(DSChangeStream::kStageName << "invalid").firstElement(), expCtx),
                       AssertionException,

            

Reported by Cppcheck.

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

Line: 391

                  }
};

TEST_F(CheckResumeTokenTest, ShouldSucceedWithOnlyResumeToken) {
    Timestamp resumeTimestamp(100, 1);

    auto checkResumeToken = createDSEnsureResumeTokenPresent(resumeTimestamp, "1");
    addOplogEntryOnTestNS(resumeTimestamp, "1");
    // We should not see the resume token.

            

Reported by Cppcheck.

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

Line: 87

                  }
};

TEST_F(CountReturnsGroupAndProjectStages, ValidStringSpec) {
    BSONObj spec = BSON("$count"
                        << "myCount");
    testCreateFromBsonResult(spec);

    spec = BSON("$count"

            

Reported by Cppcheck.

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

Line: 92

                  bool _hasShardName;
};

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

            

Reported by Cppcheck.

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

Line: 75

                  return statusDate.getValue();
}

DEATH_TEST(DensifyGeneratorTest, ErrorsIfMinOverMax, "lower or equal to max") {
    Document doc{{"a", 1}};
    ASSERT_THROWS_CODE(
        GenClass(Value(1),
                 RangeStatement(Value(1), NumericBounds(Value(1), Value(0)), boost::none),
                 "path",

            

Reported by Cppcheck.

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

Line: 164

                  }
};

TEST_F(DocumentSourceExchangeTest, SimpleExchange1Consumer) {
    const size_t nDocs = 500;

    auto source = getMockSource(nDocs);

    ExchangeSpec spec;

            

Reported by Cppcheck.