The following issues were found

src/mongo/s/query/async_results_merger_test.cpp
1 issues
syntax error
Error

Line: 72

              
using AsyncResultsMergerTest = ResultsMergerTestFixture;

TEST_F(AsyncResultsMergerTest, SingleShardUnsorted) {
    std::vector<RemoteCursor> cursors;
    cursors.push_back(
        makeRemoteCursor(kTestShardIds[0], kTestShardHosts[0], CursorResponse(kTestNss, 5, {})));
    auto arm = makeARMFromExistingCursors(std::move(cursors));


            

Reported by Cppcheck.

src/mongo/s/query/blocking_results_merger_test.cpp
1 issues
syntax error
Error

Line: 55

                  blockingMerger.kill(operationContext());
}

TEST_F(ResultsMergerTestFixture, ShouldBeAbleToBlockUntilDeadlineExpires) {
    // Set the deadline to be two seconds in the future. We always test that the deadline
    // expires, so there's no racing.
    awaitDataState(operationContext()).waitForInsertsDeadline =
        getMockClockSource()->now() + Milliseconds{2000};
    awaitDataState(operationContext()).shouldWaitForInserts = true;

            

Reported by Cppcheck.

src/mongo/s/query/cluster_client_cursor_impl_test.cpp
1 issues
syntax error
Error

Line: 53

                  ServiceContext::UniqueOperationContext _opCtx;
};

TEST_F(ClusterClientCursorImplTest, NumReturnedSoFar) {
    auto mockStage = std::make_unique<RouterStageMock>(_opCtx.get());
    for (int i = 1; i < 10; ++i) {
        mockStage->queueResult(BSON("a" << i));
    }


            

Reported by Cppcheck.

src/mongo/s/query/cluster_cursor_manager_test.cpp
1 issues
syntax error
Error

Line: 133

              };

// Test that registering a cursor and checking it out returns a pin to the same cursor.
TEST_F(ClusterCursorManagerTest, RegisterCursor) {
    auto cursor = allocateMockCursor();
    cursor->queueResult(BSON("a" << 1));
    auto cursorId =
        assertGet(getManager()->registerCursor(_opCtx.get(),
                                               std::move(cursor),

            

Reported by Cppcheck.

src/mongo/s/query/cluster_exchange_test.cpp
1 issues
syntax error
Error

Line: 63

                  boost::optional<ChunkVersion> _mergeTargetCollectionVersion;
};

TEST_F(ClusterExchangeTest, ShouldNotExchangeIfPipelineDoesNotEndWithMerge) {
    setupNShards(2);
    auto mergePipe = Pipeline::create({DocumentSourceLimit::create(expCtx(), 1)}, expCtx());
    ASSERT_FALSE(
        sharded_agg_helpers::checkIfEligibleForExchange(operationContext(), mergePipe.get()));
    mergePipe = Pipeline::create({DocumentSourceMatch::create(BSONObj(), expCtx())}, expCtx());

            

Reported by Cppcheck.

src/mongo/s/query/establish_cursors_test.cpp
1 issues
syntax error
Error

Line: 106

                  const NamespaceString _nss;
};

TEST_F(EstablishCursorsTest, NoRemotes) {
    std::vector<std::pair<ShardId, BSONObj>> remotes;
    auto cursors = establishCursors(operationContext(),
                                    executor(),
                                    _nss,
                                    ReadPreferenceSetting{ReadPreference::PrimaryOnly},

            

Reported by Cppcheck.

src/mongo/s/query/router_stage_limit_test.cpp
1 issues
syntax error
Error

Line: 49

              // going through the trouble of making one, we'll just use nullptr throughout.
OperationContext* opCtx = nullptr;

TEST(RouterStageLimitTest, LimitIsOne) {
    auto mockStage = std::make_unique<RouterStageMock>(opCtx);
    mockStage->queueResult({BSON("a" << 1)});
    mockStage->queueResult({BSON("a" << 2)});
    mockStage->queueResult({BSON("a" << 3)});


            

Reported by Cppcheck.

src/mongo/s/query/router_stage_remove_metadata_fields_test.cpp
1 issues
syntax error
Error

Line: 50

              // going through the trouble of making one, we'll just use nullptr throughout.
OperationContext* opCtx = nullptr;

TEST(RouterStageRemoveMetadataFieldsTest, RemovesMetaDataFields) {
    auto mockStage = std::make_unique<RouterStageMock>(opCtx);
    mockStage->queueResult(BSON("a" << 4 << "$sortKey" << 1 << "b" << 3));
    mockStage->queueResult(BSON("$sortKey" << BSON("" << 3) << "c"
                                           << BSON("d"
                                                   << "foo")));

            

Reported by Cppcheck.

src/mongo/s/query/router_stage_skip_test.cpp
1 issues
syntax error
Error

Line: 49

              // going through the trouble of making one, we'll just use nullptr throughout.
OperationContext* opCtx = nullptr;

TEST(RouterStageSkipTest, SkipIsOne) {
    auto mockStage = std::make_unique<RouterStageMock>(opCtx);
    mockStage->queueResult(BSON("a" << 1));
    mockStage->queueResult(BSON("a" << 2));
    mockStage->queueResult(BSON("a" << 3));


            

Reported by Cppcheck.

src/mongo/s/query/store_possible_cursor_test.cpp
1 issues
syntax error
Error

Line: 67

              };

// Test that storePossibleCursor() returns a valid cursor response document.
TEST_F(StorePossibleCursorTest, ReturnsValidCursorResponse) {
    std::vector<BSONObj> batch = {fromjson("{_id: 1}"), fromjson("{_id: 2}")};
    CursorResponse cursorResponse(nss, CursorId(0), batch);
    auto outgoingCursorResponse =
        storePossibleCursor(opCtx(),
                            shardId,

            

Reported by Cppcheck.