The following issues were found
src/mongo/db/stats/api_version_metrics_test.cpp
1 issues
Line: 89
std::shared_ptr<ClockSourceMock> _clkSource = std::make_shared<ClockSourceMock>();
};
TEST_F(APIVersionMetricsTest, StoresDefaultMetrics) {
ASSERT_FALSE(apiParams.getParamsPassed());
getMetrics().update(appName, apiParams);
auto metricsMap = getMetrics().getAPIVersionMetrics_forTest();
Reported by Cppcheck.
src/mongo/db/stats/fill_locker_info_test.cpp
1 issues
Line: 57
ASSERT_TRUE(infoObj["waitingForLock"].Bool());
}
TEST(FillLockerInfo, DoesNotReportWaitingForLockIfNotWaiting) {
LockerInfo info;
info.waitingResource = ResourceId(); // This means it is not waiting for anything.
ASSERT_FALSE(info.waitingResource.isValid());
BSONObjBuilder infoBuilder;
Reported by Cppcheck.
src/mongo/db/stats/operation_latency_histogram_test.cpp
1 issues
Line: 50
const std::array<uint64_t, kMaxBuckets>& kLowerBounds = OperationLatencyHistogram::kLowerBounds;
} // namespace
TEST(OperationLatencyHistogram, EnsureIncrementsStored) {
OperationLatencyHistogram hist;
for (int i = 0; i < kMaxBuckets; i++) {
hist.increment(i, Command::ReadWriteType::kRead);
hist.increment(i, Command::ReadWriteType::kWrite);
hist.increment(i, Command::ReadWriteType::kCommand);
Reported by Cppcheck.
src/mongo/db/stats/resource_consumption_metrics_test.cpp
1 issues
Line: 73
ServiceContext::UniqueOperationContext _opCtx;
};
TEST_F(ResourceConsumptionMetricsTest, Merge) {
auto& globalResourceConsumption = ResourceConsumption::get(getServiceContext());
auto& operationMetrics = ResourceConsumption::MetricsCollector::get(_opCtx.get());
operationMetrics.beginScopedCollecting(_opCtx.get(), "db1");
Reported by Cppcheck.
src/mongo/db/stats/timer_stats_test.cpp
1 issues
Line: 41
using namespace mongo;
TEST(TimerStatsTest, GetReportNoRecording) {
ASSERT_BSONOBJ_EQ(BSON("num" << 0 << "totalMillis" << 0), TimerStats().getReport());
}
TEST(TimerStatsTest, GetReportOneRecording) {
TimerStats timerStats;
Reported by Cppcheck.
src/mongo/db/stats/top_test.cpp
1 issues
Line: 39
using namespace mongo;
TEST(TopTest, CollectionDropped) {
Top().collectionDropped(NamespaceString("test.coll"));
}
} // namespace
Reported by Cppcheck.
src/mongo/db/storage/bson_collection_catalog_entry.cpp
1 issues
Line: 57
Column: 5
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
void appendMultikeyPathsAsBytes(BSONObj keyPattern,
const MultikeyPaths& multikeyPaths,
BSONObjBuilder* bob) {
char multikeyPathsEncodedAsBytes[kMaxKeyPatternPathLength];
size_t i = 0;
for (const auto& keyElem : keyPattern) {
StringData keyName = keyElem.fieldNameStringData();
size_t numParts = FieldRef{keyName}.numParts();
Reported by FlawFinder.
src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp
1 issues
Line: 93
};
TEST_F(EphemeralForTestKVEngineTest, AvailableHistoryUpdate) {
NamespaceString nss("a.b");
std::string ident = "collection-1234";
std::string record = "abcd";
CollectionOptions defaultCollectionOptions;
Reported by Cppcheck.
src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store_concurrent_test.cpp
1 issues
Line: 232
class ConcurrentRadixStoreTestFourThreads : public ConcurrentRadixStoreTest<4> {};
class ConcurrentRadixStoreTestNineThreads : public ConcurrentRadixStoreTest<9> {};
TEST_F(ConcurrentRadixStoreTestFourThreads, UpdateDifferentKeysDifferentBranches) {
setup([](StringStore& tree) {
tree.insert({"a", ""});
tree.insert({"b", ""});
tree.insert({"c", ""});
tree.insert({"d", ""});
Reported by Cppcheck.
src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store_test.cpp
1 issues
Line: 130
StringStore expected;
};
TEST_F(RadixStoreTest, SimpleInsertTest) {
value_type value1 = std::make_pair("food", "1");
value_type value2 = std::make_pair("foo", "2");
value_type value3 = std::make_pair("bar", "3");
std::pair<StringStore::const_iterator, bool> res = thisStore.insert(value_type(value1));
Reported by Cppcheck.