The following issues were found
src/mongo/db/s/type_locks_test.cpp
1 issues
Line: 46
ASSERT_EQUALS(ErrorCodes::NoSuchKey, locksResult.getStatus());
}
TEST(Validity, UnlockedWithOptional) {
OID testLockID = OID::gen();
BSONObj obj =
BSON(LocksType::name("dummy")
<< LocksType::process("host.local:27017:1352918870:16807")
<< LocksType::state(LocksType::State::UNLOCKED) << LocksType::lockID(testLockID)
Reported by Cppcheck.
src/mongo/db/s/type_shard_collection_test.cpp
1 issues
Line: 47
const BSONObj kDefaultCollation = BSON("locale"
<< "fr_CA");
TEST(ShardCollectionType, FromBSONEmptyShardKeyFails) {
ASSERT_THROWS_CODE(
ShardCollectionType(BSON(ShardCollectionType::kNssFieldName
<< kNss.ns() << ShardCollectionType::kEpochFieldName << OID::gen()
<< ShardCollectionType::kUuidFieldName << UUID::gen()
<< ShardCollectionType::kKeyPatternFieldName << BSONObj()
Reported by Cppcheck.
src/mongo/db/s/type_shard_identity_test.cpp
1 issues
Line: 60
ASSERT_BSONOBJ_EQ(doc, shardIdentity.toShardIdentityDocument());
}
TEST(ShardIdentityType, ParseMissingId) {
auto doc = BSON("configsvrConnectionString"
<< "test/a:123"
<< "shardName"
<< "s1"
<< "clusterId" << OID::gen());
Reported by Cppcheck.
src/mongo/db/s/vector_clock_config_server_test.cpp
1 issues
Line: 82
};
TEST_F(VectorClockConfigServerTest, TickClusterTime) {
auto sc = getServiceContext();
auto vc = VectorClockMutable::get(sc);
const auto t0 = vc->getTime();
ASSERT_EQ(LogicalTime(Timestamp(1, 0)), t0.clusterTime());
Reported by Cppcheck.
src/mongo/db/s/vector_clock_shard_server_test.cpp
1 issues
Line: 83
};
TEST_F(VectorClockShardServerTest, TickClusterTime) {
auto sc = getServiceContext();
auto vc = VectorClockMutable::get(sc);
const auto t0 = vc->getTime();
ASSERT_EQ(LogicalTime(Timestamp(1, 0)), t0.clusterTime());
Reported by Cppcheck.
src/mongo/db/server_options_test.cpp
1 issues
Line: 108
mongo::logv2::LogSeverity::Info()};
};
TEST_F(Verbosity, Default) {
OptionsParserTester parser;
moe::Environment environment;
moe::OptionSection options;
ASSERT_OK(::mongo::addGeneralServerOptions(&options));
Reported by Cppcheck.
src/mongo/db/session_catalog_mongod_test.cpp
1 issues
Line: 71
std::make_shared<MockSessionsCollection>(_collectionMock)};
};
TEST_F(MongoDSessionCatalogTest, ReapSomeExpiredSomeNot) {
// Create some "old" sessions
DBDirectClient client(_opCtx);
SessionTxnRecord txn1(
makeLogicalSessionIdForTest(), 100, repl::OpTime(Timestamp(100), 1), clock()->now());
SessionTxnRecord txn2(
Reported by Cppcheck.
src/mongo/db/session_catalog_test.cpp
1 issues
Line: 83
const bool _wasInDirectClient;
};
TEST_F(SessionCatalogTest, GetParentSessionId) {
auto parentLsid = makeLogicalSessionIdForTest();
ASSERT(!getParentSessionId(parentLsid).has_value());
ASSERT_EQ(parentLsid,
*getParentSessionId(makeLogicalSessionIdWithTxnNumberForTest(parentLsid)));
ASSERT_EQ(parentLsid, *getParentSessionId(makeLogicalSessionIdWithTxnUUIDForTest(parentLsid)));
Reported by Cppcheck.
src/mongo/db/sorter/sorter.h
1 issues
Line: 281
Column: 14
CWE codes:
120
20
* Reads the requested data from the file. Cannot write more to the file once this has been
* called.
*/
void read(std::streamoff offset, std::streamsize size, void* out);
/**
* Writes the given data to the end of the file. Cannot be called after reading.
*/
void write(const char* data, std::streamsize size);
Reported by FlawFinder.
src/mongo/db/startup_warnings_mongod_test.cpp
1 issues
Line: 45
using namespace mongo;
TEST(StartupWarningsMongodTest, ReadTransparentHugePagesParameterInvalidDirectory) {
StatusWith<std::string> result =
StartupWarningsMongod::readTransparentHugePagesParameter("no_such_directory", "param");
ASSERT_NOT_OK(result.getStatus());
ASSERT_EQUALS(ErrorCodes::NonExistentPath, result.getStatus().code());
}
Reported by Cppcheck.