The following issues were found

src/mongo/db/repl/check_quorum_for_config_change_test.cpp
1 issues
syntax error
Error

Line: 142

                  return config;
}

TEST_F(CheckQuorumForInitiate, ValidSingleNodeSet) {
    ReplSetConfig config =
        assertMakeRSConfig(BSON("_id"
                                << "rs0"
                                << "version" << 1 << "protocolVersion" << 1 << "members"
                                << BSON_ARRAY(BSON("_id" << 1 << "host"

            

Reported by Cppcheck.

src/mongo/db/repl/collection_cloner_test.cpp
1 issues
syntax error
Error

Line: 160

                  }
};

TEST_F(CollectionClonerTestResumable, CollectionClonerPassesThroughErrorFromCollStatsCommand) {
    auto cloner = makeCollectionCloner();
    cloner->setStopAfterStage_forTest("count");
    // The collection cloner pre-stage makes a remote call to collStats to store in-progress
    // metrics.
    _mockServer->setCommandReply("collStats", Status(ErrorCodes::OperationFailed, ""));

            

Reported by Cppcheck.

src/mongo/db/repl/data_replicator_external_state_impl.cpp
1 issues
Syntax Error: AST broken, 'if' doesn't have two operands.
Error

Line: 56

              const char kBlockingQueueOplogBufferName[] = "inMemoryBlockingQueue";

MONGO_INITIALIZER(initialSyncOplogBuffer)(InitializerContext*) {
    if ((initialSyncOplogBuffer != kCollectionOplogBufferName) &&
        (initialSyncOplogBuffer != kBlockingQueueOplogBufferName)) {
        uasserted(ErrorCodes::BadValue,
                  "unsupported initial sync oplog buffer option: " + initialSyncOplogBuffer);
    }
}

            

Reported by Cppcheck.

src/mongo/db/repl/database_cloner_test.cpp
1 issues
syntax error
Error

Line: 117

              std::string DatabaseClonerTest::_dbName = "testDb";

// A database may have no collections. Nothing to do for the database cloner.
TEST_F(DatabaseClonerTest, ListCollectionsReturnedNoCollections) {
    _mockServer->setCommandReply("listCollections", createListCollectionsResponse({}));
    auto cloner = makeDatabaseCloner();

    ASSERT_OK(cloner->run());
    ASSERT_OK(getSharedData()->getStatus(WithLock::withoutLock()));

            

Reported by Cppcheck.

src/mongo/db/repl/drop_pending_collection_reaper_test.cpp
1 issues
syntax error
Error

Line: 102

                  return cc().makeOperationContext();
}

TEST_F(DropPendingCollectionReaperTest, ServiceContextDecorator) {
    auto serviceContext = getServiceContext();
    ASSERT_FALSE(DropPendingCollectionReaper::get(serviceContext));
    DropPendingCollectionReaper* reaper = new DropPendingCollectionReaper(_storageInterface.get());
    DropPendingCollectionReaper::set(serviceContext,
                                     std::unique_ptr<DropPendingCollectionReaper>(reaper));

            

Reported by Cppcheck.

src/mongo/db/repl/idempotency_document_structure_test.cpp
1 issues
syntax error
Error

Line: 48

                  return enumerator.getDocs();
}

TEST(DocGenTest, NumDocsIsCorrect) {
    std::vector<BSONObj> docs = getEnumeratedDocs({{"a", "b"}, 2, 1, false, false});
    ASSERT_EQUALS(docs.size(), 104U);
    docs = getEnumeratedDocs({{"a", "b"}, 2, 1, true, false});
    ASSERT_EQUALS(docs.size(), 36U);
    docs = getEnumeratedDocs({{"a", "b"}, 2, 1, false, true});

            

Reported by Cppcheck.

src/mongo/db/repl/idempotency_scalar_generator.h
1 issues
random - This function is not sufficiently random for security-related functions such as key and nonce creation
Security

Line: 56 Column: 44 CWE codes: 327
Suggestion: Use a more secure technique for acquiring random values

              
class RandomizedScalarGenerator : public ScalarGenerator {
public:
    RandomizedScalarGenerator(PseudoRandom random);

    Value generateScalar() const override;

private:
    enum class ScalarChoice : int {

            

Reported by FlawFinder.

src/mongo/db/repl/idempotency_test.cpp
1 issues
syntax error
Error

Line: 315

                  }
}

TEST_F(RandomizedIdempotencyTest, CheckUpdateSequencesAreIdempotent) {
    runIdempotencyTestCase();
}
TEST_F(RandomizedIdempotencyTest, CheckUpdateSequencesAreIdempotentV2) {
    runUpdateV2IdempotencyTestCase(1.0);
    runUpdateV2IdempotencyTestCase(0.4);

            

Reported by Cppcheck.

src/mongo/db/repl/idempotency_update_sequence.h
1 issues
random - This function is not sufficiently random for security-related functions such as key and nonce creation
Security

Line: 68 Column: 42 CWE codes: 327
Suggestion: Use a more secure technique for acquiring random values

              
public:
    UpdateSequenceGenerator(UpdateSequenceGeneratorConfig config,
                            PseudoRandom random,
                            ScalarGenerator* scalarGenerator);

    BSONObj generateUpdate() const;

    std::vector<std::string> getPaths() const;

            

Reported by FlawFinder.

src/mongo/db/repl/initial_sync_shared_data_test.cpp
1 issues
syntax error
Error

Line: 74

                  ASSERT_EQ(Milliseconds(1000), data.getTotalTimeUnreachable(lk));
}

TEST(InitialSyncSharedDataTest, SequentialFailedOperations) {
    Days timeout(1);
    ClockSourceMock clock;
    InitialSyncSharedData data(1 /* rollBackId */, timeout, &clock);

    stdx::unique_lock<InitialSyncSharedData> lk(data);

            

Reported by Cppcheck.