The following issues were found

src/mongo/db/cst/cst_error_test.cpp
1 issues
syntax error
Error

Line: 56

                                              "within array at index 0 of input pipeline");
}

TEST(CstErrorTest, UnknownStageName) {
    // First stage.
    {
        auto input = fromjson("{pipeline: [{$unknownStage: {}}]}");
        BSONLexer lexer(input["pipeline"].embeddedObject(), ParserGen::token::START_PIPELINE);
        ASSERT_THROWS_CODE_AND_WHAT(ParserGen(lexer, nullptr).parse(),

            

Reported by Cppcheck.

src/mongo/db/cst/cst_expression_test.cpp
1 issues
syntax error
Error

Line: 65

                      "<KeyFieldname andExpr>: [ \"<UserInt 2>\", \"<UserInt -3>\" ] } } }");
}

TEST(CstExpressionTest, ParsesProjectWithOr) {
    CNode output;
    auto input = fromjson(
        "{pipeline: [{$project: {_id: 9.10, a: {$or: [4, {$or: [7, 8]}]}, b: {$or: [2, -3]}}}]}");
    BSONLexer lexer(input["pipeline"].embeddedObject(), ParserGen::token::START_PIPELINE);
    auto parseTree = ParserGen(lexer, &output);

            

Reported by Cppcheck.

src/mongo/db/cst/cst_find_project_test.cpp
1 issues
syntax error
Error

Line: 54

                  ASSERT_EQ(output.toBson().toString(), "{ <KeyFieldname projectInclusion>: {} }");
}

TEST(CstProjectTest, ParsesBasicProjection) {
    {
        CNode output;
        auto input = fromjson(
            "{project: {a: 1.0, b: {c: NumberInt(1), d: NumberDecimal('1.0') }, _id: "
            "NumberLong(1)}}");

            

Reported by Cppcheck.

src/mongo/db/cst/cst_literals_test.cpp
1 issues
syntax error
Error

Line: 67

                            CNode{CNode::ObjectChildren{{KeyFieldname::literal, std::move(literal)}}}}}}}}}}};
}

TEST(CstLiteralsTest, TranslatesDouble) {
    auto cst = makePipelineContainingProjectStageWithLiteral(CNode{UserDouble{5e-324}});
    // DocumenSourceSingleDoucmentTransformation reorders fields so we need to be insensitive.
    ASSERT(UnorderedFieldsBSONObjComparator{}.evaluate(
        BSON("_id" << true << "a" << BSON("$const" << 5e-324)) ==
        dynamic_cast<DocumentSourceSingleDocumentTransformation&>(

            

Reported by Cppcheck.

src/mongo/db/cst/cst_match_test.cpp
1 issues
syntax error
Error

Line: 56

                  ASSERT_EQ(output.toBson().toString(), "{}");
}

TEST(CstMatchTest, ParsesEqualityPredicates) {
    CNode output;
    auto input = fromjson("{filter: {a: 5.0, b: NumberInt(10), _id: NumberLong(15)}}");
    BSONLexer lexer(input["filter"].embeddedObject(), ParserGen::token::START_MATCH);
    auto parseTree = ParserGen(lexer, &output);
    ASSERT_EQ(0, parseTree.parse());

            

Reported by Cppcheck.

src/mongo/db/cst/cst_match_translation_test.cpp
1 issues
syntax error
Error

Line: 69

                  return output;
}

TEST(CstMatchTranslationTest, TranslatesEmpty) {
    const auto cst = CNode{CNode::ObjectChildren{}};
    auto match = translate(cst);
    auto andExpr = dynamic_cast<AndMatchExpression*>(match.get());
    ASSERT(andExpr);
    ASSERT_EQ(0, andExpr->numChildren());

            

Reported by Cppcheck.

src/mongo/db/cst/cst_pipeline_translation_test.cpp
1 issues
syntax error
Error

Line: 65

                  return boost::intrusive_ptr<ExpressionContextForTest>{new ExpressionContextForTest(nss)};
}

TEST(CstPipelineTranslationTest, TranslatesEmpty) {
    const auto cst = CNode{CNode::ArrayChildren{}};
    auto pipeline = cst_pipeline_translation::translatePipeline(cst, getExpCtx());
    auto& sources = pipeline->getSources();
    ASSERT_EQ(0u, sources.size());
}

            

Reported by Cppcheck.

src/mongo/db/cst/cst_set_operator_translation_test.cpp
1 issues
syntax error
Error

Line: 54

                  return ExpressionContextForTest(nss);
}

TEST(CstPipelineTranslationTest, AllElementsTrueTest) {
    const auto cst = CNode{CNode::ObjectChildren{
        {KeyFieldname::allElementsTrue,
         CNode{CNode::ArrayChildren{CNode{AggregationPath{makeVector<std::string>("set"s)}}}}}}};
    auto expCtx = getExpCtx();
    auto expr =

            

Reported by Cppcheck.

src/mongo/db/cst/cst_sort_translation_test.cpp
1 issues
syntax error
Error

Line: 79

                  }
}

TEST(CstSortTranslationTest, BasicSortGeneratesCorrectSortPattern) {
    const auto cst = CNode{CNode::ObjectChildren{
        {SortPath{makeVector<std::string>("val")}, CNode{KeyValue::intOneKey}}}};
    auto expCtx = getExpCtx();
    auto pattern = cst_sort_translation::translateSortSpec(cst, expCtx);
    auto correctPattern = SortPattern(fromjson("{val: 1}"), expCtx);

            

Reported by Cppcheck.

src/mongo/db/cst/cst_test.cpp
1 issues
syntax error
Error

Line: 69

                  }
}

TEST(CstGrammarTest, EmptyPipeline) {
    CNode output;
    auto input = fromjson("{pipeline: []}");
    BSONLexer lexer(input["pipeline"].embeddedObject(), ParserGen::token::START_PIPELINE);
    auto parseTree = ParserGen(lexer, &output);
    ASSERT_EQ(0, parseTree.parse());

            

Reported by Cppcheck.