The following issues were found

src/mongo/db/catalog/commit_quorum_options_test.cpp
1 issues
syntax error
Error

Line: 46

                  ASSERT_EQUALS("commitQuorum has to be a number or a string", status.reason());
}

TEST(CommitQuorumOptionsTest, ParseReturnsFailedToParseIfCommitQuorumIsNotNumberOrString) {
    BSONObj obj = BSON("commitQuorum" << BSONObj());
    auto status = CommitQuorumOptions().parse(obj.getField("commitQuorum"));
    ASSERT_EQUALS(ErrorCodes::FailedToParse, status);
    ASSERT_EQUALS("commitQuorum has to be a number or a string", status.reason());
}

            

Reported by Cppcheck.

src/mongo/db/catalog/create_collection.cpp
1 issues
sprintf - Potential format string problem
Security

Line: 154 Column: 39 CWE codes: 134
Suggestion: Make format string constant

                  // cannot cover all constraints. Leave the validationLevel and validationAction to their
    // strict/error defaults.
    auto timeField = options.timeseries->getTimeField();
    auto validatorObj = fromjson(fmt::sprintf(R"(
{
'$jsonSchema' : {
    bsonType: 'object',
    required: ['_id', 'control', 'data'],
    properties: {

            

Reported by FlawFinder.

src/mongo/db/catalog/create_collection_test.cpp
1 issues
syntax error
Error

Line: 142

                  return *(options.uuid);
}

TEST_F(CreateCollectionTest, CreateCollectionForApplyOpsWithSpecificUuidNoExistingCollection) {
    NamespaceString newNss("test.newColl");

    auto opCtx = makeOpCtx();
    ASSERT_FALSE(collectionExists(opCtx.get(), newNss));


            

Reported by Cppcheck.

src/mongo/db/catalog/database_test.cpp
1 issues
syntax error
Error

Line: 117

                  ServiceContextMongoDTest::tearDown();
}

TEST_F(DatabaseTest, SetDropPendingThrowsExceptionIfDatabaseIsAlreadyInADropPendingState) {
    writeConflictRetry(_opCtx.get(), "testSetDropPending", _nss.ns(), [this] {
        AutoGetDb autoDb(_opCtx.get(), _nss.db(), MODE_X);
        auto db = autoDb.ensureDbExists();
        ASSERT_TRUE(db);


            

Reported by Cppcheck.

src/mongo/db/catalog/drop_database_test.cpp
1 issues
syntax error
Error

Line: 211

                  }
}

TEST_F(DropDatabaseTest, DropDatabaseReturnsNamespaceNotFoundIfDatabaseDoesNotExist) {
    ASSERT_FALSE(AutoGetDb(_opCtx.get(), _nss.db(), MODE_X).getDb());
    ASSERT_EQUALS(ErrorCodes::NamespaceNotFound,
                  dropDatabaseForApplyOps(_opCtx.get(), _nss.db().toString()));
}


            

Reported by Cppcheck.

src/mongo/db/catalog/index_builds_manager_test.cpp
1 issues
syntax error
Error

Line: 82

                  return indexSpecs;
}

TEST_F(IndexBuildsManagerTest, IndexBuildsManagerSetUpAndTearDown) {
    AutoGetCollection autoColl(operationContext(), _nss, MODE_X);
    CollectionWriter collection(autoColl);

    auto specs = makeSpecs(_nss, {"a", "b"});
    ASSERT_OK(_indexBuildsManager.setUpIndexBuild(

            

Reported by Cppcheck.

src/mongo/db/catalog/index_key_validate_test.cpp
1 issues
syntax error
Error

Line: 58

              }


TEST(IndexKeyValidateTest, KeyElementValueOfSmallPositiveIntSucceeds) {
    for (auto indexVersion : getSupportedIndexVersions()) {
        ASSERT_OK(validateKeyPattern(BSON("x" << 1), indexVersion));
        ASSERT_OK(validateKeyPattern(BSON("x" << 5), indexVersion));
    }
}

            

Reported by Cppcheck.

src/mongo/db/catalog/index_signature_test.cpp
1 issues
syntax error
Error

Line: 103

                  NamespaceString _nss{"fooDB.barColl"};
};

TEST_F(IndexSignatureTest, CanCreateMultipleIndexesOnSameKeyPatternWithDifferentCollations) {
    // Create an index on {a: 1} with an 'en_US' collation.
    auto indexSpec = fromjson("{v: 2, name: 'a_1', key: {a: 1}, collation: {locale: 'en_US'}}");
    auto* basicIndex = unittest::assertGet(createIndex(indexSpec));

    // Create an index descriptor on the same keyPattern whose collation has an explicit strength.

            

Reported by Cppcheck.

src/mongo/db/catalog/index_spec_validate_test.cpp
1 issues
syntax error
Error

Line: 70

                  return bob.obj();
}

TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotAnObject) {
    ASSERT_EQ(ErrorCodes::TypeMismatch,
              validateIndexSpec(kDefaultOpCtx,
                                BSON("key" << 1 << "name"
                                           << "indexName")));
    ASSERT_EQ(ErrorCodes::TypeMismatch,

            

Reported by Cppcheck.

src/mongo/db/catalog/multi_index_block_test.cpp
1 issues
syntax error
Error

Line: 90

                  CatalogTestFixture::tearDown();
}

TEST_F(MultiIndexBlockTest, CommitWithoutInsertingDocuments) {
    auto indexer = getIndexer();

    AutoGetCollection autoColl(operationContext(), getNSS(), MODE_X);
    CollectionWriter coll(autoColl);


            

Reported by Cppcheck.