The following issues were found
src/mongo/db/query/sbe_stage_builder_index_scan.cpp
1 issues
Line: 194
CWE codes:
562
}
// The 'keysQueue' contains all generated pairs of low/high keys.
return {keysQueue.begin(), keysQueue.end()};
}
/**
* Constructs low/high key values from the given index 'bounds' if they can be represented either as
* a single interval between the low and high keys, or multiple single intervals. If index bounds
Reported by Cppcheck.
src/mongo/db/query/sbe_stage_builder_test.cpp
1 issues
Line: 48
}
};
TEST_F(SbeStageBuilderTest, TestVirtualScan) {
auto docs = std::vector<BSONArray>{BSON_ARRAY(int64_t{0} << BSON("a" << 1 << "b" << 2)),
BSON_ARRAY(int64_t{1} << BSON("a" << 2 << "b" << 2)),
BSON_ARRAY(int64_t{2} << BSON("a" << 3 << "b" << 2))};
// Construct a QuerySolution consisting of a single VirtualScanNode to test if a stream of
Reported by Cppcheck.
src/mongo/db/query/view_response_formatter_test.cpp
1 issues
Line: 46
static const NamespaceString testNss("db.col");
static const CursorId testCursor(1);
TEST(ViewResponseFormatter, FormatInitialCountResponseSuccessfully) {
CursorResponse cr(testNss, testCursor, {BSON("count" << 7)});
ViewResponseFormatter formatter(cr.toBSON(CursorResponse::ResponseType::InitialResponse));
BSONObjBuilder builder;
ASSERT_OK(formatter.appendAsCountResponse(&builder));
ASSERT_BSONOBJ_EQ(fromjson("{'n': 7, ok: 1}"), builder.obj());
Reported by Cppcheck.
src/mongo/db/range_arithmetic_test.cpp
1 issues
Line: 51
rangeOverlaps(BSON("x" << 100), BSON("x" << 200), BSON("x" << 80), BSON("x" << 100)));
}
TEST(BSONRange, BiggerUpperRangeNonSubset) {
ASSERT_TRUE(
rangeOverlaps(BSON("x" << 100), BSON("x" << 200), BSON("x" << 150), BSON("x" << 200)));
ASSERT_TRUE(
rangeOverlaps(BSON("x" << 100), BSON("x" << 200), BSON("x" << 160), BSON("x" << 201)));
ASSERT_TRUE(
Reported by Cppcheck.
src/mongo/db/read_write_concern_defaults_test.cpp
1 issues
Line: 71
OperationContext* const _opCtx{_opCtxHolder.get()};
};
TEST_F(ReadWriteConcernDefaultsTest, TestGetDefaultWithAbsentCWRWCWithImplicitWCW1) {
createDefaults(false /* isImplicitWCMajority */);
// By not calling _lookupMock.setLookupCallReturnValue(), tests _defaults.lookup() returning
// boost::none.
auto defaults = getDefault();
Reported by Cppcheck.
src/mongo/db/read_write_concern_provenance_test.cpp
1 issues
Line: 46
ASSERT_TRUE(provenance.isClientSupplied());
}
TEST(ReadWriteConcernProvenanceTest, ClientSupplied) {
ReadWriteConcernProvenance provenance(ReadWriteConcernProvenance::Source::clientSupplied);
ASSERT_TRUE(provenance.hasSource());
ASSERT_TRUE(provenance.isClientSupplied());
}
Reported by Cppcheck.
src/mongo/db/record_id_test.cpp
1 issues
Line: 50
ASSERT_EQUALS(hasher(locA), hasher(locB));
}
TEST(RecordId, HashEqualOid) {
RecordId locA(record_id_helpers::keyForOID(OID::gen()));
RecordId locB;
locB = locA;
ASSERT_EQUALS(locA, locB);
RecordId::Hasher hasher;
Reported by Cppcheck.
src/mongo/db/repl/abstract_async_component_test.cpp
1 issues
Line: 185
joinExecutorThread();
}
TEST_F(AbstractAsyncComponentTest, ConstructorThrowsUserAssertionOnNullTaskExecutor) {
ASSERT_THROWS_CODE_AND_WHAT(MockAsyncComponent(nullptr),
AssertionException,
ErrorCodes::BadValue,
"task executor cannot be null");
}
Reported by Cppcheck.
src/mongo/db/repl/all_database_cloner_test.cpp
1 issues
Line: 67
}
};
TEST_F(AllDatabaseClonerTest, RetriesConnect) {
// Bring the server down.
_mockServer->shutdown();
auto beforeRetryFailPoint = globalFailPointRegistry().find("hangBeforeRetryingClonerStage");
auto beforeRBIDFailPoint =
Reported by Cppcheck.
src/mongo/db/repl/apply_ops_test.cpp
1 issues
Line: 138
return getStatusFromCommandResult(newResult);
}
TEST_F(ApplyOpsTest, CommandInNestedApplyOpsReturnsSuccess) {
auto opCtx = cc().makeOperationContext();
auto mode = OplogApplication::Mode::kApplyOpsCmd;
BSONObjBuilder resultBuilder;
NamespaceString nss("test", "foo");
auto innerCmdObj =
Reported by Cppcheck.