The following issues were found

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

Line: 45

              const TimeZoneDatabase kDefaultTimeZoneDatabase{};
const TimeZone kDefaultTimeZone = TimeZoneDatabase::utcZone();

TEST(GetTimeZone, DoesReturnKnownTimeZone) {
    // Just asserting that these do not throw exceptions.
    kDefaultTimeZoneDatabase.getTimeZone("UTC");
    kDefaultTimeZoneDatabase.getTimeZone("America/New_York");
    kDefaultTimeZoneDatabase.getTimeZone("Australia/Sydney");
}

            

Reported by Cppcheck.

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

Line: 173

              }

// Use of index filters to select compound index over single key index.
TEST(GetExecutorTest, GetAllowedIndices) {
    testAllowedIndices(
        {buildSimpleIndexEntry(fromjson("{a: 1}"), "a_1"),
         buildSimpleIndexEntry(fromjson("{a: 1, b: 1}"), "a_1_b_1"),
         buildSimpleIndexEntry(fromjson("{a: 1, c: 1}"), "a_1_c_1")},
        SimpleBSONObjComparator::kInstance.makeBSONObjSet({fromjson("{a: 1, b: 1}")}),

            

Reported by Cppcheck.

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

Line: 60

                  return request;
}

TEST(GetMoreRequestTest, toBSONMissingOptionalFields) {
    GetMoreCommandRequest request = createGetMoreCommandRequest("testcoll", 123);
    BSONObj requestObj = request.toBSON({});
    BSONObj expectedRequest = BSON("getMore" << CursorId(123) << "collection"
                                             << "testcoll");
    ASSERT_BSONOBJ_EQ(requestObj, expectedRequest);

            

Reported by Cppcheck.

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

Line: 47

                  ASSERT_BSONOBJ_EQ(parseHint(hint.firstElement()), BSON("x" << 5));
}

TEST(CommandParsers, ParseIndexNameHint) {
    auto hint = BSON("hint"
                     << "x_1");
    ASSERT_BSONOBJ_EQ(parseHint(hint.firstElement()),
                      BSON("$hint"
                           << "x_1"));

            

Reported by Cppcheck.

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

Line: 61

                  ASSERT_EQUALS(tightness, IndexBoundsBuilder::EXACT);
}

TEST_F(IndexBoundsBuilderTest, TranslateEqualityToStringWithMockCollator) {
    CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
    auto testIndex = buildSimpleIndexEntry();
    testIndex.collator = &collator;

    BSONObj obj = BSON("a"

            

Reported by Cppcheck.

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

Line: 51

                                oil.intervals[1].compare(Interval(fromjson("{'': null, '': null}"), true, true)));
}

TEST_F(IndexBoundsBuilderTest, TranslateExprEqualToNullIsInexactFetch) {
    BSONObj keyPattern = BSON("a" << 1);
    BSONElement elt = keyPattern.firstElement();
    auto testIndex = buildSimpleIndexEntry(keyPattern);
    BSONObj obj = BSON("a" << BSON("$_internalExprEq" << BSONNULL));
    auto expr = parseMatchExpression(obj);

            

Reported by Cppcheck.

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

Line: 48

                  return IndexBoundsBuilder::isSingleInterval(bounds, &startKey, &startKeyIn, &endKey, &endKeyIn);
}

TEST(IndexBoundsBuilderTest, SingleFieldEqualityInterval) {
    // Equality on a single field is a single interval.
    OrderedIntervalList oil("a");
    IndexBounds bounds;
    oil.intervals.push_back(Interval(BSON("" << 5 << "" << 5), true, true));
    bounds.fields.push_back(oil);

            

Reported by Cppcheck.

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

Line: 47

                  ASSERT_EQUALS(tightness, IndexBoundsBuilder::EXACT);
}

TEST_F(IndexBoundsBuilderTest, RootedString) {
    auto testIndex = buildSimpleIndexEntry();
    IndexBoundsBuilder::BoundsTightness tightness;
    std::string prefix = IndexBoundsBuilder::simpleRegex("\\Afoo", "", testIndex, &tightness);
    ASSERT_EQUALS(prefix, "foo");
    ASSERT_EQUALS(tightness, IndexBoundsBuilder::EXACT);

            

Reported by Cppcheck.

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

Line: 61

              // Example: {a: {$elemMatch: {$gt: 2}}}
//

TEST_F(IndexBoundsBuilderTest, TranslateElemMatchValue) {
    auto testIndex = buildSimpleIndexEntry();
    // Bounds generated should be the same as the embedded expression
    // except for the tightness.
    BSONObj obj = fromjson("{a: {$elemMatch: {$gt: 2}}}");
    auto expr = parseMatchExpression(obj);

            

Reported by Cppcheck.

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

Line: 65

              }

// Test $type bounds for Code BSON type.
TEST_F(IndexBoundsBuilderTest, CodeTypeBounds) {
    auto testIndex = buildSimpleIndexEntry();
    BSONObj obj = fromjson("{a: {$type: 13}}");
    auto expr = parseMatchExpression(obj);
    BSONElement elt = obj.firstElement();


            

Reported by Cppcheck.