The following issues were found

src/mongo/db/pipeline/expression_replace_test.cpp
1 issues
syntax error
Error

Line: 71

                  return eval("$replaceAll", input, find, replacement);
}

TEST(ExpressionReplaceTest, Expects3NamedArgs) {
    ASSERT_THROWS(parse("$replaceOne", 1), AssertionException);
    ASSERT_THROWS(parse("$replaceOne", BSON_ARRAY(1 << 2)), AssertionException);
    ASSERT_THROWS(parse("$replaceOne", BSONNULL), AssertionException);
    ASSERT_THROWS(parse("$replaceOne", "string"_sd), AssertionException);
    parse("$replaceOne", Document{{"input", 1}, {"find", 1}, {"replacement", 1}});

            

Reported by Cppcheck.

src/mongo/db/pipeline/expression_test.cpp
1 issues
syntax error
Error

Line: 148

              
/* ------------------------- ExpressionArrayToObject -------------------------- */

TEST(ExpressionArrayToObjectTest, KVFormatSimple) {
    assertExpectedResults("$arrayToObject",
                          {{{Value(BSON_ARRAY(BSON("k"
                                                   << "key1"
                                                   << "v" << 2)
                                              << BSON("k"

            

Reported by Cppcheck.

src/mongo/db/pipeline/expression_test_api_version_test.cpp
1 issues
syntax error
Error

Line: 54

                                  expression->serialize(false));
}

TEST_F(TestApiVersion, UnstableDoesNotAcceptNumericValue) {
    auto expCtx = getExpCtx();

    ASSERT_THROWS_CODE(ExpressionTestApiVersion::parse(
                           expCtx.get(),
                           BSON("$_testApiVersion" << BSON("unstable" << 1)).firstElement(),

            

Reported by Cppcheck.

src/mongo/db/pipeline/expression_trigonometric_test.cpp
1 issues
syntax error
Error

Line: 88

               *
 */

TEST(ExpressionArcSineTest, IntArg) {
    assertEvaluates("$asin", Value(0), Value(0.0));
    assertEvaluates("$asin", Value(1), Value(1.57079632679));
}

TEST(ExpressionArcSineTest, LongArg) {

            

Reported by Cppcheck.

src/mongo/db/pipeline/expression_trim_test.cpp
1 issues
syntax error
Error

Line: 85

                                AssertionException);
}

TEST(ExpressionTrimParsingTest, ThrowsIfSpecDoesNotSpecifyInput) {
    auto expCtx = ExpressionContextForTest{};

    ASSERT_THROWS(Expression::parseExpression(
                      &expCtx, BSON("$trim" << BSONObj()), expCtx.variablesParseState),
                  AssertionException);

            

Reported by Cppcheck.

src/mongo/db/pipeline/expression_walker_test.cpp
1 issues
syntax error
Error

Line: 72

              using namespace std::string_literals;
using namespace expression_walker;

TEST_F(ExpressionWalkerTest, NothingTreeWalkSucceedsAndReturnsVoid) {
    struct {
        void postVisit(Expression*) {}
    } nothingWalker;
    auto expression = std::unique_ptr<Expression>{};
    static_assert(

            

Reported by Cppcheck.

src/mongo/db/pipeline/field_path_test.cpp
1 issues
syntax error
Error

Line: 44

              using std::vector;

/** FieldPath constructed from empty string. */
TEST(FieldPathTest, Empty) {
    ASSERT_THROWS(FieldPath(""), AssertionException);
}

/** FieldPath constructed from a simple string (without dots). */
TEST(FieldPathTest, Simple) {

            

Reported by Cppcheck.

src/mongo/db/pipeline/granularity_rounder_powers_of_two_test.cpp
1 issues
syntax error
Error

Line: 54

                  }
}

TEST(GranularityRounderPowersOfTwoTest, ShouldRoundUpPowersOfTwoToNextPowerOfTwo) {
    auto rounder =
        GranularityRounder::getGranularityRounder(new ExpressionContextForTest(), "POWERSOF2");

    testEquals(rounder->roundUp(Value(0.5)), Value(1));
    testEquals(rounder->roundUp(Value(1)), Value(2));

            

Reported by Cppcheck.

src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp
1 issues
syntax error
Error

Line: 420

                  }
}

TEST(GranularityRounderPreferredNumbersTest, ShouldRoundUpNumberInSeriesToNextNumberInSeries) {
    for (auto&& series : preferredNumberSeries) {
        auto rounder =
            GranularityRounder::getGranularityRounder(new ExpressionContextForTest(), series);

        testRoundingUpInSeries(rounder);

            

Reported by Cppcheck.

src/mongo/db/pipeline/lookup_set_cache_test.cpp
1 issues
syntax error
Error

Line: 60

              
const ValueComparator defaultComparator{nullptr};

TEST(LookupSetCacheTest, InsertAndRetrieveWorksCorrectly) {
    LookupSetCache cache(defaultComparator);
    cache.insert(Value(0), intToDoc(1));
    cache.insert(Value(0), intToDoc(2));
    cache.insert(Value(0), intToDoc(3));
    cache.insert(Value(1), intToDoc(4));

            

Reported by Cppcheck.