The following issues were found

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

Line: 676

                  }
};

TEST_F(UnwindStageTest, AddsUnwoundPathToDependencies) {
    auto unwind =
        DocumentSourceUnwind::create(getExpCtx(), "x.y.z", false, boost::optional<string>("index"));
    DepsTracker dependencies;
    ASSERT_EQUALS(DepsTracker::State::SEE_NEXT, unwind->getDependencies(&dependencies));
    ASSERT_EQUALS(1U, dependencies.fields.size());

            

Reported by Cppcheck.

src/mongo/db/pipeline/expression_compare_test.cpp
1 issues
Shifting by a negative value is undefined behaviour
Error

Line: 306 CWE codes: 758

                      return BSON("$cmp" << BSON_ARRAY(1 << 2));
    }
    BSONObj expectedResult() {
        return BSON("" << -1);
    }
};

/** $cmp with first == second. */
class CmpEq : public ExpectedResultBase {

            

Reported by Cppcheck.

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

Line: 123

                  }
}

TEST_F(ExpressionContextTest, ParametersCanContainExpressionsWhichAreFolded) {
    auto opCtx = makeOperationContext();
    const auto expCtx = ExpressionContext{opCtx.get(),
                                          {},     // explain
                                          false,  // fromMongos
                                          false,  // needsMerge

            

Reported by Cppcheck.

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

Line: 60

              
using ExpressionConvertTest = AggregationContextFixture;

TEST_F(ExpressionConvertTest, ParseAndSerializeWithoutOptionalArguments) {
    auto expCtx = getExpCtx();

    auto spec = BSON("$convert" << BSON("input"
                                        << "$path1"
                                        << "to"

            

Reported by Cppcheck.

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

Line: 71

                  ASSERT_VALUE_EQ(dateExp->serialize(false), expectedSerialization);
}

TEST_F(ExpressionDateFromPartsTest, OptimizesToConstantIfAllInputsAreConstant) {
    auto expCtx = getExpCtx();
    auto spec = BSON("$dateFromParts" << BSON("year" << 2017));
    auto dateExp = Expression::parseExpression(expCtx.get(), spec, expCtx->variablesParseState);
    ASSERT(dynamic_cast<ExpressionConstant*>(dateExp->optimize().get()));


            

Reported by Cppcheck.

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

Line: 75

                  }
};

TEST(FieldPath, NoOptimizationForRootFieldPathWithDottedPath) {
    auto expCtx = ExpressionContextForTest{};
    intrusive_ptr<ExpressionFieldPath> expression =
        ExpressionFieldPath::parse(&expCtx, "$$ROOT.x.y", expCtx.variablesParseState);

    // An attempt to optimize returns the Expression itself.

            

Reported by Cppcheck.

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

Line: 99

                  }
};

TEST_F(ExpressionInternalFindPositionalTest, AppliesProjectionToPostImage) {
    defineAndSetProjectionPostImageVariable(getExpCtxRaw(),
                                            Value{fromjson("{bar: 1, foo: [1,2,6,10]}")});

    auto expr = createExpression(fromjson("{bar: 1, foo: {$gte: 5}}"), "foo");


            

Reported by Cppcheck.

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

Line: 87

                  ServiceContextMongoDTest::tearDown();
}

TEST_F(MapReduceFixture, ExpressionFunctionProducesExpectedResult) {
    auto bsonExpr = BSON("expr" << BSON("body"
                                        << "function(first, second) {return first + second;};"
                                        << "args" << BSON_ARRAY("$a" << 4) << "lang"
                                        << ExpressionFunction::kJavaScript));


            

Reported by Cppcheck.

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

Line: 209

                  intrusive_ptr<Testable> _associativeAndCommutative;
};

TEST_F(ExpressionNaryTest, AddedConstantOperandIsSerialized) {
    _notAssociativeNorCommutative->addOperand(ExpressionConstant::create(&expCtx, Value(9)));
    assertContents(_notAssociativeNorCommutative, BSON_ARRAY(9));
}

TEST_F(ExpressionNaryTest, AddedFieldPathOperandIsSerialized) {

            

Reported by Cppcheck.

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

Line: 63

              // Parsing.
//

TEST(ExpressionObjectParse, ShouldAcceptEmptyObject) {
    auto expCtx = ExpressionContextForTest{};
    VariablesParseState vps = expCtx.variablesParseState;
    auto object = ExpressionObject::parse(&expCtx, BSONObj(), vps);
    ASSERT_VALUE_EQ(Value(Document{}), object->serialize(false));
}

            

Reported by Cppcheck.