The following issues were found
src/mongo/db/logical_time_validator_test.cpp
1 issues
Line: 91
std::shared_ptr<KeysCollectionManager> _keyManager;
};
TEST_F(LogicalTimeValidatorTest, GetTimeWithIncreasingTimes) {
validator()->enableKeyGenerator(operationContext(), true);
LogicalTime t1(Timestamp(10, 0));
auto newTime = validator()->trySignLogicalTime(t1);
Reported by Cppcheck.
src/mongo/db/matcher/doc_validation_error.cpp
1 issues
Line: 1055
// If 'oneOf' has more than one matching subschema, then the generated error should
// be in terms of the subschemas which matched, not the ones which failed to match.
std::vector<int> matchingClauses;
for (size_t childIndex = 0; childIndex < expr->numChildren(); ++childIndex) {
auto child = expr->getChild(childIndex);
if (child->matchesBSON(currentDoc)) {
matchingClauses.push_back(childIndex);
}
}
Reported by Cppcheck.
src/mongo/db/matcher/doc_validation_error_json_schema_test.cpp
1 issues
Line: 59
}
// properties
TEST(JSONSchemaValidation, BasicProperties) {
BSONObj query = fromjson("{'$jsonSchema': {'properties': {'a': {'minimum': 1}}}}}");
BSONObj document = fromjson("{a: 0}");
BSONObj expectedError = fromjson(
"{'operatorName': '$jsonSchema',"
" 'schemaRulesNotSatisfied': ["
Reported by Cppcheck.
src/mongo/db/matcher/doc_validation_error_test.cpp
1 issues
Line: 147
// Comparison operators.
// $eq
TEST(ComparisonMatchExpression, BasicEq) {
BSONObj query = BSON("a" << BSON("$eq" << 2));
BSONObj document = BSON("a" << 1);
BSONObj expectedError = BSON("operatorName"
<< "$eq"
<< "specifiedAs" << query << "reason"
Reported by Cppcheck.
src/mongo/db/matcher/expression_algo_test.cpp
1 issues
Line: 72
boost::intrusive_ptr<ExpressionContext> _expCtx;
};
TEST(ExpressionAlgoIsSubsetOf, NullAndOmittedField) {
// Verify that the ComparisonMatchExpression constructor prohibits creating a match expression
// with an Undefined type.
BSONObj undefined = fromjson("{a: undefined}");
boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
ASSERT_EQUALS(ErrorCodes::BadValue,
Reported by Cppcheck.
src/mongo/db/matcher/expression_always_boolean_test.cpp
1 issues
Line: 48
ASSERT_FALSE(falseExpr.matchesBSON(BSONObj()));
}
TEST(AlwaysFalseMatchExpression, EquivalentReturnsCorrectResults) {
auto falseExpr = std::make_unique<AlwaysFalseMatchExpression>();
ASSERT_TRUE(falseExpr->equivalent(falseExpr.get()));
ASSERT_TRUE(falseExpr->equivalent(falseExpr->shallowClone().get()));
AlwaysTrueMatchExpression trueExpr;
Reported by Cppcheck.
src/mongo/db/matcher/expression_array_test.cpp
1 issues
Line: 53
ASSERT(!op.matchesSingleElement(notMatch["a"]));
}
TEST(ElemMatchObjectMatchExpression, MatchesElementArray) {
auto baseOperand = BSON("1" << 5);
auto match = BSON("a" << BSON_ARRAY(BSON_ARRAY('s' << 5.0)));
auto notMatch = BSON("a" << BSON_ARRAY(BSON_ARRAY(5 << 6)));
auto eq = std::make_unique<EqualityMatchExpression>("1", baseOperand["1"]);
auto op = ElemMatchObjectMatchExpression{"a", std::move(eq)};
Reported by Cppcheck.
src/mongo/db/matcher/expression_expr_test.cpp
1 issues
Line: 89
std::unique_ptr<MatchExpression> _matchExpression;
};
TEST_F(ExprMatchTest, ComparisonToConstantMatchesCorrectly) {
createMatcher(BSON("$expr" << BSON("$eq" << BSON_ARRAY("$a" << 5))));
ASSERT_TRUE(matches(BSON("a" << 5)));
ASSERT_FALSE(matches(BSON("a" << 4)));
Reported by Cppcheck.
src/mongo/db/matcher/expression_geo_test.cpp
1 issues
Line: 58
ASSERT(ge.matchesBSON(fromjson("{a: {x: 5, y:5.1}}")));
}
TEST(ExpressionGeoTest, GeoNear1) {
BSONObj query = fromjson(
"{loc:{$near:{$maxDistance:100, "
"$geometry:{type:\"Point\", coordinates:[0,0]}}}}");
std::unique_ptr<GeoNearExpression> nq(new GeoNearExpression);
ASSERT_OK(nq->parseFrom(query["loc"].Obj()));
Reported by Cppcheck.
src/mongo/db/matcher/expression_internal_bucket_geo_within_test.cpp
1 issues
Line: 118
boost::intrusive_ptr<ExpressionContextForTest> _expCtx = new ExpressionContextForTest();
};
TEST_F(InternalBucketGeoWithinExpression, BoxPolygonOverlap) {
auto expr = getDummyBucketGeoExpr();
auto obj = createBucketObj(BSON("loc" << BSON("type"
<< "Point"
<< "coordinates" << BSON_ARRAY(0 << 0)))
Reported by Cppcheck.