The following issues were found
src/mongo/db/update/update_object_node_test.cpp
1 issues
Line: 54
using mongo::mutablebson::Element;
using unittest::assertGet;
TEST(UpdateObjectNodeTest, InvalidPathFailsToParse) {
auto update = fromjson("{$set: {'': 5}}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
std::map<StringData, std::unique_ptr<ExpressionWithPlaceholder>> arrayFilters;
std::set<std::string> foundIdentifiers;
UpdateObjectNode root;
Reported by Cppcheck.
src/mongo/db/update/update_oplog_entry_serialization_test.cpp
1 issues
Line: 53
ASSERT(isFieldRemovedByUpdate(o, "z") == FieldRemovedStatus::kFieldNotRemoved);
}
TEST(UpdateOplogSerializationTest, ReadV1EntryWithoutVersionField) {
auto setField = BSON("a" << 1 << "b" << 2);
BSONObj o(BSON("$set" << setField));
ASSERT_BSONELT_EQ(extractNewValueForField(o, "a"), setField["a"]);
ASSERT_BSONELT_EQ(extractNewValueForField(o, "b"), setField["b"]);
Reported by Cppcheck.
src/mongo/db/update/update_serialization_test.cpp
1 issues
Line: 63
mongo::JsonStringFormat::LegacyStrict);
}
TEST(UpdateSerialization, DocumentReplacementSerializesExactly) {
ASSERT_IDENTITY(R"({})", updateRoundTrip);
ASSERT_IDENTITY(R"({ "a" : 23 })", updateRoundTrip);
ASSERT_IDENTITY(R"({ "a" : 23, "b" : false, "c" : "JSON!" })", updateRoundTrip);
ASSERT_IDENTITY(R"({ "a" : [ 1, 2, { "three" : 3 } ] })", updateRoundTrip);
ASSERT_IDENTITY(R"({ "a" : [], "b" : {}, "c" : null })", updateRoundTrip);
Reported by Cppcheck.
src/mongo/db/update/v1_log_builder_test.cpp
1 issues
Line: 56
return RuntimeUpdatePath(std::move(fieldRef), std::move(types));
}
TEST(V1LogBuilder, UpdateFieldMutableBson) {
mmb::Document doc;
V1LogBuilder lb(doc.root());
const mmb::Element elt_ab = doc.makeElementInt("a.b", 1);
ASSERT_TRUE(elt_ab.ok());
Reported by Cppcheck.
src/mongo/db/update/v2_log_builder_test.cpp
1 issues
Line: 71
return RuntimeUpdatePath(std::move(fieldRef), std::move(types));
}
TEST(V2LogBuilder, UpdateFieldWithTopLevelMutableBsonElement) {
mmb::Document doc;
// Element is an array. Modifying a sub-element of mmb::Element does not store the data
// serialized. So we need to call Element::writeToArray() in those cases to serialize the array.
// We explicity modify the sub-element so that this logic can be tested.
const mmb::Element eltArr = doc.makeElementArray("",
Reported by Cppcheck.
src/mongo/db/update_index_data_test.cpp
1 issues
Line: 51
ASSERT_FALSE(a.mightBeIndexed(FieldRef("a.b")));
}
TEST(UpdateIndexDataTest, Simple2) {
UpdateIndexData a;
a.addPath(FieldRef("ab"_sd));
ASSERT_FALSE(a.mightBeIndexed(FieldRef("a")));
a.clear();
ASSERT_FALSE(a.mightBeIndexed(FieldRef("ab")));
Reported by Cppcheck.
src/mongo/db/vector_clock_mongod_test.cpp
1 issues
Line: 86
std::shared_ptr<KeysCollectionManager> _keyManager;
};
TEST_F(VectorClockMongoDTest, 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/vector_clock_test.cpp
1 issues
Line: 61
}
// Check that the initial time does not change during VectorClock creation.
TEST_F(VectorClockTest, roundtrip) {
Timestamp tX(1);
auto time = LogicalTime(tX);
VectorClockMutable::get(getServiceContext())->tickClusterTimeTo(time);
auto storedTime(getClusterTime());
Reported by Cppcheck.
src/mongo/db/views/resolved_view_test.cpp
1 issues
Line: 55
<< aggregation_request_helper::kDefaultBatchSize);
const BSONObj kSimpleCollation;
TEST(ResolvedViewTest, ExpandingAggRequestWithEmptyPipelineOnNoOpViewYieldsEmptyPipeline) {
const ResolvedView resolvedView{backingNss, emptyPipeline, kSimpleCollation};
AggregateCommandRequest requestOnView{viewNss, emptyPipeline};
auto result = resolvedView.asExpandedViewAggregation(requestOnView);
BSONObj expected =
Reported by Cppcheck.
src/mongo/db/views/view_catalog_test.cpp
1 issues
Line: 202
}
};
TEST_F(ViewCatalogFixture, CreateExistingView) {
const NamespaceString viewName("db.view");
const NamespaceString viewOn("db.coll");
ASSERT_OK(createView(operationContext(), viewName, viewOn, emptyPipeline, emptyCollation));
ASSERT_NOT_OK(createView(operationContext(), viewName, viewOn, emptyPipeline, emptyCollation));
Reported by Cppcheck.