The following issues were found

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

Line: 568

                  ASSERT_EQUALS(docs.back()["ts"].timestamp(), lastFetched.getTimestamp());
}

TEST_F(OplogFetcherTest, ShuttingExecutorDownShouldPreventOplogFetcherFromStarting) {
    getExecutor().shutdown();

    auto oplogFetcher = makeOplogFetcher();

    // Last optime fetched should match values passed to constructor.

            

Reported by Cppcheck.

src/mongo/db/repl/oplog_interface_remote.cpp
1 issues
Shifting by a negative value is undefined behaviour
Error

Line: 84 CWE codes: 758

              }

std::unique_ptr<OplogInterface::Iterator> OplogInterfaceRemote::makeIterator() const {
    const Query query = Query().sort(BSON("$natural" << -1));
    const BSONObj fields = BSON("ts" << 1 << "t" << 1LL);
    return std::unique_ptr<OplogInterface::Iterator>(
        new OplogIteratorRemote(_getConnection()->query(NamespaceString(_collectionName),
                                                        query,
                                                        0,

            

Reported by Cppcheck.

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

Line: 93

                  return unittest::assertGet(OplogEntry::parse(opEntry.first));
}

TEST_F(OplogTest, LogOpReturnsOpTimeOnSuccessfulInsertIntoOplogCollection) {
    auto opCtx = cc().makeOperationContext();

    const NamespaceString nss("test.coll");
    auto msgObj = BSON("msg"
                       << "hello, world!");

            

Reported by Cppcheck.

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

Line: 57

                  ASSERT(ReadConcernLevel::kLocalReadConcern == readConcern.getLevel());
}

TEST(ReadAfterParse, AfterClusterTimeOnly) {
    ReadConcernArgs readConcern;
    auto afterClusterTime = LogicalTime(Timestamp(20, 30));
    ASSERT_OK(readConcern.initialize(BSON("find"
                                          << "test" << ReadConcernArgs::kReadConcernFieldName
                                          << BSON(ReadConcernArgs::kAfterClusterTimeFieldName

            

Reported by Cppcheck.

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

Line: 53

              
using unittest::EnsureFCV;

TEST_F(ServiceContextTest, ValidateConfigForInitiate_VersionMustBe1) {
    ReplicationCoordinatorExternalStateMock rses;
    rses.addSelf(HostAndPort("h1"));

    ReplSetConfig config;
    OID newReplSetId = OID::gen();

            

Reported by Cppcheck.

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

Line: 81

                  return fromjson(configJson);
}

TEST(ReplSetConfig, ParseMinimalConfigAndCheckDefaults) {
    ReplSetConfig config(
        ReplSetConfig::parse(BSON("_id"
                                  << "rs0"
                                  << "version" << 1 << "term" << 1 << "protocolVersion" << 1
                                  << "members"

            

Reported by Cppcheck.

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

Line: 47

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

TEST(ReplSetHeartbeatResponse, DefaultConstructThenSlowlyBuildToFullObj) {
    int fieldsSet = 1;
    ReplSetHeartbeatResponse hbResponse;
    ReplSetHeartbeatResponse hbResponseObjRoundTripChecker;
    OpTime durableOpTime = OpTime(Timestamp(10), 0);
    Date_t durableWallTime = Date_t() + Seconds(durableOpTime.getSecs());

            

Reported by Cppcheck.

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

Line: 62

                  return os;
}

TEST(ReplSetTagConfigTest, MakeAndFindTags) {
    ReplSetTagConfig tagConfig;
    ReplSetTag dcNY = tagConfig.makeTag("dc", "ny");
    ReplSetTag dcRI = tagConfig.makeTag("dc", "ri");
    ReplSetTag rack1 = tagConfig.makeTag("rack", "1");
    ReplSetTag rack2 = tagConfig.makeTag("rack", "2");

            

Reported by Cppcheck.

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

Line: 54

                  ASSERT(tagPatternMap.empty());
}

TEST(ReplSetWriteConcernModeDefinitions, Empty) {
    auto definitions = ReplSetWriteConcernModeDefinitions::parseFromBSON(
        BSON("someTag" << BSONObj()).firstElement());
    BSONObjBuilder bob;
    definitions.serializeToBSON("someTag", &bob);
    ASSERT_BSONOBJ_EQ(bob.obj(), BSON("someTag" << BSONObj()));

            

Reported by Cppcheck.

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

Line: 192

              };


TEST_F(ReplicaSetAwareServiceTest, ReplicaSetAwareService) {
    auto sc = getGlobalServiceContext();
    auto opCtxHolder = makeOperationContext();
    auto opCtx = opCtxHolder.get();

    auto a = ServiceA::get(sc);

            

Reported by Cppcheck.