The following issues were found
src/mongo/db/views/view_definition_test.cpp
1 issues
Line: 52
const NamespaceString bucketsColl("testdb.system.buckets.testcoll");
const BSONObj samplePipeline = BSON_ARRAY(BSON("limit" << 9));
TEST(ViewDefinitionTest, ViewDefinitionCreationCorrectlyBuildsNamespaceStrings) {
ViewDefinition viewDef(
viewNss.db(), viewNss.coll(), backingNss.coll(), samplePipeline, nullptr);
ASSERT_EQ(viewDef.name(), viewNss);
ASSERT_EQ(viewDef.viewOn(), backingNss);
}
Reported by Cppcheck.
src/mongo/db/views/view_graph_test.cpp
1 issues
Line: 95
ViewGraph _viewGraph;
};
TEST_F(ViewGraphFixture, CanInsertViewsWithMatchingBinaryCollations) {
const auto fooView =
makeViewDefinition(kTestDb, kFooName, kBarName, kEmptyPipeline, kBinaryCollation);
ASSERT_OK(viewGraph()->insertAndValidate(fooView, {kBarNamespace}, kEmptyPipelineSize));
ASSERT_EQ(viewGraph()->size(), 2UL);
Reported by Cppcheck.
src/mongo/db/write_concern_options_test.cpp
1 issues
Line: 45
ASSERT_EQUALS("write concern object cannot be empty", status.reason());
}
TEST(WriteConcernOptionsTest, ParseReturnsFailedToParseOnInvalidJValue) {
auto status = WriteConcernOptions::parse(BSON("j"
<< "abc"))
.getStatus();
ASSERT_EQUALS(ErrorCodes::FailedToParse, status);
ASSERT_EQUALS("j must be numeric or a boolean value", status.reason());
Reported by Cppcheck.
src/mongo/dbtests/cursor_manager_test.cpp
1 issues
Line: 145
/**
* Test that an attempt to kill a pinned cursor succeeds.
*/
TEST_F(CursorManagerTest, ShouldBeAbleToKillPinnedCursor) {
CursorManager* cursorManager = useCursorManager();
OperationContext* const pinningOpCtx = _opCtx.get();
auto cursorPin = cursorManager->registerCursor(
pinningOpCtx,
Reported by Cppcheck.
src/mongo/dbtests/documentsourcetests.cpp
1 issues
Line: 143
};
/** Create a DocumentSourceCursor. */
TEST_F(DocumentSourceCursorTest, Empty) {
createSource();
// The DocumentSourceCursor doesn't hold a read lock.
ASSERT(!opCtx()->lockState()->isReadLocked());
// The collection is empty, so the source produces no results.
ASSERT(source()->getNext().isEOF());
Reported by Cppcheck.
src/mongo/dbtests/extensions_callback_real_test.cpp
1 issues
Line: 85
bool _isDesugarWhereToFunctionOn{false};
};
TEST_F(ExtensionsCallbackRealTest, TextNoIndex) {
BSONObj query = fromjson("{$text: {$search:\"awesome\"}}");
ASSERT_THROWS_CODE(StatusWithMatchExpression(
ExtensionsCallbackReal(&_opCtx, &_nss).parseText(query.firstElement())),
AssertionException,
ErrorCodes::IndexNotFound);
Reported by Cppcheck.
src/mongo/dbtests/framework.cpp
1 issues
Line: 107
Column: 5
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
return std::unique_ptr<DBClientBase>(new DBDirectClient(opCtx));
});
srand((unsigned)frameworkGlobalParams.seed);
// Set up the periodic runner for background job execution, which is required by the storage
// engine to be running beforehand.
auto runner = makePeriodicRunner(globalServiceContext);
globalServiceContext->setPeriodicRunner(std::move(runner));
Reported by FlawFinder.
src/mongo/dbtests/index_access_method_test.cpp
1 issues
Line: 53
return keyStrings;
}
TEST(IndexAccessMethodSetDifference, EmptyInputsShouldHaveNoDifference) {
KeyStringSet left;
KeyStringSet right;
auto diff = AbstractIndexAccessMethod::setDifference(left, right);
ASSERT_EQ(0UL, diff.first.size());
ASSERT_EQ(0UL, diff.second.size());
Reported by Cppcheck.
src/mongo/dbtests/insert_test.cpp
1 issues
Line: 81
return obj;
}
TEST_F(InsertTest, FixDocumentForInsertAcceptsEmptyDocuments) {
ASSERT_OK(fixDocumentForInsert(getOperationContext(), BSONObj()));
}
TEST_F(InsertTest, FixDocumentForInsertAcceptsDocumentsAtStorageDepthLimit) {
ASSERT_OK(fixDocumentForInsert(getOperationContext(),
Reported by Cppcheck.
src/mongo/dbtests/mock_dbclient_conn_test.cpp
1 issues
Line: 68
ASSERT_EQUALS(mongo::HostAndPort("test"), conn.getServerHostAndPort());
}
TEST(MockDBClientConnTest, QueryCount) {
MockRemoteDBServer server("test");
{
MockDBClientConnection conn(&server);
Reported by Cppcheck.