The following issues were found

src/mongo/db/commands/plan_cache_commands_test.cpp
1 issues
syntax error
Error

Line: 41

              
static const NamespaceString nss{"test.collection"_sd};

TEST(PlanCacheCommandsTest, CannotCanonicalizeWithMissingQueryField) {
    QueryTestServiceContext serviceContext;
    auto opCtx = serviceContext.makeOperationContext();
    ASSERT_NOT_OK(
        plan_cache_commands::canonicalize(opCtx.get(), nss.ns(), fromjson("{}")).getStatus());
}

            

Reported by Cppcheck.

src/mongo/db/commands/shutdown.cpp
1 issues
Boolean value assigned to pointer.
Error

Line: 59 CWE codes: 587

                  // Shared by mongos and mongod shutdown code paths
    LOGV2(4695400,
          "Terminating via shutdown command",
          "force"_attr = force,
          "timeoutSecs"_attr = timeoutSecs);

#if defined(_WIN32)
    // Signal the ServiceMain thread to shutdown.
    if (ntservice::shouldStartService()) {

            

Reported by Cppcheck.

src/mongo/db/commands_test.cpp
1 issues
syntax error
Error

Line: 55

                  ASSERT_BSONOBJ_EQ(actualResult.obj(), expectedResult.obj());
}

TEST(Commands, appendCommandStatusError) {
    BSONObjBuilder actualResult;
    const Status status(ErrorCodes::InvalidLength, "Response payload too long");
    CommandHelpers::appendCommandStatusNoThrow(actualResult, status);

    BSONObjBuilder expectedResult;

            

Reported by Cppcheck.

src/mongo/db/concurrency/d_concurrency_test.cpp
1 issues
syntax error
Error

Line: 137

              };


TEST_F(DConcurrencyTestFixture, WriteConflictRetryInstantiatesOK) {
    auto opCtx = makeOperationContext();
    getClient()->swapLockState(std::make_unique<LockerImpl>());
    writeConflictRetry(opCtx.get(), "", "", [] {});
}


            

Reported by Cppcheck.

src/mongo/db/concurrency/fast_map_noalloc_test.cpp
1 issues
syntax error
Error

Line: 53

              typedef class FastMapNoAlloc<ResourceId, TestStruct> TestFastMapNoAlloc;


TEST(FastMapNoAlloc, Empty) {
    TestFastMapNoAlloc map;
    ASSERT(map.empty());

    TestFastMapNoAlloc::Iterator it = map.begin();
    ASSERT(it.finished());

            

Reported by Cppcheck.

src/mongo/db/concurrency/lock_manager_test.cpp
1 issues
syntax error
Error

Line: 57

                  ASSERT_EQUALS(resId, resIdColl);
}

TEST(ResourceId, Constructors) {
    ResourceId resIdString(RESOURCE_COLLECTION, std::string("TestDB.collection"));
    ResourceId resIdStringData(RESOURCE_COLLECTION, StringData("TestDB.collection"));

    ASSERT_EQUALS(resIdString, resIdStringData);
}

            

Reported by Cppcheck.

src/mongo/db/concurrency/lock_state_test.cpp
1 issues
syntax error
Error

Line: 53

              
class LockerImplTest : public ServiceContextTest {};

TEST_F(LockerImplTest, LockNoConflict) {
    auto opCtx = makeOperationContext();

    const ResourceId resId(RESOURCE_COLLECTION, "TestDB.collection"_sd);

    LockerImpl locker;

            

Reported by Cppcheck.

src/mongo/db/concurrency/lock_stats_test.cpp
1 issues
syntax error
Error

Line: 41

              
class LockStatsTest : public ServiceContextTest {};

TEST_F(LockStatsTest, NoWait) {
    const ResourceId resId(RESOURCE_COLLECTION, std::string("LockStats.NoWait"));

    resetGlobalLockStats();

    auto opCtx = makeOperationContext();

            

Reported by Cppcheck.

src/mongo/db/cst/bson_lexer_test.cpp
1 issues
syntax error
Error

Line: 62

                  ASSERT_EQ(ParserGen::token::END_OF_FILE, lexer.getNext().type_get());
}

TEST(BSONLexerTest, TokenizesReservedKeywords) {
    auto input = fromjson("{pipeline: [{$_internalInhibitOptimization: {}}]}");
    BSONLexer lexer(input["pipeline"].embeddedObject(), ParserGen::token::START_PIPELINE);
    ASSERT_EQ(ParserGen::token::START_PIPELINE, lexer.getNext().type_get());
    ASSERT_EQ(ParserGen::token::START_ARRAY, lexer.getNext().type_get());
    ASSERT_EQ(ParserGen::token::START_OBJECT, lexer.getNext().type_get());

            

Reported by Cppcheck.

src/mongo/db/cst/c_node_validation.cpp
1 issues
Internal error. Token::astOperand1() cyclic dependency.
Error

Line: 185

                  // previous would be also prefixed by the path that prefixes the emplaced path and violate
    // the invariant. Thus it sufficies to check only these two positions in the set after
    // emplacing to guarantee there are no prefix relationships in the entire set.
    if (auto&& [iter, notDuplicate] = seenPaths->emplace(currentPath); notDuplicate) {
        if (iter != seenPaths->begin())
            if (auto status = validateNotPrefix(currentPath, *std::prev(iter)); !status.isOK())
                return status;
        if (std::next(iter) != seenPaths->end())
            if (auto status = validateNotPrefix(currentPath, *std::next(iter)); !status.isOK())

            

Reported by Cppcheck.