The following issues were found

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

Line: 95

                  std::unique_ptr<PartitionIterator> _iter;
};

TEST_F(WindowFunctionExecNonRemovableTest, AccumulateOnlyWithoutLookahead) {
    const auto docs = std::deque<DocumentSource::GetNextResult>{
        Document{{"a", 1}}, Document{{"a", 2}}, Document{{"a", 3}}};
    auto mgr = createForFieldPath<AccumulatorSum>(std::move(docs), "$a", 0);
    ASSERT_VALUE_EQ(Value(1), mgr.getNext());
    advanceIterator();

            

Reported by Cppcheck.

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

Line: 102

                  std::unique_ptr<PartitionIterator> _iter;
};

TEST_F(WindowFunctionExecRemovableDocumentTest, AccumulateCurrentToInteger) {
    const auto docs = std::deque<DocumentSource::GetNextResult>{
        Document{{"a", 3}}, Document{{"a", 2}}, Document{{"a", 1}}};
    {
        auto mgr = createForFieldPath(docs, "$a", WindowBounds::DocumentBased{0, 2});
        ASSERT_VALUE_EQ(Value(3), mgr.getNext());

            

Reported by Cppcheck.

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

Line: 58

                  WindowFunctionIntegral integral;
};

TEST_F(WindowFunctionIntegralTest, EmptyWindowShouldReturnNULL) {
    ASSERT_VALUE_EQ(integral.getValue(), Value(BSONNULL));
}

TEST_F(WindowFunctionIntegralTest, SingleValueShouldReturnZero) {
    const std::vector<Value> singlePoint = {

            

Reported by Cppcheck.

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

Line: 55

                  WindowFunctionMax max;
};

TEST_F(WindowFunctionMinMaxTest, EmptyWindow) {
    ASSERT_VALUE_EQ(min.getValue(), Value{BSONNULL});

    ASSERT_VALUE_EQ(max.getValue(), Value{BSONNULL});
}


            

Reported by Cppcheck.

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

Line: 53

                  WindowFunctionPush push;
};

TEST_F(WindowFunctionPushTest, EmptyWindowReturnsDefault) {
    ASSERT_VALUE_EQ(push.getValue(), Value{std::vector<Value>()});

    push.add(Value{1});
    push.remove(Value{1});
    ASSERT_VALUE_EQ(push.getValue(), Value{std::vector<Value>()});

            

Reported by Cppcheck.

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

Line: 59

                  }
};

TEST_F(WindowFunctionStdDevTest, EmptyWindow) {
    ASSERT_VALUE_EQ(pop.getValue(), Value{BSONNULL});
}

TEST_F(WindowFunctionStdDevTest, SingletonWindow) {
    pop.add(Value{1});

            

Reported by Cppcheck.

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

Line: 48

                  WindowFunctionSum sum;
};

TEST_F(WindowFunctionSumTest, EmptyWindow) {
    ASSERT_VALUE_EQ(sum.getValue(), Value{0});
}

TEST_F(WindowFunctionSumTest, IgnoresNonnumeric) {
    sum.add(Value{"not a number"_sd});

            

Reported by Cppcheck.

src/mongo/db/profile_filter_impl.cpp
1 issues
Syntax Error: AST broken, 'if' doesn't have two operands.
Error

Line: 85

                                        ())
(InitializerContext*) {
    try {
        if (auto expr = serverGlobalParams.defaultProfileFilter) {
            ProfileFilter::setDefault(std::make_shared<ProfileFilterImpl>(*expr));
        }
    } catch (AssertionException& e) {
        // Add more context to the error
        uasserted(ErrorCodes::FailedToParse,

            

Reported by Cppcheck.

src/mongo/db/query/canonical_query_encoder_test.cpp
1 issues
syntax error
Error

Line: 111

                  testComputeKey(fromjson(queryStr), fromjson(sortStr), fromjson(projStr), expectedStr);
}

TEST(CanonicalQueryEncoderTest, ComputeKey) {
    // Generated cache keys should be treated as opaque to the user.

    // No sorts
    testComputeKey("{}", "{}", "{}", "an");
    testComputeKey("{$or: [{a: 1}, {b: 2}]}", "{}", "{}", "or[eqa,eqb]");

            

Reported by Cppcheck.

src/mongo/db/query/canonical_query_test.cpp
1 issues
syntax error
Error

Line: 95

                  FAIL(ss);
}

TEST(CanonicalQueryTest, IsValidSortKeyMetaProjection) {
    QueryTestServiceContext serviceContext;
    auto opCtx = serviceContext.makeOperationContext();

    // Passing a sortKey meta-projection without a sort is an error.
    {

            

Reported by Cppcheck.