The following issues were found

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

Line: 103

              
constexpr auto dbName = "tenant_test"_sd;

TEST_F(TenantOplogBatcherTest, CannotRequestTwoBatchesAtOnce) {
    auto batcher = std::make_shared<TenantOplogBatcher>(
        "tenant", &_oplogBuffer, _executor, Timestamp(0, 0) /* resumeBatchingTs */);
    ASSERT_OK(batcher->startup());
    auto batchFuture = batcher->getNextBatch(bigBatchLimits);
    // We just started, no batch should be available.

            

Reported by Cppcheck.

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

Line: 341

                  TopologyCoordinator::Options _options;
};

TEST_F(TopoCoordTest, TopologyVersionInitializedAtStartup) {
    ASSERT_EQ(repl::instanceId, getTopoCoord().getTopologyVersion().getProcessId());
    ASSERT_EQ(0, getTopoCoord().getTopologyVersion().getCounter());
}

TEST_F(TopoCoordTest, NodeReturnsSecondaryWithMostRecentDataAsSyncSource) {

            

Reported by Cppcheck.

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

Line: 124

              };


TEST_F(TopologyVersionObserverTest, PopulateCache) {
    auto cachedResponse = getObserverCache();
    ASSERT(cachedResponse);

    auto opCtx = makeOperationContext();
    auto expectedResponse =

            

Reported by Cppcheck.

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

Line: 57

                  return haystack.find(needle) != std::string::npos;
}

TEST(ReplSetRequestVotes, ArgsAcceptsUnknownField) {
    ReplSetRequestVotesArgs requestVoteArgs;
    BSONObjBuilder bob;
    requestVoteArgs.addToBSON(&bob);
    bob.append("unknownField", 1);  // append an unknown field.
    BSONObj cmdObj = bob.obj();

            

Reported by Cppcheck.

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

Line: 145

                  WaitForMajorityService _waitForMajorityService;
};

TEST_F(WaitForMajorityServiceTest, ShutdownImmediatelyAfterStartupDoesNotCrashOrHang) {
    waitService()->shutDown();
}

TEST_F(WaitForMajorityServiceNoStartupTest, ShutdownBeforeStartupDoesNotCrashOrHang) {
    waitService()->shutDown();

            

Reported by Cppcheck.

src/mongo/db/s/active_migrations_registry_test.cpp
1 issues
syntax error
Error

Line: 79

                  return assertGet(MoveChunkRequest::createFromCommand(nss, builder.obj()));
}

TEST_F(MoveChunkRegistration, ScopedDonateChunkMoveConstructorAndAssignment) {
    auto originalScopedDonateChunk = assertGet(_registry.registerDonateChunk(
        operationContext(), createMoveChunkRequest(NamespaceString("TestDB", "TestColl"))));
    ASSERT(originalScopedDonateChunk.mustExecute());

    ScopedDonateChunk movedScopedDonateChunk(std::move(originalScopedDonateChunk));

            

Reported by Cppcheck.

src/mongo/db/s/balancer/balance_stats_test.cpp
1 issues
syntax error
Error

Line: 82

                  ChunkVersion _nextVersion{1, 0, _epoch, boost::none};
};

TEST_F(BalanceStatsTest, SingleChunkNoZones) {
    std::vector<ShardType> shards;
    shards.push_back(makeShard("a"));

    std::vector<ChunkType> chunks;
    chunks.push_back(makeChunk(BSON("x" << MINKEY), BSON("x" << MAXKEY), ShardId("a")));

            

Reported by Cppcheck.

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

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

              
class BalancerChunkSelectionPolicyImpl final : public BalancerChunkSelectionPolicy {
public:
    BalancerChunkSelectionPolicyImpl(ClusterStatistics* clusterStats, BalancerRandomSource& random);
    ~BalancerChunkSelectionPolicyImpl();

    StatusWith<SplitInfoVector> selectChunksToSplit(OperationContext* opCtx) override;

    StatusWith<SplitInfoVector> selectChunksToSplit(OperationContext* opCtx,

            

Reported by FlawFinder.

src/mongo/db/s/balancer/balancer_chunk_selection_policy_test.cpp
1 issues
syntax error
Error

Line: 122

                  std::unique_ptr<BalancerChunkSelectionPolicy> _chunkSelectionPolicy;
};

TEST_F(BalancerChunkSelectionTest, TagRangesOverlap) {
    // Set up two shards in the metadata.
    ASSERT_OK(catalogClient()->insertConfigDocument(
        operationContext(), ShardType::ConfigNS, kShard0, kMajorityWriteConcern));
    ASSERT_OK(catalogClient()->insertConfigDocument(
        operationContext(), ShardType::ConfigNS, kShard1, kMajorityWriteConcern));

            

Reported by Cppcheck.

src/mongo/db/s/balancer/balancer_policy_test.cpp
1 issues
syntax error
Error

Line: 121

                  return BalancerPolicy::balance(shardStats, distribution, &usedShards, forceJumbo);
}

TEST(BalancerPolicy, Basic) {
    auto cluster = generateCluster(
        {{ShardStatistics(kShardId0, kNoMaxSize, 4, false, emptyTagSet, emptyShardVersion), 4},
         {ShardStatistics(kShardId1, kNoMaxSize, 0, false, emptyTagSet, emptyShardVersion), 0},
         {ShardStatistics(kShardId2, kNoMaxSize, 3, false, emptyTagSet, emptyShardVersion), 3}});


            

Reported by Cppcheck.