The following issues were found

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

Line: 79

                  }
};

TEST_F(ReshardingCoordinatorObserverTest, onReshardingParticipantTransitionSucceeds) {
    auto reshardingObserver = std::make_shared<ReshardingCoordinatorObserver>();
    auto fut = reshardingObserver->awaitAllRecipientsFinishedCloning();
    ASSERT_FALSE(fut.isReady());

    auto donorShards = makeMockDonorsInState(DonorStateEnum::kDonatingInitialData, Timestamp(1, 1));

            

Reported by Cppcheck.

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

Line: 523

                  long long _term = 0;
};

TEST_F(ReshardingCoordinatorServiceTest, ReshardingCoordinatorSuccessfullyTransitionsTokDone) {
    const std::vector<CoordinatorStateEnum> coordinatorStates{
        CoordinatorStateEnum::kPreparingToDonate,
        CoordinatorStateEnum::kCloning,
        CoordinatorStateEnum::kApplying,
        CoordinatorStateEnum::kBlockingWrites,

            

Reported by Cppcheck.

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

Line: 708

                  };
};

TEST_F(ReshardingCoordinatorPersistenceTest, WriteInitialInfoSucceeds) {
    auto coordinatorDoc = makeCoordinatorDoc(CoordinatorStateEnum::kInitializing);

    // Ensure the chunks for the original namespace exist since they will be bumped as a product of
    // the state transition to kPreparingToDonate.
    auto donorChunk = makeAndInsertChunksForDonorShard(

            

Reported by Cppcheck.

src/mongo/db/s/resharding/resharding_data_copy_util.cpp
1 issues
Shifting by a negative value is undefined behaviour
Error

Line: 167 CWE codes: 758

              Value findHighestInsertedId(OperationContext* opCtx, const CollectionPtr& collection) {
    auto findCommand = std::make_unique<FindCommandRequest>(collection->ns());
    findCommand->setLimit(1);
    findCommand->setSort(BSON("_id" << -1));

    auto recordId =
        Helpers::findOne(opCtx, collection, std::move(findCommand), true /* requireIndex */);
    if (recordId.isNull()) {
        return Value{};

            

Reported by Cppcheck.

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

Line: 116

                  const ShardId _myDonorId{"myDonorId"};
};

TEST_F(ReshardingDataReplicationTest, StashCollectionsHaveSameCollationAsReshardingCollection) {
    CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
    auto sourceChunkMgr = makeChunkManagerForSourceCollection(collator.clone());

    auto stashCollections = [&] {
        auto opCtx = makeOperationContext();

            

Reported by Cppcheck.

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

Line: 228

                  RAIIServerParameterControllerForTest controller{"reshardingOplogBatchLimitOperations", 1};
};

TEST_F(ReshardingDonorOplogIterTest, BasicExhaust) {
    const auto oplog1 = makeInsertOplog(Timestamp(2, 4), BSON("x" << 1));
    const auto oplog2 = makeInsertOplog(Timestamp(33, 6), BSON("y" << 1));
    const auto finalOplog = makeFinalOplog(Timestamp(43, 24));
    const auto oplogBeyond = makeInsertOplog(Timestamp(123, 46), BSON("z" << 1));


            

Reported by Cppcheck.

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

Line: 53

              
using namespace fmt::literals;

TEST_F(ReshardingDonorRecipientCommonInternalsTest, ConstructDonorDocumentFromReshardingFields) {
    OperationContext* opCtx = operationContext();
    auto metadata = makeShardedMetadataForOriginalCollection(opCtx, kThisShard.getShardId());

    auto reshardingFields =
        createCommonReshardingFields(kReshardingUUID, CoordinatorStateEnum::kPreparingToDonate);

            

Reported by Cppcheck.

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

Line: 227

                  std::shared_ptr<DonorStateTransitionController> _controller;
};

TEST_F(ReshardingDonorServiceTest, CanTransitionThroughEachStateToCompletion) {
    for (bool isAlsoRecipient : {false, true}) {
        LOGV2(5641800,
              "Running case",
              "test"_attr = _agent.getTestName(),
              "isAlsoRecipient"_attr = isAlsoRecipient);

            

Reported by Cppcheck.

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

Line: 176

              }
*/

TEST_F(ReshardingMetricsTest, RunOnStepDownAfterOnCompletionIsSafe) {
    startOperation(ReshardingMetrics::Role::kRecipient);
    completeOperation(ReshardingMetrics::Role::kRecipient, ReshardingOperationStatusEnum::kSuccess);
    stepDownOperation(ReshardingMetrics::Role::kRecipient);
}


            

Reported by Cppcheck.

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

Line: 336

                  std::unique_ptr<ReshardingMetrics> _metrics;
};

TEST_F(ReshardingOplogApplierTest, NothingToIterate) {
    std::deque<repl::OplogEntry> crudOps;
    auto iterator = std::make_unique<OplogIteratorMock>(std::move(crudOps), 2 /* batchSize */);

    boost::optional<ReshardingOplogApplier> applier;
    auto executor = makeTaskExecutorForApplier();

            

Reported by Cppcheck.