Repository Analysis

Automattic/mongoose

MongoDB object modeling designed to work in an asynchronous environment.

1.4 Likely human-written View on GitHub
1.4
Adjusted Score
1.4
Raw Score
100%
Time Factor
2026-05-30
Last Push
27,482
Stars
JavaScript
Language
213,151
Lines of Code
632
Files
130
Pattern Hits
2026-05-31
Scan Date

Score History

Severity Breakdown

CRITICAL 15HIGH 0MEDIUM 0LOW 115

Pattern Findings

130 matches across 6 categories. Click a row to expand file-level details.

Hallucination Indicators15 hits · 175 pts
SeverityFileLineSnippet
CRITICALtest/model.discriminator.test.js2120 assert.equal(Triangle.schema.s.hooks._pres.get('save').filter(hook => hook.fn.name === 'testHook12472').length, 2);
CRITICALtest/model.discriminator.test.js2121 assert.equal(Square.schema.s.hooks._pres.get('save').filter(hook => hook.fn.name === 'testHook12472').length, 1);
CRITICALtest/model.discriminator.test.js2151 assert.equal(Triangle.schema.s.hooks._pres.get('save').filter(hook => hook.fn.name === 'testHook12604').length, 2);
CRITICALtest/model.discriminator.test.js2152 assert.equal(Square.schema.s.hooks._pres.get('save').filter(hook => hook.fn.name === 'testHook12604').length, 1);
CRITICALtest/model.populate.test.js11734 assert.deepStrictEqual(obj.rubric.parameters.param1.evaluationPrompts.map(prompt => prompt.name), ['Test Prompt', 'T
CRITICALtest/model.populate.test.js11735 assert.deepStrictEqual(obj.rubric.parameters.param2.evaluationPrompts.map(prompt => prompt.name), ['Test Prompt 3'])
CRITICALtest/document.test.js6560 mongoose.Schema.Types.Boolean.convertToTrue.add('aye');
CRITICALtest/document.test.js6561 mongoose.Schema.Types.Boolean.convertToFalse.add('nay');
CRITICALtest/document.test.js6573 mongoose.Schema.Types.Boolean.convertToTrue.delete('aye');
CRITICALtest/document.test.js6574 mongoose.Schema.Types.Boolean.convertToFalse.delete('nay');
CRITICALtest/document.test.js6582 mongoose.Schema.Types.Boolean.convertToFalse.add(null);
CRITICALtest/docs/transactions.test.js25 !db.client.topology.s.description.type.includes('ReplicaSet')) {
CRITICALdocs/schematypes.md464mongoose.Schema.Types.Boolean.convertToFalse.add('nay');
CRITICALlib/schema/boolean.js177 * mongoose.Schema.Types.Boolean.convertToTrue.add('affirmative');
CRITICALlib/schema/boolean.js199 * mongoose.Schema.Types.Boolean.convertToFalse.add('nay');
Hyper-Verbose Identifiers71 hits · 72 pts
SeverityFileLineSnippet
LOWtypes/index.d.ts1154 export function overwriteMiddlewareResult(val: any): Kareem.OverwriteMiddlewareResult;
LOWtypes/index.d.ts1158 export function overwriteMiddlewareArguments(val: any): Kareem.OverwriteArguments;
LOWtest/document.populate.test.js846 beforeEach(function setupVirtualPopulateModels() {
LOWtest/document.populate.test.js900 beforeEach(function setupEmbeddedGetterPopulateModels() {
LOWtest/model.middleware.test.js388 it('static hooks async stack traces (gh-15317) (gh-5982)', async function staticHookAsyncStackTrace() {
LOWtest/model.discriminator.querying.test.js155 async function checkHydratesCorrectModels(fields) {
LOWtest/model.discriminator.querying.test.js399 async function checkHydratesCorrectModels(fields, checkUndefinedRevenue) {
LOWtest/model.test.js10027function generateRandomCollectionName() {
LOWtest/model.updateOne.test.js3273 function getPaymentWithDotSeparatedPaths() {
LOWtest/document.test.js15393 it('works with save() validation errors', async function asyncSaveValidationErrors() {
LOWtest/document.test.js15561 it('works with async pre deleteOne errors on subdocuments', async function asyncSubdocPreDeleteOneErrors() {
LOWtest/document.test.js15659 it('works with aggregate server errors', async function asyncAggregateServerErrors() {
LOWtest/encryptedSchema.test.js17function schemaHasEncryptedProperty(schema, path) {
LOWtest/model.insertMany.test.js834 it('async stack traces with server error (gh-15317)', async function insertManyWithServerError() {
LOWtest/types/schema.test.ts1998function testInferRawDocTypeFromSchema() {
LOWtest/types/schema.test.ts2020function testInferHydratedDocTypeFromSchema() {
LOWtest/types/schema.test.ts2111function testNewSchemaWithMethodsAndVirtuals() {
LOWtest/types/schema.test.ts2372function allowNullFalseInferredTypes() {
LOWtest/types/document.test.ts200function autoTypedDocumentConnection() {
LOWtest/types/document.test.ts709 function autoInferredWithCustomVersionKey() {
LOWtest/types/document.test.ts799function testCombinedFlattenOptions() {
LOWtest/types/models.test.ts334async function overwriteBulkWriteContents() {
LOWtest/types/models.test.ts441function schemaInstanceMethodsAndQueryHelpers() {
LOWtest/types/models.test.ts1065async function customModelInstanceWithStatics() {
LOWtest/types/base.test.ts113function baseConnectionAndCollection() {
LOWtest/types/create.test.ts133async function createWithAggregateErrors() {
LOWtest/types/connection.test.ts115function schemaInstanceMethodsAndQueryHelpersOnConnection() {
LOWtest/types/schema.create.test.ts1890function testInferRawDocTypeFromSchema() {
LOWtest/types/schema.create.test.ts1914async function testInferHydratedDocTypeFromSchema() {
LOWtest/types/schema.create.test.ts2039function allowNullFalseInferredTypes() {
LOWdocs/js/sidebar-collapse.js4 function scrollActiveSidebarLinkIntoView() {
LOWlib/query.js3402function prepareDiscriminatorCriteria(query) {
LOWlib/query.js3987function convertNewToReturnDocument(options) {
LOWlib/queryHelpers.js26exports.preparePopulationOptionsMQ = function preparePopulationOptionsMQ(query, options) {
LOWlib/connection.js1678Connection.prototype.authMechanismDoesNotRequirePassword = function authMechanismDoesNotRequirePassword() {
LOWlib/connection.js1696Connection.prototype.optionsProvideAuthenticationData = function optionsProvideAuthenticationData(options) {
LOWlib/document.js4437function applySchemaTypeTransforms(self, json) {
LOWlib/plugins/sharding.js32function shardingPluginPreDeleteOne() {
LOWlib/plugins/sharding.js36function shardingPluginPreUpdateOne() {
LOWlib/schema/array.js634function createLogicalQueryOperatorHandler(op) {
LOWlib/schema/array.js635 return function logicalQueryOperatorHandler(val, context) {
LOWlib/schema/string.js735function formatMaxLengthValidatorMessage(msg) {
LOWlib/schema/documentArrayElement.js27function SchemaDocumentArrayElement(path, schema, options, parentSchema) {
LOWlib/helpers/getDefaultBulkwriteResult.js3function getDefaultBulkwriteResult() {
LOWlib/helpers/update/applyTimestampsToChildren.js12function applyTimestampsToChildren(now, update, schema) {
LOWlib/helpers/update/applyTimestampsToChildren.js82function applyTimestampsToDocumentArray(arr, schematype, now) {
LOWlib/helpers/update/applyTimestampsToChildren.js108function applyTimestampsToSingleNested(subdoc, schematype, now) {
LOWlib/helpers/update/applyTimestampsToChildren.js127function applyTimestampsToUpdateKey(schema, key, update, now) {
LOWlib/helpers/update/decorateUpdateWithVersionKey.js8module.exports = function decorateUpdateWithVersionKey(update, options, versionKey) {
LOWlib/helpers/update/updatedPathsByArrayFilter.js5module.exports = function updatedPathsByArrayFilter(update) {
LOWlib/helpers/cursor/eachAsync.js219function createEachAsyncMultiError(aggregatedErrors) {
LOWlib/helpers/aggregate/prepareDiscriminatorPipeline.js3module.exports = function prepareDiscriminatorPipeline(pipeline, schema, prefix) {
LOWlib/helpers/aggregate/stringifyFunctionOperators.js3module.exports = function stringifyFunctionOperators(pipeline) {
LOWlib/helpers/populate/removeDeselectedForeignField.js11module.exports = function removeDeselectedForeignField(foreignFields, options, docs) {
LOWlib/helpers/populate/markArraySubdocsPopulated.js19module.exports = function markArraySubdocsPopulated(doc, populated) {
LOWlib/helpers/populate/assignRawDocsToIdStructure.js34function assignRawDocsToIdStructure(rawIds, resultDocs, resultOrder, options, recursed) {
LOWlib/helpers/populate/createPopulateQueryFilter.js8module.exports = function createPopulateQueryFilter(ids, _match, _foreignField, model, skipInvalidIds) {
LOWlib/helpers/document/applyTimestamps.js38function applyTimestampsToChildren(schema, res, options) {
LOWlib/helpers/document/getEmbeddedDiscriminatorPath.js16module.exports = function getEmbeddedDiscriminatorPath(doc, path, options) {
LOWlib/helpers/document/getDeepestSubdocumentForPath.js14module.exports = function getDeepestSubdocumentForPath(doc, parts, schema) {
11 more matches not shown…
Fake / Example Data32 hits · 34 pts
SeverityFileLineSnippet
LOWtest/document.populate.test.js939 const createdTeam = await Team.create({ captain: 'John Doe', players: [{ player: 'John Doe' }, { player: 'Foo Bar'
LOWtest/model.discriminator.test.js396 employee.name.full = 'John Doe';
LOWtest/model.discriminator.test.js397 assert.equal(employee.name.full, 'John Doe');
LOWtest/model.test.js7653 userToUpdate.name = 'John Doe';
LOWtest/model.test.js7675 userToUpdate.name = 'John Doe';
LOWtest/model.test.js7697 userToUpdate.name = 'John Doe';
LOWtest/model.test.js8321 userToUpdate.name = 'John Doe';
LOWtest/model.test.js8348 userToUpdate.name = 'John Doe';
LOWtest/model.test.js8370 userToUpdate.name = 'John Doe';
LOWtest/model.populate.test.js6557 await User.create({ id: 111, name: 'John Doe' });
LOWtest/model.populate.test.js6576 assert.equal(doc.outer.inner.flexible[0].users_$[0].name, 'John Doe');
LOWtest/model.populate.test.js8429 const user = await User.create({ fullName: 'John Doe', companyId: company._id });
LOWtest/model.populate.test.js8483 const user = await User.create({ fullName: 'John Doe', company: 'GitHub' });
LOWtest/model.populate.test.js11115 email: 'admin@example.com',
LOWtest/model.populate.test.js11343 await Author.create({ group: 'AUTH1', name: 'John Doe' });
LOWtest/document.test.js817 const post = await Post.create({ owner: savedUser._id, content: 'lorem ipsum' });
LOWtest/document.test.js1122 company: { companyName: 'Acme Inc' }
LOWtest/document.test.js3136 username: 'John Doe',
LOWtest/document.test.js3141 username: 'John Doe',
LOWtest/document.test.js5601 title: 'Lorem Ipsum Dolor',
LOWtest/document.test.js5709 title: 'Lorem Ipsum Dolor',
LOWtest/document.test.js10102 email: 'foo@bar.com',
LOWtest/document.test.js12900 addresses: [{ street: '123 Main St', city: 'Boston', image: { url: 'google.com' } }],
LOWtest/document.test.js13107 phones: [{ number: '555-1234' }]
LOWtest/document.test.js14707 email: 'test@test.com'
LOWtest/types/queries.test.ts414 const update: UpdateQuery<IUser> = { $addToSet: { friendsNames: 'John Doe' } };
LOWtest/types/queries.test.ts418 update.$addToSet.friendsNames = 'Jane Doe';
LOWtest/types/schema.test.ts1488 schema.statics.createWithFullName('John Doe');
LOWtest/types/models.test.ts1056 const data = { name: 'John Doe', age: 30, address: '123 Main St' };
LOWtest/types/models.test.ts1056 const data = { name: 'John Doe', age: 30, address: '123 Main St' };
LOWtest/types/schema.create.test.ts1429 schema.statics.createWithFullName('John Doe');
LOWlib/schema/string.js136 * new User({ name: ' John Doe ' }).name; // 'John Doe'
Verbosity Indicators4 hits · 6 pts
SeverityFileLineSnippet
LOWlib/query.js125 // this is the case where we have a CustomQuery, we need to check if we got
LOWlib/schema.js2904 // Now that we found the array, we need to check if there
LOWlib/schema.js3006 // Now that we found the array, we need to check if there
LOWlib/helpers/populate/getSchemaTypes.js83 // Now that we found the array, we need to check if there
Over-Commented Block5 hits · 5 pts
SeverityFileLineSnippet
LOWindex.js61// The following properties are not exported using ESM because `setDriver()` can mutate these
LOWtypes/index.d.ts1/// <reference path="./aggregate.d.ts" />
LOWtest/docs/promises.test.js141 // acquit:ignore:end
LOWtest/docs/lean.test.js41 // To enable the `lean` option for a query, use the `lean()` function.
LOWdocs/promises.md81 await Band.findOne({ _id: badId });
Slop Phrases3 hits · 4 pts
SeverityFileLineSnippet
LOWtest/encryptedSchema.test.js250 // Don't forget to add `Int8` to the type registry
LOWtest/encryptedSchema.test.js280 // Don't forget to add `Int8` to the type registry
LOWtest/docs/schematypes.test.js54 // Don't forget to add `Int8` to the type registry