The following issues were found

src/mongo/db/curop_test.cpp
1 issues
syntax error
Error

Line: 59

                  ASSERT_EQ(a.prepareReadConflicts.load(), b.prepareReadConflicts.load());
}

TEST(CurOpTest, AddingAdditiveMetricsObjectsTogetherShouldAddFieldsTogether) {
    OpDebug::AdditiveMetrics currentAdditiveMetrics = OpDebug::AdditiveMetrics();
    OpDebug::AdditiveMetrics additiveMetricsToAdd = OpDebug::AdditiveMetrics();

    // Initialize field values for both AdditiveMetrics objects.
    currentAdditiveMetrics.keysExamined = 0;

            

Reported by Cppcheck.

src/mongo/db/db_raii_test.cpp
1 issues
syntax error
Error

Line: 111

                  }
}

TEST_F(DBRAIITestFixture, AutoGetCollectionForReadCollLockDeadline) {
    Lock::DBLock dbLock1(client1.second.get(), nss.db(), MODE_IX);
    ASSERT(client1.second->lockState()->isDbLockedForMode(nss.db(), MODE_IX));
    Lock::CollectionLock collLock1(client1.second.get(), nss, MODE_X);
    ASSERT(client1.second->lockState()->isCollectionLockedForMode(nss, MODE_X));
    failsWithLockTimeout(

            

Reported by Cppcheck.

src/mongo/db/dbmessage_test.cpp
1 issues
syntax error
Error

Line: 40

              using std::string;

// Test if the reserved field is short of 4 bytes
TEST(DBMessage1, ShortFlags) {
    BufBuilder b;
    string ns("test");

    b.appendChar(1);


            

Reported by Cppcheck.

src/mongo/db/error_labels_test.cpp
1 issues
syntax error
Error

Line: 49

                      ErrorCodes::WriteConflict, false /* hasWriteConcernError */, false /* isCommitOrAbort */));
}

TEST(IsTransientTransactionErrorTest, LockTimeoutIsTransient) {
    ASSERT_TRUE(isTransientTransactionError(
        ErrorCodes::LockTimeout, false /* hasWriteConcernError */, false /* isCommitOrAbort */));
}

TEST(IsTransientTransactionErrorTest, PreparedTransactionInProgressIsTransient) {

            

Reported by Cppcheck.

src/mongo/db/exec/add_fields_projection_executor_test.cpp
1 issues
syntax error
Error

Line: 54

              // creation, so we include an abbreviation of the same tests here.

// Verify that AddFieldsProjectionExecutor rejects specifications with conflicting field paths.
TEST(AddFieldsProjectionExecutorSpec, ThrowsOnCreationWithConflictingFieldPaths) {
    boost::intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
    // These specs contain the same exact path.
    ASSERT_THROWS(AddFieldsProjectionExecutor::create(expCtx, BSON("a" << 1 << "a" << 2)),
                  AssertionException);
    ASSERT_THROWS(

            

Reported by Cppcheck.

src/mongo/db/exec/bucket_unpacker_test.cpp
1 issues
syntax error
Error

Line: 82

                  }
};

TEST_F(BucketUnpackerTest, UnpackBasicIncludeAllMeasurementFields) {
    std::set<std::string> fields{
        "_id", kUserDefinedMetaName.toString(), kUserDefinedTimeName.toString(), "a", "b"};

    auto bucket = fromjson(
        "{meta: {'m1': 999, 'm2': 9999}, data: {_id: {'0':1, '1':2}, time: {'0':1, '1':2}, "

            

Reported by Cppcheck.

src/mongo/db/exec/document_value/document_comparator_test.cpp
1 issues
syntax error
Error

Line: 51

                  ASSERT_FALSE(DocumentComparator().evaluate(doc1 == doc3));
}

TEST(DocumentComparatorTest, EqualToEvaluatesCorrectlyWithNonSimpleCollator) {
    CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kAlwaysEqual);
    const Document doc1{{"foo", "abc"_sd}};
    const Document doc2{{"foo", "def"_sd}};
    ASSERT_TRUE(DocumentComparator(&collator).evaluate(doc1 == doc2));
}

            

Reported by Cppcheck.

src/mongo/db/exec/document_value/document_internal.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 100 Column: 11 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                  Position nextCollision;  // Position of next field with same hashBucket
    const int nameLen;       // doesn't include '\0'
    Kind kind;               // See the possible kinds above for comments
    const char _name[1];     // pointer to start of name (use nameSD instead)

    ValueElement* next() {
        return align(plusBytes(sizeof(ValueElement) + nameLen));
    }


            

Reported by FlawFinder.

src/mongo/db/exec/document_value/document_metadata_fields_test.cpp
1 issues
syntax error
Error

Line: 74

                                         << "foo"));
}

TEST(DocumentMetadataFieldsTest, HasMethodsReturnFalseForEmptyMetadata) {
    DocumentMetadataFields metadata;
    ASSERT_FALSE(metadata);
    ASSERT_FALSE(metadata.hasTextScore());
    ASSERT_FALSE(metadata.hasRandVal());
    ASSERT_FALSE(metadata.hasSortKey());

            

Reported by Cppcheck.

src/mongo/db/exec/document_value/document_value_test.cpp
1 issues
syntax error
Error

Line: 82

                  ASSERT_DOCUMENT_EQ(document1, document2);
}

TEST(DocumentConstruction, Default) {
    Document document;
    ASSERT_EQUALS(0ULL, document.computeSize());
    assertRoundTrips(document);
}


            

Reported by Cppcheck.