The following issues were found

src/mongo/executor/thread_pool_task_executor_test.cpp
1 issues
syntax error
Error

Line: 58

                  });
}

TEST_F(ThreadPoolExecutorTest, TimelyCancellationOfScheduleWorkAt) {
    auto net = getNet();
    auto& executor = getExecutor();
    launchExecutorThread();
    auto status1 = getDetectableErrorStatus();
    const auto now = net->now();

            

Reported by Cppcheck.

src/mongo/executor/thread_pool_task_executor_with_mock_net_stress_test.cpp
1 issues
syntax error
Error

Line: 52

                  });
}

TEST_F(ThreadPoolExecutorMockNetStressTest, StressTest) {
#if defined(__APPLE__) && defined(__aarch64__)
    // TODO: Fix this test under mac os arm64.
#else
    // The idea is to have as much concurrency in the 'executor' as possible. However adding
    // too many threads increases contention in the ThreadPoolExecutorStressTestEngine

            

Reported by Cppcheck.

src/mongo/idl/command_generic_argument_test.cpp
1 issues
syntax error
Error

Line: 90

                  {"$topologyTime"_sd,                     1, 1, 1}}};
// clang-format on

TEST(CommandGenericArgument, AllGenericArgumentsAndReplyFields) {
    for (const auto& record : specials) {
        if (isGenericArgument(record.name) != record.isGeneric) {
            FAIL("isGenericArgument('{}') should be {}, but it's {}"_format(
                record.name, record.isGeneric, isGenericArgument(record.name)));
        }

            

Reported by Cppcheck.

src/mongo/idl/config_option_test.cpp
1 issues
syntax error
Error

Line: 124

                  ASSERT_THROWS(env[name].as<T>(), AssertionException);
}

TEST(ConfigOption, Opt1) {
    ASSERT_OPTION_NOT_SET<bool>(moe::startupOptionsParsed, "test.config.opt1");

    moe::Environment parsed;
    ASSERT_OK(parseArgv({"mongod", "--testConfigOpt1"}, &parsed));
    ASSERT_OPTION_SET<bool>(parsed, "test.config.opt1", true);

            

Reported by Cppcheck.

src/mongo/idl/feature_flag_test.cpp
1 issues
syntax error
Error

Line: 78

              }

// Sanity check feature flags
TEST(IDLFeatureFlag, Basic) {
    // false is set by "default" attribute in the IDL file.
    ASSERT(feature_flags::gFeatureFlagToaster.isEnabledAndIgnoreFCV() == false);

    auto* featureFlagToaster = getServerParameter("featureFlagToaster");
    ASSERT_OK(featureFlagToaster->setFromString("true"));

            

Reported by Cppcheck.

src/mongo/idl/idl_test.cpp
1 issues
syntax error
Error

Line: 201

              
/// Type tests:
// Positive: Test we can serialize the type out and back again
TEST(IDLOneTypeTests, TestLoopbackTest) {
    TestLoopback<One_string, const StringData, String>("test_value");
    TestLoopback<One_int, std::int32_t, NumberInt>(123);
    TestLoopback<One_long, std::int64_t, NumberLong>(456);
    TestLoopback<One_double, double, NumberDouble>(3.14159);
    TestLoopback<One_bool, bool, Bool>(true);

            

Reported by Cppcheck.

src/mongo/idl/server_parameter.cpp
1 issues
There is an unknown macro here somewhere. Configuration is required. If MONGO_INITIALIZER_GROUP is a macro then please configure it.
Error

Line: 39

              namespace mongo {
using SPT = ServerParameterType;

MONGO_INITIALIZER_GROUP(BeginServerParameterRegistration, (), ("EndServerParameterRegistration"))
MONGO_INITIALIZER_GROUP(EndServerParameterRegistration,
                        ("BeginServerParameterRegistration"),
                        ("BeginStartupOptionHandling"))

ServerParameter::ServerParameter(StringData name, ServerParameterType spt)

            

Reported by Cppcheck.

src/mongo/idl/server_parameter_specialized_test.cpp
1 issues
syntax error
Error

Line: 97

                  return Status::OK();
}

TEST(SpecializedServerParameter, dummy) {
    auto* dsp = getServerParameter("specializedDummy");
    ASSERT_APPENDED_STRING(dsp, "Dummy Value");
    ASSERT_OK(dsp->setFromString("new value"));
    ASSERT_NOT_OK(dsp->set(BSON("" << BSON_ARRAY("bar")).firstElement()));
    ASSERT_OK(dsp->set(BSON(""

            

Reported by Cppcheck.

src/mongo/idl/server_parameter_with_storage_test.cpp
1 issues
syntax error
Error

Line: 143

                  doStorageTest<T, SPT::kStartupAndRuntime>("StartupAndRuntime" + name, valid, invalid);
}

TEST(ServerParameterWithStorage, StorageTest) {
    const std::vector<std::string> boolVals = {"true", "false", "1", "0"};
    const std::vector<std::string> numberVals = {"-2", "-1", "0", "1", "2", "3"};
    const std::vector<std::string> doubleVals = {"3.14", "2.71", "-1.1", "NaN", "INF", "-INF"};
    const std::vector<std::string> stringVals = {"purple", "moist"};


            

Reported by Cppcheck.

src/mongo/logv2/log_debug.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 45 Column: 24 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              template <std::size_t I>
inline constexpr char digit = "0123456789"[I];
template <std::size_t N>
inline constexpr const char attrName[4] = {'_', digit<(N / 10) % 10>, digit<N % 10>, '\0'};

template <std::size_t... Is, typename... Args>
auto argAttrs_(std::index_sequence<Is...>, const Args&... args) {
    return makeAttributeStorage((AttrUdl{attrName<Is>} = args)...);
}

            

Reported by FlawFinder.