Public report of Automattic/mongoose, published 24 October 2026. It has the same score, grades and number of
findings as the full report. The details of security findings (where they are in the code, which known
vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive reportMeasured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.10.5). Watchdog signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey →
Signed and filed in the standard's public register, 24 October 2026, 16:39 UTC · Survey ID cd_ca7d814e049d4f8a9322bfe8b3fafbd1
Automattic/mongoose
Measured 24 October 2026, 16:32 UTC, at code version f59e13a
A regression is a drop of 0.5 points or more in the score, or of 2.5 or more out of 10 in a dimension, since the last survey.
Code coverage is not measured: JavaScript/TypeScript suite (CouldNotMeasureTestRunFailed).
Dependency hygiene is not measured: Npm pinning read, dependency currency not (no committed lockfile, so no resolved version to grade).
CAI scoreWeak
CriticalWeakAdequateStrongExemplary
Up 3 since the last survey
The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.
A medium codebase: 52,719 lines of product code in 1 project, tests not counted · Estimated rebuild effort: about 1.0 person-years · Weakest lens: Security and Compliance, 46
Findings by how serious they are
20 critical705 serious104 minor
6 dimensions are left out of the score. For each one, Watchdog either couldn't measure it in this code, or found no evidence of the safeguard it looks for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.
This survey was produced by
Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
24 October 2026, 16:32 UTC
A measurement, not a certificate. The Code Assurance Index records a number
together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee
the code. The standard was written by Canine Development, which also builds Watchdog. It is open to any tool that
implements it, and today Watchdog is the only one that does.
The score is deterministic, which means the same code always gets the same score. Watchdog works it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸
73of 77 dimensions measured by tools. The other 4 are advisory notes from an AI model, which explain the code but don't count towards the score.
808of 829 findings point to an exact file and line, so you can open each one in the code. The other 21 concern the repository as a whole, such as missing documentation.
77dimensions across 7 lenses, read from 52,719 lines of product code in 1 project.
Automattic/mongoose scores 49 out of 100 and is rated Weak, while four of its seven lenses score higher still: Performance at 91, rated Exemplary, and Production Readiness at 66, Architecture at 59 and Maturity at 58, all rated Adequate.
The score is lower than those four because the weakest lens counts most, and here that is Security and Compliance, which scores 46 and is rated Weak. Its Access Controls dimension scores 0 out of 10, and until that reaches 4, Security and Compliance can't be rated higher than Adequate. The first actions are to protect endpoints by default-deny: a global authentication guard or middleware with explicit public opt-outs, or a guard on every route, plus named role/permission rules for what an authenticated caller may do and to bring the 370 bodies over 15 down to 15 or less in Cognitive Complexity. The weakest lenses score close to each other, so improving any of them moves the score.
20 findings are critical: 12 in Static Analysis (SAST), three in Page structure, two in Circular Imports, two in Test Quality and one in Text alternatives.
Watchdog couldn't measure 5 dimensions in this code, among them Test Reliability, License Compliance and Navigability, so they are left out of the score. The product code is 52,719 lines, which would take an estimated 1.0 person-years, around €140,000, to rebuild.
A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.
How the score is built: what each lens counts forThe lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
Incompleteness & stubs · Guard cannot change the result — returns what the code already falls through to lib/schema/bigint.js
Visual & motion safety · Focus outline removed in CSS without a :focus replacement docs/css/mongoose9.css
Visual & motion safety · Focus outline removed in CSS without a :focus replacement docs/css/mongoose9.css
Visual & motion safety · Animation without a prefers-reduced-motion guard docs/css/copy-code.css
Visual & motion safety · Animation without a prefers-reduced-motion guard docs/css/mongoose9.css
Visual & motion safety · Animation without a prefers-reduced-motion guard docs/css/mongoose9.css
Visual & motion safety · Animation without a prefers-reduced-motion guard docs/css/mongoose9.css
Visual & motion safety · Animation without a prefers-reduced-motion guard docs/css/style.css
Visual & motion safety · Animation without a prefers-reduced-motion guard docs/css/style.css
Watchdog compares every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.
Fixed since the last survey: 121 findings
These 121 critical or serious findings were in the previous survey, on 10 October 2026, and are gone from this one. The first 100 are listed here.
€48,000 to €240,000, for 794 to 2,520 hours of work, about 1.0 person-years for 1 to 2 engineers
Difficulty of the problem
Standard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor
×0.7 at a score of 49. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
Size
Medium: 52,719 lines of product code
How the estimate is made: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Protect endpoints by default-deny: a global authentication guard or middleware with explicit public opt-outs, or a guard on every route, plus named role/permission rules for what an authenticated caller may do.
Raises the score by about 3 points · Medium effort · Access Controls
2
Bring the 370 bodies over 15 down to 15 or less in Cognitive Complexity — start with cast (cognitive 305), cast.cast (cognitive 296), $set (cognitive 274).
Migrate the remaining .js/.jsx files to TypeScript.
Raises the score by about 2 points · Medium effort · Type Safety
Diagnosis: what the measurements show together
Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.
Where the investment is most exposed · Value at risk
This code would cost about €140,000 to build again, about 1.0 person-years of work. Its weakest lens is Security and Compliance, at 46 (Weak). Security and Compliance is about how well the product is protected, and how it handles personal data. Because the weakest lens counts most in the score, work on Security and Compliance also moves the score most.
Based on: the rebuild estimate · the Security and Compliance grade · how much each lens counts
What to do: Start with the Security and Compliance actions in Top priorities.
If you do one thing first · First action
Protect endpoints by default-deny: a global authentication guard or middleware with explicit public opt-outs, or a guard on every route, plus named role/permission rules for what an authenticated caller may do. Of all the actions in this report, it raises the score most for the work it takes: about 3 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 4.7 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 8% to 19% on every change. The history of the code shows how much it changes: about 14,351 lines over the last 90 days, which is about 58,201 lines a year. At that pace, the extra work comes to an estimated 12.1 to 72.8 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of Watchdog's own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.
Architecture: which parts of the code depend on which
The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.
84 modules, with 33 dependencies between them. Every module uses only modules listed above it, so there are no loops.
The table shows the 40 modules with the most connections; 44 more are left out to keep it readable.
Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
lib.error.browserMissingSchema uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.browserMissingSchema, while a change to lib.error.browserMissingSchema can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.browserMissingSchema uses a module listed above it, which is the healthy direction.
lib.error.bulkSaveIncompleteError uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.bulkSaveIncompleteError, while a change to lib.error.bulkSaveIncompleteError can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.bulkSaveIncompleteError uses a module listed above it, which is the healthy direction.
lib.error.bulkWriteError uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.bulkWriteError, while a change to lib.error.bulkWriteError can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.bulkWriteError uses a module listed above it, which is the healthy direction.
lib.error.cast uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.cast, while a change to lib.error.cast can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.cast uses a module listed above it, which is the healthy direction.
lib.error.createCollectionsError uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.createCollectionsError, while a change to lib.error.createCollectionsError can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.createCollectionsError uses a module listed above it, which is the healthy direction.
lib.error.divergentArray uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.divergentArray, while a change to lib.error.divergentArray can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.divergentArray uses a module listed above it, which is the healthy direction.
lib.error.eachAsyncMultiError uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.eachAsyncMultiError, while a change to lib.error.eachAsyncMultiError can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.eachAsyncMultiError uses a module listed above it, which is the healthy direction.
lib.error.invalidSchemaOption uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.invalidSchemaOption, while a change to lib.error.invalidSchemaOption can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.invalidSchemaOption uses a module listed above it, which is the healthy direction.
lib.error.missingSchema uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.missingSchema, while a change to lib.error.missingSchema can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.missingSchema uses a module listed above it, which is the healthy direction.
lib.error.notFound uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.notFound, while a change to lib.error.notFound can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.notFound uses a module listed above it, which is the healthy direction.
lib.error.objectExpected uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.objectExpected, while a change to lib.error.objectExpected can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.objectExpected uses a module listed above it, which is the healthy direction.
lib.error.objectParameter uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.objectParameter, while a change to lib.error.objectParameter can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.objectParameter uses a module listed above it, which is the healthy direction.
lib.error.overwriteModel uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.overwriteModel, while a change to lib.error.overwriteModel can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.overwriteModel uses a module listed above it, which is the healthy direction.
lib.error.parallelSave uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.parallelSave, while a change to lib.error.parallelSave can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.parallelSave uses a module listed above it, which is the healthy direction.
lib.error.parallelValidate uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.parallelValidate, while a change to lib.error.parallelValidate can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.parallelValidate uses a module listed above it, which is the healthy direction.
lib.error.serverSelection uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.serverSelection, while a change to lib.error.serverSelection can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.serverSelection uses a module listed above it, which is the healthy direction.
lib.error.setOptionError uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.setOptionError, while a change to lib.error.setOptionError can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.setOptionError uses a module listed above it, which is the healthy direction.
lib.error.strict uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.strict, while a change to lib.error.strict can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.strict uses a module listed above it, which is the healthy direction.
lib.error.strictPopulate uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.strictPopulate, while a change to lib.error.strictPopulate can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.strictPopulate uses a module listed above it, which is the healthy direction.
lib.error.syncIndexes uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.syncIndexes, while a change to lib.error.syncIndexes can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.syncIndexes uses a module listed above it, which is the healthy direction.
lib.error.validation uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.validation, while a change to lib.error.validation can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.validation uses a module listed above it, which is the healthy direction.
lib.error.validator uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.validator, while a change to lib.error.validator can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.validator uses a module listed above it, which is the healthy direction.
lib.error.version uses lib.error.mongooseError, so a change to lib.error.mongooseError can break lib.error.version, while a change to lib.error.version can't break lib.error.mongooseError.
Position
Below the diagonal: lib.error.version uses a module listed above it, which is the healthy direction.
lib.options.schemaArrayOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaArrayOptions, while a change to lib.options.schemaArrayOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaArrayOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaBufferOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaBufferOptions, while a change to lib.options.schemaBufferOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaBufferOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaDateOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaDateOptions, while a change to lib.options.schemaDateOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaDateOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaDocumentArrayOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaDocumentArrayOptions, while a change to lib.options.schemaDocumentArrayOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaDocumentArrayOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaMapOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaMapOptions, while a change to lib.options.schemaMapOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaMapOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaNumberOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaNumberOptions, while a change to lib.options.schemaNumberOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaNumberOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaObjectIdOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaObjectIdOptions, while a change to lib.options.schemaObjectIdOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaObjectIdOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaStringOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaStringOptions, while a change to lib.options.schemaStringOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaStringOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaSubdocumentOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaSubdocumentOptions, while a change to lib.options.schemaSubdocumentOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaSubdocumentOptions uses a module listed above it, which is the healthy direction.
lib.options.schemaUnionOptions uses lib.options.schemaTypeOptions, so a change to lib.options.schemaTypeOptions can break lib.options.schemaUnionOptions, while a change to lib.options.schemaUnionOptions can't break lib.options.schemaTypeOptions.
Position
Below the diagonal: lib.options.schemaUnionOptions uses a module listed above it, which is the healthy direction.
At a glance — Code Health · 46% · Weak · gated by D1, D2, R1 ·
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A05:2025 — Injection
14
High / Critical
A03:2025 — Software Supply Chain Failures
8
Medium
A08:2025 — Software or Data Integrity Failures
1
Medium
Roadmap
First, secure the application by implementing a global authentication guard with explicit public opt-outs and named role permissions. Next, reduce cognitive complexity by refactoring the most complex functions to improve maintainability, and migrate all remaining JavaScript files to TypeScript to ensure type safety. Finally, enhance accessibility by enforcing visible focus styles, respecting reduced motion preferences, and improving color contrast, while threading AbortSignals through async requests to ensure proper cancellation.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Protect endpoints by default-deny: a global authentication guard or middleware with explicit public opt-outs, or a guard on every route, plus named role/permission rules for what an authenticated caller may do.
Bring the 370 bodies over 15 down to 15 or less in Cognitive Complexity — start with cast (cognitive 305), cast.cast (cognitive 296), $set (cognitive 274).
Keep a visible focus style (don't remove the outline without a replacement), guard animation with prefers-reduced-motion, and raise low-contrast colour pairs to at least 4.5:1.
Every finding carries one of four grades. Three say how serious it is. The fourth says this
survey could not settle it — and it is a grade, not a gap.
Critical — 20
A definite problem that already costs you something and drags the score down: a
missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here
tends to cause failures elsewhere.
Serious — 705
Likely wrong, but not failing yet. It degrades
the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to
carry for two years either.
Minor — 104
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 6
Something this survey could not settle
from the outside, and which could be critical or serious. Either a control was required and no
positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves
nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean
result. These are excluded from the score rather than awarded a pass, so the number on the cover neither
rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each
one is named under Limitations.
Methodology & how to trust this report
Watchdog is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. 73 of 77 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 4 documentation/naming judgement(s) are LLM-assisted and labelled advisory. Overall confidence is 0.8 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.
Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.
What we checked — 77 dimensions across the health lenses
Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.
How to trust any code-health report — three questions
Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 808 of 829 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D11 Test Reliability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test reliability NOT MEASURED: the JavaScript/TypeScript suite could not be re-run in the analyzer sandbox — the mocha run in the repository root produced no per-test report (Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:). This is OUR limitation, not a defect in the repo — it is excluded from the score.
D11 Test Reliability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test reliability for the mocha suite in the repository root was NOT MEASURED: the mocha run in the repository root produced no per-test report (Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:). This is OUR limitation, not a defect in the repository, and the suite is excluded from the measurement rather than counted against it.
D12 Dependency Hygiene — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. This repository's 2 package.json manifest(s) WERE read and their pinning discipline assessed; what went unanswered is the currency half, because answering it needs a lockfile resolved to CONCRETE versions and this repository commits none — a package.json states version RANGES, and a range names no particular release to be behind. So registry.npmjs.org was never asked, and there was nothing here for it to grade. This is a true statement about the repository and NOT a gap on our side: no lockfile reader we could write would find anything here to read, so there is no capability behind this row to build.
D14 License Compliance — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Not scored — this repository declares package.json manifests but commits no lockfile this pass can resolve (npm, pnpm, yarn and bun each write a different one, and `bun.lockb` is a binary format with no published shape), so the set of packages it actually ships is not resolvable from the checkout: its declarations carry version RANGES, and grading whichever release happens to be newest today would be a verdict about a dependency graph this repository has not pinned. Commit the lock and this dimension grades its production dependencies against registry.npmjs.org. NOT a finding that this repository's licences are compliant: this dimension asserts nothing about its licensing in either direction.
D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
D30 Dependency Vulnerabilities — measured, with a gap in what it reached — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. The scanner produced no output at all, so no dependency was actually scanned. 1 of 2 declared ecosystem(s) (npm) WERE scanned and every vulnerability they reported is included in this result; REDACTED was not, so this dimension's score covers less than the dependency surface this repository declares, and nothing here is evidence that REDACTED is free of known-vulnerable dependencies.
D32 Data Compliance (PII/GDPR) — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `types/index.d.ts`, `types/inferhydrateddoctype.d.ts`, `types/models.d.ts`, `types/populate.d.ts`, `types/query.d.ts` produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
D43 Malicious Dependencies — measured, with a gap in what it reached — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. The scanner produced no output at all, so no dependency was actually scanned. 1 of 2 declared ecosystem(s) (npm) WERE scanned and every vulnerability they reported is included in this result; REDACTED was not, so this dimension's score covers less than the dependency surface this repository declares, and nothing here is evidence that REDACTED is free of known-vulnerable dependencies.
AXB1 Runtime evidence locked — no reproducible boot — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Subject: 1 markup document(s) — HTML, Razor, JSX, Vue, Svelte or server templates. The Runtime Evidence tier boots an app only via docker-compose, an Aspire AppHost, a Dockerfile, an npm dev script, a web service's own toolchain entry point (cargo, go, dotnet, Python, Spring Boot), or an Android app's own Gradle wrapper (run on an emulator); an Apple or Flutter app needs a host it lacks. None applied, so no live runtime a11y/egress/header evidence was collected. You can widen what we reach: add a docker-compose.yml (or an Aspire AppHost) that brings the app up with its dependencies. Watchdog then boots it in an isolated sandbox and gathers real runtime evidence — you change nothing in your pipeline (no CI step, no SDK).
P5 DR & Backup — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. No backup/snapshot/replication config, RTO/RPO or restore-procedure documentation was found — and none applies: this repository publishes a library and deploys nothing (no container, IaC or deployment manifest), so it holds no runtime state of its own. Any data-access dependency it declares is the store it is a CLIENT for, not one it operates. The DR control belongs to whoever runs that data.
R10 Code Duplication — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 95 further occurrence(s) are not listed individually; the score already reflects all 135.
R7 Dead Code — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 536 further occurrence(s) are not listed individually; the score already reflects all 576.
X4 Structured logging — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java, Kotlin, Python, PHP, Dart, Ruby, Scala and Rust source only, and no C# was loaded, and this repository's JavaScript/TypeScript, Python and PHP make no call through a named logger, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.
Limitations & what we did not check
Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.
Per-dimension blind spots
For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.
D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D19 Documentation Quality: Documentation quality is judged by an LLM over a bounded sample of docs — it reads what is written, not whether the docs match the running system, and it is advisory, not a measurement. Its critique rows are drawn from a closed category vocabulary and each row means the same thing in every run, so two scans can be compared row by row; the SET that fires is still a sample, and does not repeat exactly. Measured on one frozen input, six scans at one engine SHA: 2-5 critique rows per scan, 8 distinct rows across the six, 3 of those 8 seen in only one scan. So a D19 row is evidence about the documentation, but a COUNT of D19 rows is not a quantity — never read a change in it as an improvement or a regression.
D21 Naming Consistency: Naming quality is an LLM judgement over a bounded sample — it assesses clarity/consistency of the names it sees, not domain-correctness, and is advisory.
D22 Internal API Consistency: API-surface coherence is an LLM judgement over a sample of the public surface — consistency of intent across the whole API is approximated, not exhaustively verified.
D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a Dockerfile (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
AC1 Text alternatives: Alt-text is detected structurally — the scan sees that an alternative EXISTS, not whether it meaningfully describes the image, and decorative-vs-missing is judged by attribute shape; runtime-injected images and a non-role=img decorative svg are out of scope. This is accessibility readiness, never a WCAG conformance claim.
AC2 Forms & labels: Label association is read from static markup — a label wired up at runtime (JS-set aria-labelledby, framework-injected ids) reads as missing, a present label says nothing about whether its text is correct. A known UI-library field component (e.g. a JSX <TextField>) is now checked conservatively — flagged only when it carries NO label/aria-label/aria-labelledby/id/name — but wrapper/context-labelled libraries (Chakra/Radix FormControl+FormLabel) aren't statically visible (possible false positive) and non-JSX lowercased components are still skipped. A click handler on a plain element is now asked for a name too (it is a control the author declared), but the subtree test that answers it is deliberately generous: any DYNAMIC text expression in the subtree counts as a name, so an icon chosen by a ternary ({cond ? <IconA/> : <IconB/>}) reads as named, and a glyph component from a library the icon-import list does not know still names its parent. A clean result is "no unlabelled control found", not a labelling proof.
AC3 Page structure: Page structure is read from the static markup tree — landmarks, headings and lang injected at runtime aren't seen, heading ORDER is checked structurally (not against the rendered visual hierarchy), and lang/title/main fire only on full documents, never partials, and the data-table check sees header-cell presence (a <th> exists), not whether each header correctly associates with its cells. Static readiness, not conformance.
AC5 ARIA correctness: ARIA correctness is checked against the static role/attribute shape — roles/attributes set dynamically aren't seen, a valid role says nothing about whether it matches the element's real behaviour, and required-state checks are suppressed when a JSX spread could supply them. The two-branch toggle check (a control whose state is conveyed only by which of two mutually exclusive branches renders) reads CONDITIONALS THAT ARE ATTRIBUTES — Vue v-if/v-else/v-show and Alpine x-if/x-show — so the same toggle written as a Svelte {#if} block or a JSX ternary is control flow the markup model never projects as a branch and is not seen at all.
AC6 Visual & motion safety: Contrast and motion safety are PARTIAL by construction — literal colours (hex/rgb/hsl/named) in inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS top-level declarations are read (same-rule/same-element colour+background pairs only); computed/runtime/theme colour, external-CDN stylesheets, CSS-in-JS dynamic (${…}) and nested-selector colours, cross-element pairs and image contrast stay out of reach, so a clean result is bounded by what the static CSS itself shows.
AC7 A11y enforcement: Enforcement is scored from in-repo config/CI evidence only — an a11y gate enforced in external tooling with no in-repo trace can't be credited, and a configured linter is presence, not proof the rules actually run or block a merge.
AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
The LLM boundary
LLM-set scores this run (4): D19, D21, D22, M4 (model: Local LLM). For these, a model reads a bounded sample and sets the numeric score; each names its own sample and method on its card. They are sampled and advisory by design: they vary at the margins between runs and are never a deterministic measurement. Every other score in this report is tool-computed at confidence 1.0.
What it measures: How tangled the control flow is — methods with many branches are hard to test and change.
Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.
253 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was document.Document.$set at 177. A further 2 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being collection.iter at 34 — they are counted neither in the figure above nor in this dimension's score.
+ 129 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 16 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with document.Document.$set (cyclomatic 177), $set (cyclomatic 177), cast.cast (cyclomatic 103). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 16 together lifts Cyclomatic Complexity from 2.0 to about 3.2/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How hard the code is for a person to follow, beyond raw branching.
Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.
+ 195 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 370 bodies over 15 down to 15 or less in Cognitive Complexity — start with cast (cognitive 305), cast.cast (cognitive 296), $set (cognitive 274). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 370 together lifts Cognitive Complexity from 2.0 to about 10.0/10, projected with the scoring formula itself and assuming each lands exactly at 15.
Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes8.5 / 10Strong✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
Resolve the 14 FunctionTooLong finding(s) in God Classes — start with document.js (4), model.js (3), castUpdate.js. — One of this dimension's main actionable groups (14 warning-level).
Resolve the 7 FileTooLong finding(s) in God Classes — start with document.js, model.js, query.js. — One of this dimension's main actionable groups (7 warning-level).
Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.
Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.
4575 test methods: 4575 unit, 0 integration, 0 BDD, 0 e2e. The JavaScript/TypeScript suite contributes 4575 `it`/`test` case(s) across 157 test file(s) declaring at least one; its tier split is read from package names and paths only.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality9.5 / 10Adequategated by 2 critical findings✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
38 skipped (36 with a documented reason), 140 zero-assertion, 21 synchronised by a fixed sleep, no mocking-framework packages referenced (hand-written doubles or no mocking) across 4575 tests.
No assertions (empty test): 2dsphere indexed field with geojson without value is saved (gh-3233) · ×2test/model.test.js:3596
No assertions: works with numbericAlpha paths · ×138test/versioning.test.js:158
Resolve the 2 No assertions (empty test) finding(s) in Test Quality — start with model.test.js (2). — One of this dimension's main actionable groups (2 issue-level).
Resolve the 138 No assertions finding(s) in Test Quality — start with document.test.js (29), model.updateOne.test.js (24), connection.test.js (14). — One of this dimension's main actionable groups (138 warning-level).
Resolve the 21 Fixed-sleep synchronisation finding(s) in Test Quality — start with timestamps.test.js (6), model.test.js (6), model.updateOne.test.js (3). — One of this dimension's main actionable groups (21 warning-level).
Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
Top hotspots: lib/document.js (33×85=2805); lib/model.js (20×61=1220); lib/queryHelpers.js (4×88=352) Repeated repair below the complexity floor: lib/helpers/model/castBulkWrite.js (4 of 5 changes were fixes); lib/schema/documentArrayElement.js (3 of 4 changes were fixes)
Resolve the 14 Hotspot finding(s) in Churn × Complexity Hotspots — start with document.js, model.js, queryHelpers.js. — One of this dimension's main actionable groups (14 warning-level).
Resolve the 2 Repeated repair finding(s) in Churn × Complexity Hotspots — start with castBulkWrite.js, documentArrayElement.js. — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor9.1 / 10Exemplary✓ Tool-verified
What it measures: Whether knowledge is concentrated in too few people (the "bus factor").
Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.
8 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is lib/helpers/document/applyDefaults.js. Counted over 91 of the 285 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Off-boarding risk: anonymized user #1
Further sole-owners (lower concentration)
✓ On the Gold path — maintain.
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.
Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.
0 deducted task-comment markers across 92 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic doc sample (READMEs plus first 25 architecture docs), with two-pass stability filtering. Advisory, sampled.
The repository's root README and the accompanying architecture/Docs markdown files form an excellent documentation set. The README covers what Mongoose does (MongoDB object modeling for Node.js/Deno), links to build/test status, npm version badges, a full roadmap of support channels, plugins, contributors, and a clear overview of the project with installation, usage, and contribution guidance. The architecture/Docs files are comprehensive: advanced schemas, async/await, Atlas search/vector search, change streams, browser support, version compatibility, and dozens of other topics, each clearly numbered in an outline that is itself clipped by the scanner (so no section is flagged as missing). This repository is a deep Mongoose schema and model reference guide with an overwhelming abundance of documentation (12 READMEs plus 63 architecture/design docs). The main document is the defaults.md tutorial on default values and default functions, which is well written but sits below the threshold for overview quality. It is clear and complete within its scope; the remaining documents are excellent references. The repository's documentation is strong and well-organized. The README (docs/index.md) gives a clear getting-started walkthrough with installation, a code example showing how to connect to MongoDB and create a kitten model, and links to the core guide topics such as Schema, Model, Populate, Validation, and more. It also documents incompatible packages in an incompatibility guide. A separate architecture/Docs set of 63 markdown files (Guides, Incompatible Packages, Migration Guides) provides comprehensive coverage for advanced concepts, design decisions, and migration content.
Documentation: no architecture or design documentation · ×3README.md
✓ On the Gold path — maintain.
Detailed fixes: d19_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether names — types, methods, variables — are clear and consistent.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic random symbol sample (fixed size, not exhaustive), with disclosed confidence band. Advisory, sampled.
0 naming inconsistencies across 0 sampled symbols.
✓ On the Gold path — maintain.
Detailed fixes: d21_recommendation.md.
Do you agree with this assessment?
D22 · Internal API ConsistencyStrong◐ Sampled · advisory
What it measures: Whether the internal API surface is consistent and coherent.
Method: Judged by language model at low temperature over a sample of the public API surface (IsPackable or .Contracts types). Sampled, advisory; confidence discounted by model uncertainty.
Redundant validation methods with overlapping intent. Both methods appear to validate whether a value is a valid MongoDB ObjectId or a valid hex string representation of one. Having two distinct public methods for the same logical check creates confusion for consumers.
What to do
Resolve the 1 Redundant validation methods with overlapping intent. Both methods… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d22_recommendation.md · top locations in Appendix A, every location in findings.md.
1 of 1 build units (npm) flagged as possibly oversized/incoherent.
Projects may be oversized for their cohesion
What to do
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
14 finding(s): 0 critical, 12 high, 2 medium, 0 low. 8 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 7 file(s) — `lib/document.js`, `lib/model.js`, `types/index.d.ts` (line 872, lines 1180–1182, lines 1192–1196), `types/inferhydrateddoctype.d.ts` (line 111), `types/models.d.ts` (line 206, line 454, line 505, …), … (+2 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 1 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
+ 1 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).
Resolve the 1 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
No action in Static Analysis (SAST) — all 8 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (8 issue-level, 0 of them charged here).
Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.
Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over REDACTED.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05.
No known-vulnerable dependencies in the 1 ecosystem(s) that were scanned (npm). Partial dependency scan: 1 of 2 declared ecosystem(s) were scanned (npm), and the findings above are real and complete for them. REDACTED was not scanned (REDACTED: the scanner produced no output at all, so no dependency was actually scanned), so this is not the whole dependency surface and the result is reported at reduced confidence.
REDACTED
✓ On the Gold path — maintain.
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.
Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.
Every significant source file has living knowledge — recently and meaningfully worked. Counted over 91 of the 285 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Resolve the 1 Change coupling finding(s) in Change Coupling — start with getIndexes.js. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.
Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the repository publishes a coordinated-vulnerability-disclosure policy (SECURITY.md or security.txt) with a reporting contact, so finders know how to report a vulnerability. Presence of a policy file with a contact, not whether the policy is adequate or honoured.
Method: Vulnerability-disclosure policy read deterministically from the repo: a SECURITY.md (root/.github/docs) or .well-known/security.txt / security.txt, regex-checked for a reporting contact (email / URL / mailto). Present + contact → 10; present without a contact → 4; NotApplicable when no policy file exists (it may live off-repo). Detects the policy file's presence + contact, not its adequacy.
What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Scored apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.
Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. SCORED, not informational.
No known-vulnerable dependencies in the 1 ecosystem(s) that were scanned (npm). Partial dependency scan: 1 of 2 declared ecosystem(s) were scanned (npm), and the findings above are real and complete for them. REDACTED was not scanned (REDACTED: the scanner produced no output at all, so no dependency was actually scanned), so this is not the whole dependency surface and the result is reported at reduced confidence.
REDACTED
✓ On the Gold path — maintain.
Detailed fixes: d43_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.
Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.
0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 0 platform declaration(s) and 7 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.
✓ On the Gold path — maintain.
Detailed fixes: d44_recommendation.md.
Do you agree with this assessment?
Frontend & cross-cutting dimensions
R = React/JS · M = Maturity · P = Readiness.
AC1 · Text alternatives4.3 / 10Weak✓ Tool-verified
Other · Accessibility — Whether non-text content carries a text alternative — img/area/input[type=image] have alt, a meaningful svg has a title or aria-label, video has a captions track, and object/embed/canvas have a name or fallback content. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: every img/area/input[type=image] checked for alt, svg[role=img] for a title/aria-label, video for a captions <track>. Components skipped, spreads suppressed. Deterministic, hard fact per element.
Coverage: Population: image/media elements — img, area, input[type=image], svg, video, object, embed, canvas — across the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and dynamic-attribute elements are skipped. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is NOT read by any producer, so it contributes no element to this population; where such a frontend is present the card discloses it as an analyzer gap rather than scoring around it.
An image with no alt (and no aria-label/aria-labelledby) is unreadable to assistive tech. Add alt — alt="" if it's purely decorative. — docs/sponsors.pug:11
What to do
Add a text alternative — alt on images (alt="" for purely decorative ones), a title or aria-label on meaningful svg, an aria-label or inner fallback content on canvas, and a captions <track> on video.
Do you agree with this assessment?
AC2 · Forms & labels10.0 / 10Exemplary○ Nothing flagged
Other · Accessibility — Whether form controls have a programmatic label (an associated label, aria-label or aria-labelledby), buttons have text, links have an accessible name, a click handler on a plain element names the control it declares, fieldsets have a non-empty legend, known UI-library field components carry a label prop, and a placeholder isn't used as the only label. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: inputs/selects/textareas checked for an associated label[for]/wrapping label/aria-label/aria-labelledby (per document), buttons for accessible text, fieldsets for a legend; placeholder-only labelling flagged. Deterministic, hard fact per control.
Coverage: Population: form controls, buttons, links, fieldsets and known UI-library field components in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and spread/dynamic-attribute elements are skipped, so a control whose label arrives through a spread or a runtime expression is deliberately not judged. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
Do you agree with this assessment?
AC3 · Page structure4.5 / 10Weak✓ Tool-verified
Other · Accessibility — Whether pages declare a language (well-formed BCP-47) and a non-empty title, expose exactly one main landmark and a sane heading order with non-empty headings, keep zoom enabled, title their iframes, give data tables header cells, and avoid meta-refresh. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: html lang, document <title>, a main landmark and heading order on full documents only, plus zoom-disabling viewports, untitled iframes and meta-refresh anywhere. Deterministic, per structural checkpoint.
Coverage: Population: the PARSED MARKUP documents (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx). The page-level checks — lang, title, single main landmark — fire ONCE PER FULL DOCUMENT (an <html> root) and never on a partial or component fragment, so a repo of fragments is assessed only on the per-element checks (heading order, table headers, iframe titles, meta-refresh, zoom). Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
Skipping heading levels breaks the document outline assistive tech relies on. Don't jump levels — increase by at most one. (×3) — docs/api_split.pug:42, docs/api_split.pug:48, docs/sponsors.pug:13
No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>. — index.pug:2
user-scalable=no/0 or a maximum-scale below 2 stops low-vision users zooming to 200%. Remove the zoom restriction from the viewport meta. — index.pug:5
An iframe with no title (or an empty one) is announced only as "frame". Add a non-empty title describing its content, or an aria-label. (×2) — index.pug:73, index.pug:78
What to do
Declare <html lang>, a document <title> and a <main> landmark, keep headings in order, leave zoom enabled, title iframes and drop meta-refresh.
Other · Accessibility — Whether ARIA is used correctly — valid non-abstract roles, the ARIA state a role requires, valid (non-misspelled) aria-* attribute names, in-enum values for token-typed aria-* attributes, and no aria-hidden on (or wrapping) a focusable element. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: role values checked against the WAI-ARIA role set (abstract/invalid flagged), required ARIA state for a role, and aria-hidden on a focusable element. Deterministic, role/attribute level.
Coverage: Population: elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) that carry a role or an aria-* attribute; roles and token values are checked against the ARIA enums exhaustively within that set. An expression-valued (dynamic) role or aria-* value is skipped rather than guessed, and markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
Other · Accessibility — Whether focus outlines aren't removed without a replacement, motion respects prefers-reduced-motion, and literal CSS colour pairs meet contrast — PARTIAL: inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS literals are read (hex/rgb/hsl/named), never computed/runtime/external-CDN colour. Static markup readiness, not a WCAG conformance claim.
Method: Static markup/CSS scan: inline outline:none/0, literal inline colour/background contrast against the 4.5:1 AA floor, and <style>-block animation without a prefers-reduced-motion guard. Deterministic but PARTIAL — only inline styles and in-repo CSS literals are visible.
Coverage: Population: styled elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx), plus in-repo <style> blocks, in-repo .css files and CSS-in-JS literals. Colour contrast is computed from LITERAL colour pairs only (hex/rgb/hsl/named, including var() tokens and Tailwind neutral utilities) — computed, runtime-themed and external-CDN colour is never resolved, so this is a partial read of contrast by construction. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
`.assistant-floating-input:focus` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible. — docs/css/mongoose9.css:1095
`.assistant-panel-input:focus` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible. — docs/css/mongoose9.css:1364
`.copy-btn` moves (`transition: opacity 0.18s ease, transform 0.18s ease, color 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — docs/css/copy-code.css:17
`#theme-icon-light` moves (`transition: opacity 0.2s ease, transform 0.3s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — docs/css/mongoose9.css:449
`.version-picker-caret` moves (`transition: transform 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — docs/css/mongoose9.css:555
`.sidebar-section-caret` moves (`transition: transform 0.15s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — docs/css/mongoose9.css:644
`#theme-toggle-btn` moves (`transition: background-color 0.2s ease, transform 0.1s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — docs/css/style.css:39
`#theme-icon-light` moves (`transition: opacity 0.3s ease, transform 0.3s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — docs/css/style.css:58
What to do
Keep a visible focus style (don't remove the outline without a replacement), guard animation with prefers-reduced-motion, and raise low-contrast colour pairs to at least 4.5:1.
Do you agree with this assessment?
AC7 · A11y enforcement4.0 / 10Weak✓ Tool-verified
Other · Accessibility — Whether accessibility is ENFORCED in the toolchain — an accessibility checker configured over the markup (an a11y lint rule set, e.g. eslint-plugin-jsx-a11y or vuejs-accessibility where the project lints JavaScript) and an automated accessibility assertion wired into tests or CI (axe/pa11y/Lighthouse or an equivalent) — on the Documented→Verified→Prevented ladder.
Method: Repo config/CI scan: an accessibility checker configured over the markup (an a11y lint rule set such as eslint-plugin-jsx-a11y / vuejs-accessibility where JavaScript is linted) and an automated accessibility assertion in tests or CI (axe/pa11y/Lighthouse or equivalent), graded on the Documented→Verified→Prevented rungs. Deterministic, presence/rung detection.
Coverage: Population: the repository's own tooling configuration — lint config, test and CI files — NOT the markup. It is read for a configured accessibility checker and an automated accessibility assertion (axe/pa11y/Lighthouse, or a native-toolkit equivalent), and it credits an INVOCATION, never a mention: a licence filename, an import comment or a doc reference earns no rung. Enforcement configured entirely outside the repository leaves no evidence here and cannot be credited.
No accessibility enforcement found — no a11y linter (an a11y linter that can read your UI — no component framework was detected, so the JSX/Vue ESLint plugins would have nothing to lint; use an HTML-template a11y linter (html-eslint, htmlhint) or run axe/pa11y over the rendered pages) and no axe/pa11y/Lighthouse in tests or CI. Start with the linter to catch issues at author time. What was searched, so you can tell an absence from a miss: the 9 markup file(s) this pass actually assessed, the linter configuration checked in beside them, and this repository's test and CI files — matched by name against the accessibility checkers this dimension carries. An audit run outside the repository, a hosted scanner, or a check whose name is not one of those, is not seen here.
What to do
Enforce accessibility in the toolchain: add an a11y linter that can read your UI — no component framework was detected, so the JSX/Vue ESLint plugins would have nothing to lint; use an HTML-template a11y linter (html-eslint, htmlhint) or run axe/pa11y over the rendered pages, then assert with your test runner's axe binding (jest-axe, vitest-axe, cypress-axe or @axe-core/playwright) in tests, then gate axe/pa11y/Lighthouse in CI.
Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.
Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.
Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.
What to do
The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.
Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.
Other · Security — Whether access is authorized by default — a framework authorization attribute/decorator or policy, or imperative guard methods (throw-on-violation) called from handlers.
Method: Roslyn scan: [Authorize] usage and authorization policies, plus imperative throw-on-violation guard methods detected via syntax. Deterministic.
This repository serves requests — express() (scripts/static.js:4) — and no route guard, auth-gate middleware, global guard or imperative check that refuses a caller (401/403, an Unauthorized/Forbidden error) was found: its endpoints may be unprotected. — scripts/static.js:4
What to do
Protect endpoints by default-deny: a global authentication guard or middleware with explicit public opt-outs, or a guard on every route, plus named role/permission rules for what an authenticated caller may do.
Other · Code Health — Unreviewed-generation residue in this repository's JavaScript/TypeScript: functions whose whole body still throws a "not implemented" error, and placeholder text (lorem ipsum, changeme/replace_me…) left in strings and JSX of non-test, non-generated code. Scored as a quality signature, never as a claim about authorship.
Method: Roslyn syntax scan: NotImplementedException throws and placeholder string literals in non-test, non-generated shipped code. Deterministic, code-shape signature.
Other · Code Health — Unfinished work detected by code SHAPE, not keywords, in this repository's JavaScript/TypeScript: functions that only throw a "not implemented" error, functions that take inputs and return a constant or do nothing, async functions that never await, dead `if (false)` branches, and skeleton classes most of whose methods are holes.
Method: Roslyn syntax scan: incompleteness by code shape (constant-returning methods, async-never-await, #if false branches, guards that return what the code already falls through to, tests an earlier guard already decided, comparisons against NaN, skeleton types), not keyword-gated. Deterministic, code-shape heuristic.
The guard above `return v;` also returns `v`, so no input can make it matter. Implement the distinction that was intended, or delete the guard. — lib/schema/bigint.js:254
A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something. (×2) — test/model.test.js:3753, test/model.test.js:3787
What to do
Clear the softer debt: re-enable or delete skipped tests, decide whether each empty function is a deliberate no-op (and say so in a comment), and replace blanket `eslint-disable` / `@ts-nocheck` with targeted, justified suppressions.
Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.
Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.
What to do
Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
Add a README to the 1 of 1 project(s) that lack one — worth up to 2 pts.
Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.
Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.
No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
No C4/Structurizr/PlantUML/Mermaid/Graphviz/D2 diagram, no drawn diagram named for the architecture, no file named `architecture` or `design` in any markup this check reads, and nothing in the README, docs or contributor guides that announces the shape — no `## Architecture` heading, no "architecture overview"/"high-level design" phrasing, no "the architecture is …" introduction, no guided code tour. A shape laid out in prose that never names itself as the architecture is not visible to this check, and neither is one kept outside the repository, so this row reports the absence of a re-findable shape document — not evidence that nobody wrote the shape down.
What to do
Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
Add a C4 context/container diagram (Structurizr, PlantUML or Mermaid) or an architecture.md overview.
Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).
Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.
CONTRIBUTING.md runs `npm run ts-benchmark-watch`, but no package.json declares a `ts-benchmark-watch` script. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — CONTRIBUTING.md:48
docs/atlas-vector-search.md names MongoDB 8, but the manifest declares `mongodb` ~7.7. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/atlas-vector-search.md:110
docs/nextjs.md documents the environment variable `MONGODB_URI`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/nextjs.md:54
What to do
Reconcile the README with reality: CONTRIBUTING.md runs `npm run ts-benchmark-watch`, but no package.json declares a `ts-benchmark-watch` script; docs/atlas-vector-search.md names MongoDB 8, but the manifest declares `mongodb` ~7.7; docs/nextjs.md documents the environment variable `MONGODB_URI`, but no code, script or configuration file names it.
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).
Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.
What to do
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.
Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.
The release is automated and no gate that pauses it for a human is DECLARED IN THIS REPOSITORY'S PIPELINE FILES. What was read: every file under `.github/workflows/`, `.forgejo/workflows/`, `.gitea/workflows/`, `.azuredevops/` and `.azure-pipelines/`, plus `.gitlab-ci*` and `azure-pipelines*` — with comment text stripped, so documenting a gate is not declaring one. What would have counted: GitLab's `when: manual`, CircleCI's `type: approval`, an Azure `ManualValidation@` task or an `approvals:` block, a Jenkins `input` step, a `uses:` step naming an approval action, an `environment:` paired with `reviewers` / `required_reviewers` / `protection` / `wait-timer` / `deployment_branch_policy`, a draft-release step, a `workflow_dispatch` promotion, or a release-event gate. ★ What this cannot see, because none of it is a file: a GitHub environment whose required reviewers are configured in repo SETTINGS, a branch protection rule, or an organisation deployment policy — all of them real, enforced gates that live outside the repository. If yours is one of those, this row is wrong and nothing in the tree could have told us. Otherwise: whatever the release trigger points at is published to users unreviewed, so a mistagged or unverified commit ships and the only remedy is a follow-up release.
What to do
Nothing pauses a release for a human: publish as a draft release (or gate the release job on a protected tag/manual dispatch) so a bad build can be stopped before users can download it.
Readiness · Readiness — Whether outbound HTTP calls are wrapped in resilience (retry/timeout/circuit-breaker) so a failing dependency doesn't cascade.
Method: Source scan: outbound HTTP clients and what bounds them — resilience handlers (Polly, AddStandardResilienceHandler) on .NET; on Go, the JVM, Python, JavaScript/TypeScript, Ruby, PHP, Rust, Elixir, Swift, Dart and Erlang, a timeout, deadline, retry or breaker beside each call, or a process-wide client default (a framework-wide deadline such as Drupal core's, Laravel's or actix's awc counts). Exhaustive, deterministic.
`fetch(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×2) — docs/js/ask-ai.js:85, scripts/loadSponsorData.js:61
What to do
Bound every outbound call: pass `signal: AbortSignal.timeout(ms)` to `fetch`, set `timeout` on the axios instance (`axios.create({ timeout })`), and add retries with back-off (`axios-retry`, `p-retry`) and a breaker (`opossum`, `cockatiel`) around dependencies that fail.
Readiness · Performance — Whether the code protects its performance with benchmarks — a benchmark suite, allocation/memory measurement, and (ideally) a CI gate. Presence is credited as a bonus, never a deduction.
Method: Repo + source scan: BenchmarkDotNet referenced (csproj/source), [Benchmark]/[MemoryDiagnoser] attribute counts, and a benchmark step in CI; off .NET, the same ladder over Go testing.B, Rust criterion/#[bench]/divan, JMH/kotlinx-benchmark, pytest-benchmark/asv/pyperf, tinybench/mitata/vitest bench/benchmark.js and Swift package-benchmark — scored as a bonus ladder (absence is neutral, never a deduction). Deterministic, presence detection.
Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.
Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from the language model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.
Do you agree with this assessment?
R1 · Type Safety0.8 / 10Critical✓ Tool-verified
React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.
Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.
39 typed · 428 plain JS — the untyped files are index.js, lib/aggregate.js, lib/cast.js, lib/cast/bigint.js, lib/cast/boolean.js, lib/cast/date.js (+422 more).
What to do
Migrate the remaining .js/.jsx files to TypeScript.
React / JS · Code Health — Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm over JS/TS tokens, D-386): a block is reported only where its copies still agree on most of their own identifiers and literals, or were renamed as they were pasted but kept most of their constants, and where the copies carry enough code to stand on their own or the copied extent reaches 30 lines — so a re-implementation sharing neither names nor values, and a small pasted declaration, are both found and deliberately not reported, and a clean R10 is not a claim that nothing was copied.
Method: Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm run over JS/TS tokens). Masking finds the candidates; a block is reported when its copies still agree on most of their own identifiers and literals, or when a renamed copy still agrees on most of its constants, AND the copies carry enough code to stand on their own — or when the copied extent reaches 30 lines. So a re-implementation sharing neither names nor values, and a small pasted declaration, are deliberately not counted. Deterministic.
lib/schema/bigint.js:83 · lib/schema/int32.js:101 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schema/bigint.js:83
lib/schema/double.js:39 · lib/schema/int32.js:40 — the two spans are one implementation copied and then locally edited — 274 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — lib/schema/double.js:39
lib/query.js:4246 · lib/query.js:4292 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/query.js:4246
lib/helpers/document/applyTimestamps.js:39 · lib/helpers/document/applyVirtuals.js:51 — the two spans are one implementation copied and then locally edited — 222 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — lib/helpers/document/applyTimestamps.js:39
lib/types/array/index.js:82 · lib/types/documentArray/index.js:76 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another. — lib/types/array/index.js:82
lib/schema/date.js:368 · lib/schema/decimal128.js:194 · lib/schema/double.js:177 — the 3 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. There is one copy in each of 3 separate files rather than several in one place, so check first whether these are sibling modules that each declare their own version of one shape — one per entity, per provider, per language. Where they are, no single extracted module collapses them: each module still has to be written, and what recurs is the TEMPLATE. The moves that do collapse a template are to generate these modules from the set they enumerate, or to replace the repeated construction with one factory each site calls with its own values — and where the set is the point, each module pinning one distinct thing, the repetition IS the enumeration and there is nothing to delete. — lib/schema/date.js:368
lib/connection.js:607 · lib/connection.js:1749 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/connection.js:607
lib/helpers/model/castBulkWrite.js:103 · lib/helpers/model/castBulkWrite.js:167 — the two spans are one implementation copied and then locally edited — 197 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — lib/helpers/model/castBulkWrite.js:103
scripts/generateSearch.js:55 · scripts/generateSearch.js:92 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — scripts/generateSearch.js:55
lib/cast.js:338 · lib/helpers/query/castFilterPath.js:28 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another. — lib/cast.js:338
lib/schema/number.js:434 · lib/schema/uuid.js:225 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schema/number.js:434
lib/query.js:4359 · lib/query.js:4430 · lib/query.js:4506 — all 3 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/query.js:4359
lib/schema/buffer.js:260 · lib/schema/uuid.js:226 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schema/buffer.js:260
lib/schema/buffer.js:148 · lib/schema/buffer.js:181 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/schema/buffer.js:148
lib/helpers/model/castBulkWrite.js:147 · lib/helpers/model/castBulkWrite.js:212 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/helpers/model/castBulkWrite.js:147
lib/schema.js:209 · lib/schema.js:235 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/schema.js:209
lib/schema/date.js:267 · lib/schema/date.js:329 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schema/date.js:267
lib/aggregate.js:249 · lib/aggregate.js:662 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/aggregate.js:249
lib/cursor/aggregationCursor.js:220 · lib/cursor/queryCursor.js:215 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. — lib/cursor/aggregationCursor.js:220
lib/document.js:5261 · lib/document.js:5290 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/document.js:5261
lib/helpers/update/applyTimestampsToUpdate.js:56 · lib/helpers/update/applyTimestampsToUpdate.js:104 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/helpers/update/applyTimestampsToUpdate.js:56
lib/schema/boolean.js:88 · lib/schema/string.js:59 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. — lib/schema/boolean.js:88
lib/types/subdocument.js:263 · lib/types/subdocument.js:295 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/types/subdocument.js:263
lib/error/setOptionError.js:58 · lib/error/validation.js:64 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/error/setOptionError.js:58
lib/schema.js:2122 · lib/schema.js:2184 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schema.js:2122
lib/types/documentArray/methods/index.js:92 · lib/types/documentArray/methods/index.js:415 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/types/documentArray/methods/index.js:92
lib/helpers/populate/getVirtual.js:31 · lib/helpers/populate/getVirtual.js:63 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/helpers/populate/getVirtual.js:31
lib/query.js:1168 · lib/query.js:1186 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/query.js:1168
lib/query.js:3290 · lib/query.js:3366 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/query.js:3290
lib/query.js:3758 · lib/query.js:3908 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/query.js:3758
lib/types/array/methods/index.js:315 · lib/types/documentArray/methods/index.js:480 — the two spans are one implementation copied and then locally edited — 81 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — lib/types/array/methods/index.js:315
lib/document.js:2431 · lib/document.js:2532 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/document.js:2431
lib/helpers/setDefaultsOnInsert.js:113 · lib/helpers/setDefaultsOnInsert.js:152 — the two spans are one implementation copied and then locally edited — 57 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — lib/helpers/setDefaultsOnInsert.js:113
lib/model.js:3071 · lib/model.js:3464 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/model.js:3071
lib/query.js:2825 · lib/query.js:3765 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lib/query.js:2825
lib/schema/number.js:73 · lib/schema/objectId.js:121 · lib/schema/string.js:53 — the 3 copies are spread across 3 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schema/number.js:73
lib/schema/string.js:258 · lib/schema/string.js:297 · lib/schema/string.js:334 — all 3 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schema/string.js:258
lib/schema/string.js:596 · lib/schema/uuid.js:190 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. — lib/schema/string.js:596
lib/schema/string.js:614 · lib/schemaType.js:1741 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schema/string.js:614
lib/schemaType.js:570 · lib/schemaType.js:607 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lib/schemaType.js:570
What to do
Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
React / JS · Architecture — Conformance to the detected frontend architecture layout (feature-sliced / layered src) plus cross-package deep-import rules (D-386).
Method: Conformance to the detected frontend layout (feature-sliced / layered src) plus cross-package deep-import rules, over the module graph. Deterministic.
lib/cast/bigint.js:3 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/cast/bigint.js:3
lib/cast/double.js:4 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/cast/double.js:4
lib/cast/uuid.js:3 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/cast/uuid.js:3
lib/drivers/node-mongodb-native/bulkWriteResult.js:3 imports mongodb/lib/bulk/common, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/drivers/node-mongodb-native/bulkWriteResult.js:3
REDACTED:14 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — REDACTED:14
lib/helpers/common.js:7 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/helpers/common.js:7
lib/types/buffer.js:7 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/types/buffer.js:7
lib/types/buffer.js:8 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/types/buffer.js:8
lib/types/decimal128.js:13 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/types/decimal128.js:13
lib/types/double.js:13 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/types/double.js:13
lib/types/objectid.js:13 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/types/objectid.js:13
lib/types/uuid.js:13 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/types/uuid.js:13
lib/utils.js:7 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lib/utils.js:7
What to do
Fix the listed violations: import through public entries (package exports / slice index), never reach into another layer or package's internals.
React / JS · Code Health — Per-function cyclomatic/cognitive complexity from the token-level function scanner (D-386) — real branching, not a regex heuristic.
Method: Per-function cyclomatic/cognitive complexity from a token-level function scanner (real branching, not a regex heuristic), computed over every frontend function. Deterministic.
$set has cyclomatic complexity 164 and cognitive complexity 260; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/document.js:1103
cast has cyclomatic complexity 103 and cognitive complexity 305; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/cast.js:38
walkUpdatePath has cyclomatic complexity 96 and cognitive complexity 238; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/helpers/query/castUpdate.js:222
_getPathsToValidate has cyclomatic complexity 86 and cognitive complexity 172; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/document.js:3102
applyDefaults has cyclomatic complexity 76 and cognitive complexity 189; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/helpers/document/applyDefaults.js:5
interpretAsType has cyclomatic complexity 76 and cognitive complexity 133; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/schema.js:1600
_populatePath has cyclomatic complexity 61 and cognitive complexity 106; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/model.js:4574
add has cyclomatic complexity 57 and cognitive complexity 107; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/schema.js:793
getModelsMapForPopulate has cyclomatic complexity 57 and cognitive complexity 102; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/helpers/populate/getModelsMapForPopulate.js:25
search has cyclomatic complexity 56 and cognitive complexity 171; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/helpers/populate/getSchemaTypes.js:49
validate has cyclomatic complexity 56 and cognitive complexity 75; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/document.js:2747
_insertMany has cyclomatic complexity 55 and cognitive complexity 87; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/model.js:3089
$toObject has cyclomatic complexity 54 and cognitive complexity 60; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/document.js:4221
init has cyclomatic complexity 52 and cognitive complexity 93; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/document.js:751
deepEqual has cyclomatic complexity 51 and cognitive complexity 54; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/utils.js:77
castUpdate has cyclomatic complexity 50 and cognitive complexity 61; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/helpers/query/castUpdate.js:51
clone has cyclomatic complexity 47 and cognitive complexity 73; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — REDACTED:33
$__save has cyclomatic complexity 46 and cognitive complexity 99; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/model.js:385
path has cyclomatic complexity 44 and cognitive complexity 68; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/schema.js:1285
$__delta has cyclomatic complexity 43 and cognitive complexity 86; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lib/document.js:5406
What to do
Break down the listed branch-heavy functions; aim P95 cyclomatic ≤ 5.
Do you agree with this assessment?
R3 · Large Files7.0 / 10Strong✓ Tool-verified
React / JS · Code Health — How many source files exceed the large-file threshold.
Method: Components/modules exceeding the large-file threshold, counted exhaustively across the frontend source tree. Deterministic.
lib/query.js has 5306 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/query.js:1
lib/document.js has 5300 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/document.js:1
lib/model.js has 4810 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/model.js:1
lib/schema.js has 3042 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/schema.js:1
lib/schemaType.js has 1747 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/schemaType.js:1
lib/connection.js has 1642 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/connection.js:1
lib/mongoose.js has 1261 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/mongoose.js:1
lib/aggregate.js has 1122 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/aggregate.js:1
lib/types/array/methods/index.js has 960 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/types/array/methods/index.js:1
lib/utils.js has 914 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/utils.js:1
lib/helpers/populate/getModelsMapForPopulate.js has 788 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/helpers/populate/getModelsMapForPopulate.js:1
lib/schema/string.js has 665 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/schema/string.js:1
lib/helpers/query/castUpdate.js has 617 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/helpers/query/castUpdate.js:1
lib/schema/array.js has 611 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/schema/array.js:1
lib/cursor/queryCursor.js has 594 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/cursor/queryCursor.js:1
lib/schema/documentArray.js has 576 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/schema/documentArray.js:1
lib/cursor/aggregationCursor.js has 461 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/cursor/aggregationCursor.js:1
lib/types/documentArray/methods/index.js has 457 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/types/documentArray/methods/index.js:1
lib/schema/number.js has 448 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/schema/number.js:1
lib/drivers/node-mongodb-native/connection.js has 436 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/drivers/node-mongodb-native/connection.js:1
lib/schema/date.js has 411 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lib/schema/date.js:1
What to do
Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
Do you agree with this assessment?
R4 · Test Coverage9.5 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Static test reachability (D-386): the share of production files reachable from any test via the import graph — measured without running anything.
Method: Static test reachability: the share of production files reachable from any test via the import graph — measured without running anything. Deterministic.
No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one. (×15) — scripts/website.js:1, scripts/generateSearch.js:1, scripts/generateLLMsTXT.js:1, …
What to do
Add tests that import the unreached modules (directly or through their public entry).
Do you agree with this assessment?
R6 · Tooling10.0 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each package.json script's COMMAND (eslint / tsc / vitest / jest / playwright), not just its name, and corroborated against CI-workflow invocations so a tool run only in CI still counts.
Method: package.json scanned for test/lint/typecheck script wiring. Deterministic presence check.
Do you agree with this assessment?
R7 · Dead Code8.0 / 10Strong✓ Tool-verified
React / JS · Code Health — Files unreachable from every application/tooling/test entry point, and exports nothing imports (module-graph reachability, D-386).
Method: Dead code: files unreachable from every application/tooling/test entry point plus exports nothing imports, via module-graph reachability. Deterministic, exhaustive over the import graph.
Unreachable from the 44 application, 33 tooling and 188 test entry point(s) detected in this repo. Nothing this repository declares compiles or type-checks these files, so a wrong deletion here would raise no compile error — gate removals on `npm test`, which loads the modules, and note that it only covers what it exercises. An undetected custom entry would make these reachable.
no import path from any entry point (44 application, 33 tooling, 188 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make (×5) — tools/sharded.js, tools/auth.js, lib/error/browserMissingSchema.js, …
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/hydrateComplex.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/hydrateComplex.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/saveSimple.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/saveSimple.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/findOneAndUpdateSimple.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/findOneAndUpdateSimple.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/get.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/get.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/findOneWithCast.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/findOneWithCast.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/insertManySimple.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/insertManySimple.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/recursiveToObject.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/recursiveToObject.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/mapOfSubdocs.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/mapOfSubdocs.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/nestedArrayLarge.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/nestedArrayLarge.js
This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/createDeepNestedDocArray.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it. — benchmarks/createDeepNestedDocArray.js
This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it. (×24) — test/types/Errors.test.ts:8, test/types/Errors.test.ts:18, test/types/PipelineStage.test.ts:9, …
What to do
Delete the dead files and unused exports — every line is maintenance cost and rebuild-estimate inflation with zero runtime value.
React / JS · Readiness — npm dependency truthfulness (D-386): unused dependencies, imports not declared anywhere, and type-/test-only packages shipped as production deps.
Method: npm dependency truthfulness: unused dependencies, imports declared nowhere, and type-/test-only packages shipped as production deps — from the manifest + import graph. Deterministic.
Declared in the root package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
What to do
Remove unused dependencies, declare unlisted imports explicitly, and demote type-/test-only packages to devDependencies.
React / JS · Architecture — Import cycles in the module graph (D-386) — files that can only be understood and changed together.
Method: Import cycles in the module graph, detected exhaustively over JS/TS imports (the same cycle detection as the .NET coupling dimension). Deterministic.
lib/cast.js → lib/schema/index.js → lib/schema/array.js → lib/cast.js (one verified cycle inside a mutually-dependent group of 51 files) — lib/cast.js:10
Other · Security — Read from this repository's JavaScript/TypeScript source: cryptographic hygiene (weak hash or cipher, key material fixed in the source) and outbound TLS (certificate validation, protocol version) — facts about code that hold whether or not it serves anything itself. The server controls — HTTPS enforcement, HSTS, cookie flags, input validation — are NOT assessed for JavaScript/TypeScript: each is scored as an absence, an absence is only reportable over the production HTTP server, and in this ecosystem the file that opens the port is build output or a framework launcher rather than a file in the source tree. Their absence here is not a finding about this repository. Its Node HTTP listeners were read for HTTPS enforcement alone — TLS served, a redirect to https:// or HSTS, or a TLS-terminating proxy configuration committed beside the server — each judged per server package.
Method: Roslyn plus filesystem scan: HSTS/security headers, secure cookies, input validation, middleware order, weak crypto (MD5/SHA1/DES); HTTPS-metadata context-aware. On a repository with no .NET source it reads JavaScript/TypeScript, Dart, Ruby, Scala, Rust or Elixir source itself (test, vendored, generated and minified paths not) for the arms that hold whether or not the code serves HTTP: a weak hash or cipher, key material fixed in the source, a TLS client that accepts any certificate, and (JavaScript/TypeScript, Ruby, Scala, Rust and Elixir) an obsolete TLS version; the server controls are not assessed there, and a Dart, Ruby, Scala, Rust or Elixir repository that serves no HTTP of its own is N/A on them. Deterministic.
`app.listen(…)` serves plain HTTP on a network address, and nothing in its package enforces HTTPS: no TLS served (`https.createServer`, Fastify `https`, Nest `httpsOptions`), no redirect of plain requests to `https://`, no `Strict-Transport-Security` (helmet sends it by default), and no TLS-terminating proxy configuration committed beside it — so a browser may talk to it in clear text. (−2.0 on this card.) — scripts/static.js:22
What to do
Enforce HTTPS on each listed server: serve TLS itself, or redirect plain requests to `https://` and send `Strict-Transport-Security` (`helmet()` does by default) behind the TLS-terminating proxy — and commit that proxy's configuration beside the service. A server only this machine reaches should bind `127.0.0.1`.
Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.
Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.
Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.
Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.
Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.
Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.
Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.
Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.
Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X17 · Uncapped recursion over a caller-supplied document2.7 / 10Weak✓ Tool-verified
Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.
Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.
`clone` is exported and takes `obj: object` from its caller, and it calls itself at line 75 (`clone`) with a piece of `obj` — and nowhere in `clone` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. JavaScript sets no limit of its own on that nesting: `JSON.parse` accepts any depth, so a 100,000-byte body — inside Express's default 100kb limit — parses to 50,000 levels, and a walk like this one throws `RangeError: Maximum call stack size exceeded` long before it reaches the bottom. Wherever that throw lands, the work fails: a request errors, and a walk running outside any `try` — an event handler, a timer, a promise nobody awaits — takes the Node process down with every other request in flight. Thread a depth argument through `clone` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — REDACTED:75
`applyTimestamps` is exported, takes a document from its caller (line 19) and hands it to `applyTimestampsToDoc`, which calls itself at line 70 (`applyTimestampsToDoc`) with a piece of `obj` — and nowhere in `applyTimestampsToDoc` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. JavaScript sets no limit of its own on that nesting: `JSON.parse` accepts any depth, so a 100,000-byte body — inside Express's default 100kb limit — parses to 50,000 levels, and a walk like this one throws `RangeError: Maximum call stack size exceeded` long before it reaches the bottom. Wherever that throw lands, the work fails: a request errors, and a walk running outside any `try` — an event handler, a timer, a promise nobody awaits — takes the Node process down with every other request in flight. Thread a depth argument through `applyTimestampsToDoc` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — lib/helpers/document/applyTimestamps.js:70
What to do
Each finding names the externally-callable member that accepts the document and the self-call that descends, and states that no depth parameter or counter exists anywhere in the walk. Confirm from the two, then thread a depth argument through the walk and reject documents past a fixed maximum, or rewrite it with an explicit stack.
Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.
Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.
Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether async functions that make a cancellable request accept or pass on an AbortSignal (adoption curve).
Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.
Only 0/2 async functions that make a cancellable request (fetch, axios, ky, ofetch) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
`submitQuestion` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — docs/js/ask-ai.js:65
`run` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — scripts/loadSponsorData.js:24
What to do
Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.
Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.
Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.
Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.
Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.
Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.
Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.
Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.
Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.
Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.
An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. (×5) — lib/tracing.js:8, lib/types/documentArray/methods/index.js:150, scripts/website.js:40, …
`.catch(function$modelInitNoop(){})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it. (×4) — lib/mongoose.js:695, lib/connection.js:1098, lib/connection.js:1497, …
`.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it. (×4) — lib/model.js:5289, lib/connection.js:748, lib/connection.js:1134, …
`.then(…, () => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it. (×2) — lib/cursor/changeStream.js:64, lib/cursor/changeStream.js:206
What to do
Swallowed exception (empty catch)
Do you agree with this assessment?
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.
Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
WCAG coverage — what static analysis assessed
Statically assessed 13 of 55 WCAG 2.2 Level A/AA success criteria (24%; ≈26% of the 50 WCAG 2.1 AA criteria for EN 301 549). The other 42 require runtime or manual evaluation. Partial signal only (a clean result is necessary, not sufficient; static analysis fully verifies none). This is accessibility readiness, not a conformance claim — a WCAG conformance claim requires manual evaluation (WCAG-EM 1.0).
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Unscored — 4 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
D12 Dependency Hygiene — 1 observation(s) recorded · Dependency currency not established — this repository commits no lockfile to resolve
SC1 Supply-chain hygiene — 1 observation(s) recorded · Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X10 Duplicated predicate — 21 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 1 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 1 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 49 check(s) not relevant to this codebase
These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.
AC4 Keyboard semantics — No interactive element found in the parsed markup — AC4 not applicable here.
AX1 Captive dependencies — Not applicable: this repository's JavaScript imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
AX2 Stateful singletons — Not applicable: TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX6 Interface segregation — no exported interface declares behaviour
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AX8 Test isolation — no test/production split to check
AX9 CQS / query purity — no CQRS query handlers detected — query purity is not applicable to this codebase
AXB1 Runtime evidence locked — no reproducible boot — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
C1 Data Protection — No personal data detected in a persisted data model — no PII-named field (email, firstName, dateOfBirth, phoneNumber, …) or stored credential on a TypeORM/MikroORM/sequelize-typescript/NestJS-Mongoose entity, a Mongoose schema, a Sequelize or Drizzle table, a Knex migration or a Prisma model — and no database or data-store client in the source either, so this repository keeps no data at rest for these controls to protect. If it does persist personal data (through a hosted backend configured outside this repository, for instance), the controls belong to wherever that data is stored.
C3 Audit Trail — No personal data detected in a persisted data model — no PII-named field (email, firstName, dateOfBirth, phoneNumber, …) or stored credential on a TypeORM/MikroORM/sequelize-typescript/NestJS-Mongoose entity, a Mongoose schema, a Sequelize or Drizzle table, a Knex migration or a Prisma model — and no database or data-store client in the source either, so this repository keeps no sensitive data whose changes an audit trail would record. If it does (through a hosted backend configured outside this repository, for instance), the trail belongs to wherever that data is stored.
C4 Data Retention — No personal data detected in a persisted data model — no PII-named field (email, firstName, dateOfBirth, phoneNumber, …) or stored credential on a TypeORM/MikroORM/sequelize-typescript/NestJS-Mongoose entity, a Mongoose schema, a Sequelize or Drizzle table, a Knex migration or a Prisma model — and no database or data-store client in the source either, so this repository keeps no personal data whose lifetime a retention limit would bound. If it does (through a hosted backend configured outside this repository, for instance), the limit belongs wherever that data is stored.
C5 Data-Subject Rights — No personal data detected in a persisted data model — no PII-named field (email, firstName, dateOfBirth, phoneNumber, …) or stored credential on a TypeORM/MikroORM/sequelize-typescript/NestJS-Mongoose entity, a Mongoose schema, a Sequelize or Drizzle table, a Knex migration or a Prisma model — and no database or data-store client in the source either, so this repository keeps no personal data for a data subject to erase, export or consent over. If it does (through a hosted backend configured outside this repository, for instance), the rights are served wherever that data is stored.
D11 Test Reliability — Test reliability not measured — JavaScript/TypeScript suite did not run
D14 License Compliance — npm licences not graded — this npm repository commits no lockfile this pass can resolve
D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
D20 ADR Quality — N/A — ADRs are expected on deployable products with a user-facing host, not consumed libraries; no ADR log is required here.
D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ projects each declaring an entity of their own. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — No inline comments to assess — comment value is not applicable here.
D25 ADR Conformance — no ADRs to check
D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.js), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D31 IaC & Container Security — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
D32 Data Compliance (PII/GDPR) — 5 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
D4 Code Duplication — This repository's production source (.cjs, .js, .mts) is not read by D4's token comparison, which compares .NET source: duplication in it is measured by R10 Code Duplication, the frontend lens's card running the same clone algorithm over the JS/TS token stream. Not scored here — read the R10 card for this repository's duplication.
D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
D5 Coupling — Not applicable — this npm build ships 1 production module(s), so there is no coupling BETWEEN modules to measure. (Its test and non-production modules are not part of the shipped graph.)
D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
D8 Code Coverage — Coverage NOT MEASURED: the JavaScript/TypeScript half could not be measured — the mocha suite in the repository root ran and not one test passed (Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:), so the coverage report describes the failed run, not the code. Coverage is excluded from the score rather than counted as a near-zero. The named suite step is one the repository's maintainers can perform; once it passes, the real number is measured on the next scan. Alternatively, commit the lcov/Cobertura report your CI produces and it is read without a re-run.
DM1 Domain Modelling — not scored — this repository shows none of the 3 signals this lens looks for
ED1 Event-Driven — not scored — this repository shows none of the 3 signals this lens looks for
ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
P2 Observability — This repository's JavaScript/TypeScript source (1 module(s), 288 file(s) read) declares no entry point and bootstraps no server, and nothing here deploys a service — it is a library, run inside whatever hosts it, so production observability (structured logging, tracing/metrics, health checks) is N/A. If it grows a binary or a service, the dimension reactivates.
P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (lcov — `c8 --reporter=lcovonly <your existing test command>` (c8 is already a devDependency here)) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
PF2 Allocation hygiene — Not applicable: TypeScript/JavaScript runs on a garbage-collected runtime that gives a program no allocation-control idiom to choose on a hot path — no pools, stack allocation or value types — so allocation awareness is not something this code can be rated on.
R5 Dependency Freshness — no package-lock.json — dependency freshness not measured (would require an npm lockfile); JS/npm CVEs are scored in D30 (Dependency Vulnerabilities), which answers every ecosystem
X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X26 Unsynchronised callback handoff — Not applicable: this check looks for a collection written by a callback on one thread while the body waiting on it touches it on another, and in this repository's languages no collection is reachable from two threads at once. TypeScript/JavaScript runs every callback on the one thread that owns its objects: a callback runs only when the body waiting on it has yielded, never alongside it, and a worker thread receives a COPY of what it is sent. A SharedArrayBuffer carries raw bytes, never an Array, Map or Set, so no collection is reachable from two threads at once. Not a gap in the analyzer and not a finding about your code.
X27 Collection changed while being enumerated — Not applicable: this check looks for a loop whose body adds to or removes from the very collection the loop is walking, invalidating the enumerator it holds, and in this repository's languages that cannot happen. JavaScript and TypeScript have no iterator that a change can invalidate: an `Array` is walked by index against its live length, and a `Map` or `Set` by the ECMAScript specification's live entry list, so a body that adds to, removes from or empties what it walks raises nothing — every loop form (`for…of`, `for…in`, `forEach`, `map`, `filter`, `reduce`, `entries()`) on every built-in collection (`Array`, `Map`, `Set`, plain objects, `URLSearchParams`, `Headers`, `FormData`) runs to completion. Such a loop can still skip an element or never end, which is a different defect and not the one this check asks about. Not a gap in the analyzer and not a finding about your code.
X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X5 Nullable reference types — Not applicable: this check asks whether the null-typed discipline a language offers is switched on, and how much of that the assertion operator takes back, and in this repository's languages there is no such switch and no such operator. Plain JavaScript carries no type annotations and commits no tsconfig, so it states no null-typed discipline for this check to grade: there is nothing here that switches null checking on or off, and TypeScript (or `// @ts-check`) is how a repository acquires one — advice, not a defect this card measures. Not a gap in the analyzer and not a finding about your code.
X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
AC3 · Page structure· <iframe> without a title · ×2
<iframe> without a title index.pug:73— An iframe with no title (or an empty one) is announced only as "frame". Add a non-empty title describing its content, or an aria-label.
<iframe> without a title index.pug:78— An iframe with no title (or an empty one) is announced only as "frame". Add a non-empty title describing its content, or an aria-label.
D10 · Test Quality· No assertions (empty test) · ×2
No assertions (empty test): 2dsphere indexed field with geojson without value is saved (gh-3233) test/model.test.js:3596— Test method has an empty body — it asserts nothing and exercises no code.
No assertions (empty test): createCollection() handles NamespaceExists errors (gh-9447) test/model.test.js:6430— Test method has an empty body — it asserts nothing and exercises no code.
AC1 · Text alternatives· <img> without a text alternative · ×1
<img> without a text alternative docs/sponsors.pug:11— An image with no alt (and no aria-label/aria-labelledby) is unreadable to assistive tech. Add alt — alt="" if it's purely decorative.
Viewport restricts zoom index.pug:5— user-scalable=no/0 or a maximum-scale below 2 stops low-vision users zooming to 200%. Remove the zoom restriction from the viewport meta.
No assertions: works with numbericAlpha paths test/versioning.test.js:158— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: handles validation of document array with maps and nested paths (gh-8767) test/types.map.test.js:919— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: clears listeners on cast error (gh-6723) test/types.documentarray.test.js:575— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: regex validator works with validate() (gh-15380) test/schema.string.test.js:25— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: selecting _id works with excluded schematype path test/schema.select.test.js:432— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: selecting _id works with excluded schematype path on sub doc test/schema.select.test.js:441— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: allows 0 with required: true and ref set (gh-11912) test/schema.number.test.js:10— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: with findOneAndUpdate (gh-4318) test/query.toconstructor.test.js:143— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: ignores sort when passed to countDocuments test/query.test.js:1452— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: ignores count when passed to sort test/query.test.js:1458— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: timestamps with $each (gh-4805) test/query.test.js:1499— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: $geoWithin with single nested schemas (gh-4044) test/query.test.js:1535— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: string with $not (gh-4592) test/query.test.js:1712— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: $exists under $not (gh-4933) test/query.test.js:1785— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: geojson underneath array (gh-5467) test/query.test.js:1795— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: overwrites when passing an object when path already set to primitive (gh-6097) test/query.test.js:1844— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: $exists for arrays and embedded docs (gh-4937) test/query.test.js:1854— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: no longer has the deprecation warning message with writeConcern gh-10083 test/query.test.js:3491— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: with schema test/object.create.null.test.js:114— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: supports arrays defined using schemas from separate instance (gh-15466) test/multiple-require-instance.test.js:25— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: avoids nested paths if setting parent path (gh-4911) test/model.updateOne.test.js:679— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: validators ignore $inc test/model.updateOne.test.js:859— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: handles empty update with promises (gh-2796) test/model.updateOne.test.js:944— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: works with undefined date (gh-2833) test/model.updateOne.test.js:1067— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: works with buffers (gh-3496) test/model.updateOne.test.js:1276— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
+ 113 more in this group — see findings.md.
D10 · Test Quality· Fixed-sleep synchronisation · ×21
Fixed-sleep synchronisation: timestamps handle reusing child schemas (gh-7712) test/timestamps.test.js:311— This test starts work it did not wait for (`M1`, still running when the sleep starts) and then orders itself against it with `new Promise(resolve => setTimeout(resolve, 25))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: updates updatedAt when calling update without $set (gh-4768) test/timestamps.test.js:367— This test starts work it did not wait for (`Model`, still running when the sleep starts) and then orders itself against it with `delay(50)` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: sets timestamps on bulk write without `$set` (gh-9268) test/timestamps.test.js:442— This test starts work it did not wait for (`Test`, still running when the sleep starts) and then orders itself against it with `delay(10)` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: nested docs with push (gh-4049) test/timestamps.test.js:689— This test starts work it did not wait for (`Group`, still running when the sleep starts) and then orders itself against it with `new Promise(resolve => setTimeout(resolve, 5))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: shouldnt bump updatedAt in single nested subdocs that are not modified (gh-9357) test/timestamps.test.js:766— This test starts work it did not wait for (`Parent`, still running when the sleep starts) and then orders itself against it with `delay(10)` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: bumps updatedAt with mixed $set (gh-9357) test/timestamps.test.js:801— This test starts work it did not wait for (`Parent`, still running when the sleep starts) and then orders itself against it with `delay(10)` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: allows skipping timestamps in updateOne() (gh-6980) test/query.test.js:2738— This test starts work it did not wait for (`M`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 10))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: increments timestamps for nested subdocs (gh-4412) test/query.test.js:2759— This test starts work it did not wait for (`Parent`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 10))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: updates with timestamps with $set (gh-4989) (gh-7152) test/model.updateOne.test.js:1375— This test starts work it did not wait for (`Tag`, still running when the sleep starts) and then orders itself against it with `delay(10)` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: sets child timestamps even without $set (gh-7261) test/model.updateOne.test.js:2534— This test starts work it did not wait for (`Parent`, still running when the sleep starts) and then orders itself against it with `delay(10)` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: handles timestamp properties in nested paths when overwriting parent path (gh-9105) test/model.updateOne.test.js:3120— This test starts work it did not wait for (`Test`, still running when the sleep starts) and then orders itself against it with `delay(10)` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: with child timestamps and array filters (gh-7032) test/model.test.js:4843— This test starts work it did not wait for (`Parent`, still running when the sleep starts) and then orders itself against it with `new Promise(resolve => setTimeout(resolve, 100))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: with timestamps and replaceOne (gh-5708) test/model.test.js:4879— This test starts work it did not wait for (`M`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 10))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: with timestamps from merged schema (gh-13409) test/model.test.js:4903— This test starts work it did not wait for (`M`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 10))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: with child timestamps (gh-7032) test/model.test.js:4926— This test starts work it did not wait for (`M`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 10))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: bulkwrite should not change updatedAt on subdocs when timestamps set to false (gh-13611) test/model.test.js:6982— This test starts work it did not wait for (`User`, still running when the sleep starts) and then orders itself against it with `delay(10)` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: doesnt wipe out changes made while `save()` is in flight (gh-9327) test/model.test.js:7269— This test starts work it did not wait for (`Test`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 0))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: can be disabled test/model.indexes.test.js:334— This test starts work it did not wait for (`Test`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 100))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: will not create indexes if the global auto index is false and schema option isnt set (gh-1875) test/model.indexes.test.js:368— This test starts work it did not wait for (`db`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 100))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: buffers connection helpers test/connection.test.js:2068— This test starts work it did not wait for (`promise`, still running when the sleep starts) and then orders itself against it with `new Promise(resolve => setTimeout(resolve, 100))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
Fixed-sleep synchronisation: creation test/collection.capped.test.js:38— This test starts work it did not wait for (`Capped`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => setTimeout(resolve, 100))` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
R4 · Test Coverage· No test reaches this file · ×15
No test reaches this file scripts/website.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file scripts/generateSearch.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file scripts/generateLLMsTXT.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file scripts/loadSponsorData.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file scripts/update-mongodb-links.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file scripts/setup-encryption-tests.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file tools/sharded.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file tools/repl.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file scripts/static.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file tools/auth.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file lib/error/browserMissingSchema.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file scripts/tsc-diagnostics-check.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file lib/helpers/once.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file scripts/create-tarball.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file lib/helpers/query/validOps.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
Swallowed exception (empty catch) lib/tracing.js:8— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) lib/mongoose.js:695— `.catch(function$modelInitNoop(){})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/model.js:5289— `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/connection.js:748— `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/connection.js:1098— `.catch(function$modelInitNoop(){})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/connection.js:1134— `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/connection.js:1156— `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/connection.js:1497— `.catch(function$modelInitNoop(){})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/cursor/changeStream.js:64— `.then(…, () => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/cursor/changeStream.js:206— `.then(…, () => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/drivers/node-mongodb-native/connection.js:426— `.catch(function$modelInitNoop(){})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lib/types/documentArray/methods/index.js:150— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) scripts/website.js:40— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) scripts/website.js:342— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) scripts/loadSponsorData.js:53— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Hotspot: lib/document.js lib/document.js:3102— lib/document.js changed 33 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 85 in document._getPathsToValidate at line 3102. 16 of those changes were fix/bug commits, and the other 17 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/document.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/model.js lib/model.js:4574— lib/model.js changed 20 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 61 in model._populatePath at line 4574. 7 of those changes were fix/bug commits, and the other 13 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/model.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/queryHelpers.js lib/queryHelpers.js:139— lib/queryHelpers.js changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 88 in queryHelpers.applyPaths at line 139. 4 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/queryHelpers.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/query.js lib/query.js:1739— lib/query.js changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in query.Query.setOptions at line 1739. 5 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/query.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/cast.js lib/cast.js:38— lib/cast.js changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 103 in cast.cast at line 38. 3 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/cast.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/schema/documentArray.js lib/schema/documentArray.js:404— lib/schema/documentArray.js changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 37 in documentArray.SchemaDocumentArray.cast at line 404. 5 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/schema/documentArray.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/schema.js lib/schema.js:431— lib/schema.js changed 16 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 15 in schema.Schema._clone at line 431. 9 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/schema.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/schema/array.js lib/schema/array.js:333— lib/schema/array.js changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in array.SchemaArray.cast at line 333. 3 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/schema/array.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/helpers/query/castUpdate.js lib/helpers/query/castUpdate.js:51— lib/helpers/query/castUpdate.js changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 50 in castUpdate.castUpdate at line 51. 3 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/helpers/query/castUpdate.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/connection.js lib/connection.js:456— lib/connection.js changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 32 in connection.Connection.bulkWrite at line 456. 3 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/connection.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/helpers/update/applyTimestampsToUpdate.js lib/helpers/update/applyTimestampsToUpdate.js:16— lib/helpers/update/applyTimestampsToUpdate.js changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 41 in applyTimestampsToUpdate.applyTimestampsToUpdate at line 16. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/helpers/update/applyTimestampsToUpdate.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/schemaType.js lib/schemaType.js:1306— lib/schemaType.js changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 16 in schemaType.SchemaType.getDefault at line 1306. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/schemaType.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/helpers/query/cast$expr.js lib/helpers/query/cast$expr.js:82— lib/helpers/query/cast$expr.js changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 24 in cast$expr._castExpression at line 82. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/helpers/query/cast$expr.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: lib/helpers/update/castArrayFilters.js lib/helpers/update/castArrayFilters.js:59— lib/helpers/update/castArrayFilters.js changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in castArrayFilters._castArrayFilters at line 59. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/helpers/update/castArrayFilters.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
FunctionTooLong: document.Document.$set lib/document.js:1103— FunctionTooLong — Document.$set runs 310 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 210 over it, 3.10× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: castUpdate.walkUpdatePath lib/helpers/query/castUpdate.js:222— FunctionTooLong — walkUpdatePath runs 187 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 87 over it, 1.87× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: model._insertMany lib/model.js:3089— FunctionTooLong — _insertMany runs 157 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 57 over it, 1.57× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: document._getPathsToValidate lib/document.js:3102— FunctionTooLong — _getPathsToValidate runs 150 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 50 over it, 1.50× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: queryHelpers.applyPaths lib/queryHelpers.js:139— FunctionTooLong — applyPaths runs 140 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 40 over it, 1.40× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: schema.Schema.interpretAsType lib/schema.js:1600— FunctionTooLong — Schema.interpretAsType runs 139 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 39 over it, 1.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: api.processFile docs/source/api.js:373— FunctionTooLong — processFile runs 136 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 36 over it, 1.36× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: document.Document.validate lib/document.js:2747— FunctionTooLong — Document.validate runs 135 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 35 over it, 1.35× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: model.Model.$__save lib/model.js:385— FunctionTooLong — Model.$__save runs 123 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 23 over it, 1.23× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: discriminator.discriminator lib/helpers/model/discriminator.js:70— FunctionTooLong — discriminator runs 121 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 21 over it, 1.21× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: connection.Connection.bulkWrite lib/connection.js:456— FunctionTooLong — Connection.bulkWrite runs 109 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 9 over it, 1.09× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: model.Model.create lib/model.js:2733— FunctionTooLong — Model.create runs 107 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 7 over it, 1.07× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: document.Document.$__delta lib/document.js:5406— FunctionTooLong — Document.$__delta runs 102 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 2 over it, 1.02× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: collection.iter lib/drivers/node-mongodb-native/collection.js:89— FunctionTooLong — iter runs 102 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 2 over it, 1.02× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
Boundary violation [package:third-party-deep-import] lib/cast/bigint.js:3— lib/cast/bigint.js:3 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/cast/double.js:4— lib/cast/double.js:4 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/cast/uuid.js:3— lib/cast/uuid.js:3 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/drivers/node-mongodb-native/bulkWriteResult.js:3— lib/drivers/node-mongodb-native/bulkWriteResult.js:3 imports mongodb/lib/bulk/common, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] REDACTED:14— REDACTED:14 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/helpers/common.js:7— lib/helpers/common.js:7 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/types/buffer.js:7— lib/types/buffer.js:7 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/types/buffer.js:8— lib/types/buffer.js:8 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/types/decimal128.js:13— lib/types/decimal128.js:13 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/types/double.js:13— lib/types/double.js:13 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/types/objectid.js:13— lib/types/objectid.js:13 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/types/uuid.js:13— lib/types/uuid.js:13 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] lib/utils.js:7— lib/utils.js:7 imports mongodb/lib/bson, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
FileTooLong: lib/document.js lib/document.js— FileTooLong — 2601 significant lines (blank, comment-only and punctuation-only lines excluded; the length bar is tripled for a single-responsibility module of 4 or fewer top-level units). The bar is 500 significant lines; this is 2101 over it, 5.20× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: lib/model.js lib/model.js— FileTooLong — 2157 significant lines (blank, comment-only and punctuation-only lines excluded; the length bar is tripled for a single-responsibility module of 4 or fewer top-level units). The bar is 500 significant lines; this is 1657 over it, 4.31× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: lib/query.js lib/query.js— FileTooLong — 1843 significant lines (blank, comment-only and punctuation-only lines excluded; the length bar is tripled for a single-responsibility module of 4 or fewer top-level units). The bar is 500 significant lines; this is 1343 over it, 3.69× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: lib/schema.js lib/schema.js— FileTooLong — 1407 significant lines (blank, comment-only and punctuation-only lines excluded; the length bar is tripled for a single-responsibility module of 4 or fewer top-level units). The bar is 500 significant lines; this is 907 over it, 2.81× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: lib/connection.js lib/connection.js— FileTooLong — 629 significant lines (blank, comment-only and punctuation-only lines excluded; the length bar is tripled for a single-responsibility module of 4 or fewer top-level units). The bar is 500 significant lines; this is 129 over it, 1.26× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: lib/schemaType.js lib/schemaType.js— FileTooLong — 609 significant lines (blank, comment-only and punctuation-only lines excluded; the length bar is tripled for a single-responsibility module of 4 or fewer top-level units). The bar is 500 significant lines; this is 109 over it, 1.22× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: populate/getModelsMapForPopulate.js lib/helpers/populate/getModelsMapForPopulate.js— FileTooLong — 561 significant lines (blank, comment-only and punctuation-only lines excluded; the length bar is tripled for a single-responsibility module of 4 or fewer top-level units). The bar is 500 significant lines; this is 61 over it, 1.12× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
AC6 · Visual & motion safety· Animation without a prefers-reduced-motion guard · ×6
Animation without a prefers-reduced-motion guard docs/css/copy-code.css:17— `.copy-btn` moves (`transition: opacity 0.18s ease, transform 0.18s ease, color 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard docs/css/mongoose9.css:449— `#theme-icon-light` moves (`transition: opacity 0.2s ease, transform 0.3s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard docs/css/mongoose9.css:555— `.version-picker-caret` moves (`transition: transform 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard docs/css/mongoose9.css:644— `.sidebar-section-caret` moves (`transition: transform 0.15s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard docs/css/style.css:39— `#theme-toggle-btn` moves (`transition: background-color 0.2s ease, transform 0.1s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard docs/css/style.css:58— `#theme-icon-light` moves (`transition: opacity 0.3s ease, transform 0.3s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Duplicated block (14 lines × 2 locations) lib/document.js:2431— lib/document.js:2431 · lib/document.js:2532 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2 locations) lib/model.js:3071— lib/model.js:3071 · lib/model.js:3464 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (14 lines × 2 locations) lib/query.js:2825— lib/query.js:2825 · lib/query.js:3765 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2 locations) lib/schema/string.js:596— lib/schema/string.js:596 · lib/schema/uuid.js:190 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it.
Duplicated block (14 lines × 2 locations) lib/schema/string.js:614— lib/schema/string.js:614 · lib/schemaType.js:1741 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (14 lines × 2 locations) lib/schemaType.js:570— lib/schemaType.js:570 · lib/schemaType.js:607 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (18 lines × 2 locations) lib/document.js:5261— lib/document.js:5261 · lib/document.js:5290 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2 locations) lib/helpers/update/applyTimestampsToUpdate.js:56— lib/helpers/update/applyTimestampsToUpdate.js:56 · lib/helpers/update/applyTimestampsToUpdate.js:104 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2 locations) lib/schema/boolean.js:88— lib/schema/boolean.js:88 · lib/schema/string.js:59 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it.
Duplicated block (18 lines × 2 locations) lib/types/subdocument.js:263— lib/types/subdocument.js:263 · lib/types/subdocument.js:295 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 2 locations) lib/helpers/model/castBulkWrite.js:147— lib/helpers/model/castBulkWrite.js:147 · lib/helpers/model/castBulkWrite.js:212 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 2 locations) lib/schema.js:209— lib/schema.js:209 · lib/schema.js:235 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 2 locations) lib/schema/date.js:267— lib/schema/date.js:267 · lib/schema/date.js:329 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (17 lines × 2 locations) lib/error/setOptionError.js:58— lib/error/setOptionError.js:58 · lib/error/validation.js:64 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (17 lines × 2 locations) lib/schema.js:2122— lib/schema.js:2122 · lib/schema.js:2184 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (17 lines × 2 locations) lib/types/documentArray/methods/index.js:92— lib/types/documentArray/methods/index.js:92 · lib/types/documentArray/methods/index.js:415 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2 locations) lib/query.js:1168— lib/query.js:1168 · lib/query.js:1186 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2 locations) lib/query.js:3290— lib/query.js:3290 · lib/query.js:3366 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (15 lines × 2 locations) lib/query.js:3758— lib/query.js:3758 · lib/query.js:3908 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
AC3 · Page structure· Heading level jumps from h1 to h3 · ×2
Heading level jumps from h1 to h3 docs/api_split.pug:42— Skipping heading levels breaks the document outline assistive tech relies on. Don't jump levels — increase by at most one.
Heading level jumps from h1 to h3 docs/sponsors.pug:13— Skipping heading levels breaks the document outline assistive tech relies on. Don't jump levels — increase by at most one.
AC6 · Visual & motion safety· Focus outline removed in CSS without a · ×2
Focus outline removed in CSS without a :focus replacement docs/css/mongoose9.css:1095— `.assistant-floating-input:focus` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible.
Focus outline removed in CSS without a :focus replacement docs/css/mongoose9.css:1364— `.assistant-panel-input:focus` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible.
Repeated repair: lib/helpers/model/castBulkWrite.js lib/helpers/model/castBulkWrite.js:24— lib/helpers/model/castBulkWrite.js changed 5 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is castBulkWrite.castBulkWrite at line 24), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(model): remove duplicate update declaration in bulkWrite”; “fix(model): don't mutate the caller's update object in bulkWrite updateMany”; “fix(model): cast array filter values in bulkWrite()”; “fix(query+model): replace {MODEL} in cast error messages from update and bulkWrite casting”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/helpers/model/castBulkWrite.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Repeated repair: lib/schema/documentArrayElement.js lib/schema/documentArrayElement.js:104— lib/schema/documentArrayElement.js changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 5 (its worst body is documentArrayElement.SchemaDocumentArrayElement.doValidate at line 104), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: handle validateAllPaths running validators on the element schematype”; “fix: avoid double-calling validators on document arrays underneath nested paths re: #5411”; “fix(schema): clone a document array element with its own constructor signature”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-25..2026-10-23, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-25 13:37:01 -04:00' --until='2026-10-23 13:37:01 -04:00' --full-history --no-merges -- lib/schema/documentArrayElement.js`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Outbound HTTP without resilience docs/js/ask-ai.js:85— `fetch(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
Outbound HTTP without resilience scripts/loadSponsorData.js:61— `fetch(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
Duplicated block (19 lines × 2 locations) lib/aggregate.js:249— lib/aggregate.js:249 · lib/aggregate.js:662 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (19 lines × 2 locations) lib/cursor/aggregationCursor.js:220— lib/cursor/aggregationCursor.js:220 · lib/cursor/queryCursor.js:215 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it.
Duplicated block (14 lines × 3 locations) lib/schema/number.js:73— lib/schema/number.js:73 · lib/schema/objectId.js:121 · lib/schema/string.js:53 — the 3 copies are spread across 3 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (14 lines × 3 locations) lib/schema/string.js:258— lib/schema/string.js:258 · lib/schema/string.js:297 · lib/schema/string.js:334 — all 3 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
X17 · Uncapped recursion over a caller-supplied document· Recursive walk over a caller-supplied document has no depth cap · ×2
Recursive walk over a caller-supplied document has no depth cap REDACTED:75— `clone` is exported and takes `obj: object` from its caller, and it calls itself at line 75 (`clone`) with a piece of `obj` — and nowhere in `clone` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. JavaScript sets no limit of its own on that nesting: `JSON.parse` accepts any depth, so a 100,000-byte body — inside Express's default 100kb limit — parses to 50,000 levels, and a walk like this one throws `RangeError: Maximum call stack size exceeded` long before it reaches the bottom. Wherever that throw lands, the work fails: a request errors, and a walk running outside any `try` — an event handler, a timer, a promise nobody awaits — takes the Node process down with every other request in flight. Thread a depth argument through `clone` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
Recursive walk over a caller-supplied document has no depth cap lib/helpers/document/applyTimestamps.js:70— `applyTimestamps` is exported, takes a document from its caller (line 19) and hands it to `applyTimestampsToDoc`, which calls itself at line 70 (`applyTimestampsToDoc`) with a piece of `obj` — and nowhere in `applyTimestampsToDoc` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. JavaScript sets no limit of its own on that nesting: `JSON.parse` accepts any depth, so a 100,000-byte body — inside Express's default 100kb limit — parses to 50,000 levels, and a walk like this one throws `RangeError: Maximum call stack size exceeded` long before it reaches the bottom. Wherever that throw lands, the work fails: a request errors, and a walk running outside any `try` — an event handler, a timer, a promise nobody awaits — takes the Node process down with every other request in flight. Thread a depth argument through `applyTimestampsToDoc` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
X2 · Cancellation propagation· Async function without AbortSignal · ×2
Async function without AbortSignal: submitQuestion docs/js/ask-ai.js:65— `submitQuestion` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
Async function without AbortSignal: run scripts/loadSponsorData.js:24— `run` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
AC3 · Page structure· Heading level jumps from h3 to h5 · ×1
Heading level jumps from h3 to h5 docs/api_split.pug:48— Skipping heading levels breaks the document outline assistive tech relies on. Don't jump levels — increase by at most one.
AC3 · Page structure· Page without a main landmark · ×1
Page without a main landmark index.pug:2— No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
AC7 · A11y enforcement· Accessibility enforcement below the top rung · ×1
Accessibility enforcement below the top rung — No accessibility enforcement found — no a11y linter (an a11y linter that can read your UI — no component framework was detected, so the JSX/Vue ESLint plugins would have nothing to lint; use an HTML-template a11y linter (html-eslint, htmlhint) or run axe/pa11y over the rendered pages) and no axe/pa11y/Lighthouse in tests or CI. Start with the linter to catch issues at author time. What was searched, so you can tell an absence from a miss: the 9 markup file(s) this pass actually assessed, the linter configuration checked in beside them, and this repository's test and CI files — matched by name against the accessibility checkers this dimension carries. An audit run outside the repository, a hosted scanner, or a check whose name is not one of those, is not seen here.
No authorization scripts/static.js:4— This repository serves requests — express() (scripts/static.js:4) — and no route guard, auth-gate middleware, global guard or imperative check that refuses a caller (401/403, an Unauthorized/Forbidden error) was found: its endpoints may be unprotected.
document.Document.$set (cyclomatic 177) lib/document.js:1103— document.Document.$set has cyclomatic complexity 177 (threshold 15). Of this number, 164 points are the body's own statements and 13 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
cast.cast (cyclomatic 103) lib/cast.js:38— cast.cast has cyclomatic complexity 103 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
walkUpdatePath (cyclomatic 96) lib/helpers/query/castUpdate.js:222— walkUpdatePath has cyclomatic complexity 96 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
_getPathsToValidate (cyclomatic 86) lib/document.js:3102— _getPathsToValidate has cyclomatic complexity 86 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
applyDefaults.applyDefaults (cyclomatic 76) lib/helpers/document/applyDefaults.js:5— applyDefaults.applyDefaults has cyclomatic complexity 76 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
interpretAsType (cyclomatic 76) lib/schema.js:1600— interpretAsType has cyclomatic complexity 76 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
_insertMany (cyclomatic 69) lib/model.js:3089— _insertMany has cyclomatic complexity 69 (threshold 15). Of this number, 55 points are the body's own statements and 14 belong to 8 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
model._populatePath (cyclomatic 61) lib/model.js:4574— model._populatePath has cyclomatic complexity 61 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document.validate (cyclomatic 60) lib/document.js:2747— document.Document.validate has cyclomatic complexity 60 (threshold 15). Of this number, 56 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
api.processFile (cyclomatic 59) docs/source/api.js:373— api.processFile has cyclomatic complexity 59 (threshold 15). Of this number, 58 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
add (cyclomatic 57) lib/schema.js:793— add has cyclomatic complexity 57 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
getModelsMapForPopulate (cyclomatic 57) lib/helpers/populate/getModelsMapForPopulate.js:25— getModelsMapForPopulate has cyclomatic complexity 57 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
getSchemaTypes.getSchemaTypes::search (cyclomatic 56) lib/helpers/populate/getSchemaTypes.js:49— getSchemaTypes.getSchemaTypes::search has cyclomatic complexity 56 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
model.Model.create (cyclomatic 55) lib/model.js:2733— model.Model.create has cyclomatic complexity 55 (threshold 15). Of this number, 46 points are the body's own statements and 9 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
$toObject (cyclomatic 54) lib/document.js:4221— $toObject has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.init (cyclomatic 52) lib/document.js:751— document.init has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
utils.deepEqual (cyclomatic 51) lib/utils.js:77— utils.deepEqual has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
castUpdate.castUpdate (cyclomatic 50) lib/helpers/query/castUpdate.js:51— castUpdate.castUpdate has cyclomatic complexity 50 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document.$__delta (cyclomatic 49) lib/document.js:5406— document.Document.$__delta has cyclomatic complexity 49 (threshold 15). Of this number, 43 points are the body's own statements and 6 belong to 4 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
updateValidators (cyclomatic 48) lib/helpers/updateValidators.js:23— updateValidators has cyclomatic complexity 48 (threshold 15). Of this number, 41 points are the body's own statements and 7 belong to 7 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
$__save (cyclomatic 47) lib/model.js:385— $__save has cyclomatic complexity 47 (threshold 15). Of this number, 46 points are the body's own statements and 1 belongs to 4 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
clone (cyclomatic 47) REDACTED:33— clone has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
schema.Schema.path (cyclomatic 44) lib/schema.js:1285— schema.Schema.path has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
applyTimestampsToUpdate (cyclomatic 42) lib/helpers/update/applyTimestampsToUpdate.js:16— applyTimestampsToUpdate has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document.$__set (cyclomatic 41) lib/document.js:1747— document.Document.$__set has cyclomatic complexity 41 (threshold 15). Of this number, 38 points are the body's own statements and 3 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document (cyclomatic 40) lib/document.js:92— document.Document has cyclomatic complexity 40 (threshold 15). Of this number, 36 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
schema.Schema.virtual (cyclomatic 39) lib/schema.js:2652— schema.Schema.virtual has cyclomatic complexity 39 (threshold 15). Of this number, 19 points are the body's own statements and 20 belong to 4 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
assignVals.assignVals (cyclomatic 39) lib/helpers/populate/assignVals.js:16— assignVals.assignVals has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (assignVals.assignVals::setValue) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
documentArray.SchemaDocumentArray.cast (cyclomatic 37) lib/schema/documentArray.js:404— documentArray.SchemaDocumentArray.cast has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
queryHelpers.applyPaths::analyzePath (cyclomatic 36) lib/queryHelpers.js:307— queryHelpers.applyPaths::analyzePath has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (queryHelpers.applyPaths) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
eachAsync.eachAsync (cyclomatic 36) lib/helpers/cursor/eachAsync.js:26— eachAsync.eachAsync has cyclomatic complexity 36 (threshold 15). Most of this is not in the body itself: 2 of the 36 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 88, a function literal at line 139, a function literal at line 36, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
getModelsMapForPopulate.getModelsMapForPopulate::_getModelNames (cyclomatic 36) lib/helpers/populate/getModelsMapForPopulate.js:226— getModelsMapForPopulate.getModelsMapForPopulate::_getModelNames has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
queryHelpers.applyPaths (cyclomatic 35) lib/queryHelpers.js:139— queryHelpers.applyPaths has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (queryHelpers.applyPaths::analyzePath) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
getIndexes.getIndexes::collectIndexes (cyclomatic 35) lib/helpers/schema/getIndexes.js:23— getIndexes.getIndexes::collectIndexes has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
mergeDiscriminatorSchema.mergeDiscriminatorSchema (cyclomatic 35) lib/helpers/discriminator/mergeDiscriminatorSchema.js:17— mergeDiscriminatorSchema.mergeDiscriminatorSchema has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
query.Query.setOptions (cyclomatic 35) lib/query.js:1739— query.Query.setOptions has cyclomatic complexity 35 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
cast (cyclomatic 35) lib/schema/array.js:333— cast has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity· iter (cyclomatic 34) · ×1
iter (cyclomatic 34) lib/drivers/node-mongodb-native/collection.js:89— iter has cyclomatic complexity 34 (threshold 15). Most of this is not in the body itself: 1 of the 34 points is its own statement and the rest belongs to 6 function literals inside it that branch (lines 90, 198, 207, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
model._execPopulateQuery (cyclomatic 33) lib/model.js:4804— model._execPopulateQuery has cyclomatic complexity 33 (threshold 15). Of this number, 30 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
castObject (cyclomatic 33) lib/model.js:3867— castObject has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
bulkWrite (cyclomatic 33) lib/connection.js:456— bulkWrite has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
model._ensureIndexes (cyclomatic 32) lib/model.js:1698— model._ensureIndexes has cyclomatic complexity 32 (threshold 15). Most of this is not in the body itself: 12 of the 32 points are its own statements and the rest belongs to 4 function items inside it that branch (create, done, a function literal at line 1758, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
mongoose.Mongoose.set (cyclomatic 32) lib/mongoose.js:256— mongoose.Mongoose.set has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
getsetOptions (cyclomatic 32) lib/mongoose.js:256— getsetOptions has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document.$__validateSync (cyclomatic 31) lib/document.js:3564— document.Document.$__validateSync has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
getModelsMapForPopulate._virtualPopulate (cyclomatic 31) lib/helpers/populate/getModelsMapForPopulate.js:487— getModelsMapForPopulate._virtualPopulate has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
validate (cyclomatic 31) lib/model.js:4360— validate has cyclomatic complexity 31 (threshold 15). Of this number, 23 points are the body's own statements and 8 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
buffer.SchemaBuffer.cast (cyclomatic 30) lib/schema/buffer.js:145— buffer.SchemaBuffer.cast has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
merge (cyclomatic 30) lib/query.js:2609— merge has cyclomatic complexity 30 (threshold 15). Of this number, 28 points are the body's own statements and 2 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document.get (cyclomatic 29) lib/document.js:1978— document.Document.get has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
_bulkWrite (cyclomatic 29) lib/model.js:3483— _bulkWrite has cyclomatic complexity 29 (threshold 15). Of this number, 26 points are the body's own statements and 3 belong to 15 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
_castExpression (cyclomatic 29) lib/helpers/query/cast$expr.js:82— _castExpression has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
castUpdate.castUpdateVal (cyclomatic 28) lib/helpers/query/castUpdate.js:586— castUpdate.castUpdateVal has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
getVirtual.getVirtual (cyclomatic 28) lib/helpers/populate/getVirtual.js:9— getVirtual.getVirtual has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
assignRawDocsToIdStructure.assignRawDocsToIdStructure (cyclomatic 27) lib/helpers/populate/assignRawDocsToIdStructure.js:34— assignRawDocsToIdStructure.assignRawDocsToIdStructure has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity· model (cyclomatic 27) · ×1
model (cyclomatic 27) lib/connection.js:1441— model has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
exports (cyclomatic 27) lib/helpers/setDefaultsOnInsert.js:17— exports has cyclomatic complexity 27 (threshold 15). Of this number, 19 points are the body's own statements and 8 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
schemaType.SchemaType (cyclomatic 26) lib/schemaType.js:43— schemaType.SchemaType has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
cast$expr.castComparison (cyclomatic 26) lib/helpers/query/cast$expr.js:216— cast$expr.castComparison has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
discriminator.discriminator::merge (cyclomatic 26) lib/helpers/model/discriminator.js:131— discriminator.discriminator::merge has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (discriminator.discriminator) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
schema.Schema._getSchema::search (cyclomatic 26) lib/schema.js:3044— schema.Schema._getSchema::search has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
createClient (cyclomatic 26) lib/drivers/node-mongodb-native/connection.js:232— createClient has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.operand (cyclomatic 25) lib/document.js:5626— document.operand has cyclomatic complexity 25 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
utils.merge (cyclomatic 25) lib/utils.js:285— utils.merge has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MongooseMap.set (cyclomatic 25) lib/types/map.js:90— MongooseMap.set has cyclomatic complexity 25 (threshold 15). Of this number, 23 points are the body's own statements and 2 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
setDefaultsOnInsert.default (cyclomatic 25) lib/helpers/setDefaultsOnInsert.js:17— setDefaultsOnInsert.default has cyclomatic complexity 25 (threshold 15). Of this number, 17 points are the body's own statements and 8 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
query.Query.sort (cyclomatic 25) lib/query.js:3169— query.Query.sort has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
model._assign (cyclomatic 25) lib/model.js:4928— model._assign has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
bulkSave (cyclomatic 25) lib/model.js:3651— bulkSave has cyclomatic complexity 25 (threshold 15). Of this number, 24 points are the body's own statements and 1 belongs to 6 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
_registerAtomic (cyclomatic 25) lib/types/array/methods/index.js:346— _registerAtomic has cyclomatic complexity 25 (threshold 15). Of this number, 23 points are the body's own statements and 2 belong to 4 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
compile.defineKey (cyclomatic 24) lib/helpers/document/compile.js:68— compile.defineKey has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 6 of the 24 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 121, 78, 183, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
applyTimestampsToChildren.applyTimestampsToUpdateKey (cyclomatic 24) lib/helpers/update/applyTimestampsToChildren.js:127— applyTimestampsToChildren.applyTimestampsToUpdateKey has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
query.Query.findOneAndUpdate (cyclomatic 24) lib/query.js:3518— query.Query.findOneAndUpdate has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
assignVals.valueFilter (cyclomatic 24) lib/helpers/populate/assignVals.js:267— assignVals.valueFilter has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
schemaType.SchemaType.doValidate (cyclomatic 23) lib/schemaType.js:1468— schemaType.SchemaType.doValidate has cyclomatic complexity 23 (threshold 15). Of this number, 19 points are the body's own statements and 4 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
castArrayFilters._castArrayFilters (cyclomatic 23) lib/helpers/update/castArrayFilters.js:59— castArrayFilters._castArrayFilters has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
connection._setClient (cyclomatic 23) lib/drivers/node-mongodb-native/connection.js:436— connection._setClient has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 9 of the 23 points are its own statements and the rest belongs to 4 function items inside it that branch (a function literal at line 484, a function literal at line 470, _handleReconnect, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
query.Query._optionsForExec (cyclomatic 23) lib/query.js:2133— query.Query._optionsForExec has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
addModelNamesToMap (cyclomatic 23) lib/helpers/populate/getModelsMapForPopulate.js:607— addModelNamesToMap has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
setupTimestamps (cyclomatic 23) lib/helpers/timestamps/setupTimestamps.js:14— setupTimestamps has cyclomatic complexity 23 (threshold 15). Of this number, 12 points are the body's own statements and 11 belong to 2 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
isIndexEqual (cyclomatic 23) lib/helpers/indexes/isIndexEqual.js:18— isIndexEqual has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
index.MongooseDocumentArray (cyclomatic 22) lib/types/documentArray/index.js:30— index.MongooseDocumentArray has cyclomatic complexity 22 (threshold 15). Most of this is not in the body itself: 8 of the 22 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 69, 91). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
document.Document.isSelected (cyclomatic 22) lib/document.js:2563— document.Document.isSelected has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document.depopulate (cyclomatic 22) lib/document.js:5236— document.Document.depopulate has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
index.MongooseArray (cyclomatic 22) lib/types/array/index.js:32— index.MongooseArray has cyclomatic complexity 22 (threshold 15). Most of this is not in the body itself: 10 of the 22 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 81, 97). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
getEmbeddedDiscriminatorPath.getEmbeddedDiscriminatorPath (cyclomatic 22) lib/helpers/query/getEmbeddedDiscriminatorPath.js:20— getEmbeddedDiscriminatorPath.getEmbeddedDiscriminatorPath has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
queryCursor._next (cyclomatic 22) lib/cursor/queryCursor.js:465— queryCursor._next has cyclomatic complexity 22 (threshold 15). Of this number, 12 points are the body's own statements and 10 belong to 4 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
createCollection (cyclomatic 22) lib/model.js:1222— createCollection has cyclomatic complexity 22 (threshold 15). Of this number, 21 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
collection.format (cyclomatic 21) lib/drivers/node-mongodb-native/collection.js:340— collection.format has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: collection.iter (cyclomatic 34) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
document.applyVirtuals (cyclomatic 21) lib/document.js:4548— document.applyVirtuals has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
discriminator.discriminator (cyclomatic 21) lib/helpers/model/discriminator.js:70— discriminator.discriminator has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (discriminator.discriminator::merge) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
query.Query.select (cyclomatic 21) lib/query.js:1140— query.Query.select has cyclomatic complexity 21 (threshold 15). Of this number, 13 points are the body's own statements and 8 belong to 5 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
mongoose.Mongoose.model (cyclomatic 21) lib/mongoose.js:591— mongoose.Mongoose.model has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
document.applyGetters (cyclomatic 20) lib/document.js:4637— document.applyGetters has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.checkDivergentArray (cyclomatic 20) lib/document.js:5568— document.checkDivergentArray has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
applyTimestampsToChildren.applyTimestampsToChildren (cyclomatic 20) lib/helpers/update/applyTimestampsToChildren.js:12— applyTimestampsToChildren.applyTimestampsToChildren has cyclomatic complexity 20 (threshold 15). Of this number, 10 points are the body's own statements and 10 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
array.SchemaArray (cyclomatic 20) lib/schema/array.js:45— array.SchemaArray has cyclomatic complexity 20 (threshold 15). Of this number, 18 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
query.Query.orFail (cyclomatic 20) lib/query.js:4690— query.Query.orFail has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 1 of the 20 points is its own statement and the rest belongs to one function literal inside it that branches (line 4691). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
applyVirtuals.applyVirtualsToDoc (cyclomatic 20) lib/helpers/document/applyVirtuals.js:94— applyVirtuals.applyVirtualsToDoc has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
_getModelNamesFromFunctionRefPath::walkSubdocs (cyclomatic 20) lib/helpers/populate/getModelsMapForPopulate.js:384— _getModelNamesFromFunctionRefPath::walkSubdocs has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
_cast (cyclomatic 20) lib/types/documentArray/methods/index.js:60— _cast has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity· id (cyclomatic 20) · ×1
id (cyclomatic 20) lib/types/documentArray/methods/index.js:132— id has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
schemaType.SchemaType.required (cyclomatic 19) lib/schemaType.js:1139— schemaType.SchemaType.required has cyclomatic complexity 19 (threshold 15). Of this number, 13 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
query.Query.exec (cyclomatic 19) lib/query.js:4778— query.Query.exec has cyclomatic complexity 19 (threshold 15). Of this number, 13 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
model.Model.discriminator (cyclomatic 19) lib/model.js:1000— model.Model.discriminator has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
website.renderFile (cyclomatic 19) scripts/website.js:464— website.renderFile has cyclomatic complexity 19 (threshold 15). Of this number, 18 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
document.Document.$__shouldModify (cyclomatic 18) lib/document.js:1683— document.Document.$__shouldModify has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
schemaType.SchemaType.doValidateSync (cyclomatic 18) lib/schemaType.js:1581— schemaType.SchemaType.doValidateSync has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
common.flatten (cyclomatic 18) lib/helpers/common.js:20— common.flatten has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
query.Query.near (cyclomatic 18) lib/query.js:5595— query.Query.near has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
assignVals.assignVals::setValue (cyclomatic 18) lib/helpers/populate/assignVals.js:44— assignVals.assignVals::setValue has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (assignVals.assignVals) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
getDefault (cyclomatic 18) lib/schemaType.js:1306— getDefault has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
clone.cloneObject (cyclomatic 17) REDACTED:160— clone.cloneObject has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
number.SchemaNumber.enum (cyclomatic 17) lib/schema/number.js:318— number.SchemaNumber.enum has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
documentArray.SchemaDocumentArray.doValidate (cyclomatic 17) lib/schema/documentArray.js:233— documentArray.SchemaDocumentArray.doValidate has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
schema.Schema (cyclomatic 17) lib/schema.js:110— schema.Schema has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
schema.Schema.set (cyclomatic 17) lib/schema.js:2487— schema.Schema.set has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
sanitizeFilter.sanitizeFilter (cyclomatic 17) lib/helpers/query/sanitizeFilter.js:7— sanitizeFilter.sanitizeFilter has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
createPopulateQueryFilter.createPopulateQueryFilter (cyclomatic 17) lib/helpers/populate/createPopulateQueryFilter.js:8— createPopulateQueryFilter.createPopulateQueryFilter has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
virtual::virtualPreInit (cyclomatic 17) lib/schema.js:2676— virtual::virtualPreInit has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
(anonymous) (cyclomatic 17) lib/schema/number.js:318— (anonymous) has cyclomatic complexity 17 (threshold 15). Of this number, 16 points are the body's own statements and 1 belongs to 5 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
applyWriteConcern (cyclomatic 17) lib/helpers/schema/applyWriteConcern.js:5— applyWriteConcern has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document.$__buildDoc (cyclomatic 16) lib/document.js:563— document.Document.$__buildDoc has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
document.Document.$getAllSubdocs (cyclomatic 16) lib/document.js:4129— document.Document.$getAllSubdocs has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 6 of the 16 points are its own statements and the rest belongs to one function item inside it that branches (getSubdocs). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
modelNamesFromRefPath.modelNamesFromRefPath (cyclomatic 16) lib/helpers/populate/modelNamesFromRefPath.js:12— modelNamesFromRefPath.modelNamesFromRefPath has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
schema.getPositionalPathType (cyclomatic 16) lib/schema.js:2034— schema.getPositionalPathType has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
schema.Schema._getPathType (cyclomatic 16) lib/schema.js:3141— schema.Schema._getPathType has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 2 of the 16 points are its own statements and the rest belongs to one function item inside it that branches (search). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
castUpdate.castPipelineOperator (cyclomatic 16) lib/helpers/query/castUpdate.js:177— castUpdate.castPipelineOperator has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
query.Query._find (cyclomatic 16) lib/query.js:2457— query.Query._find has cyclomatic complexity 16 (threshold 15). Of this number, 15 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
query.Query._mergeUpdate (cyclomatic 16) lib/query.js:4145— query.Query._mergeUpdate has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
stringifyFunctionOperators.stringifyFunctionOperators (cyclomatic 16) lib/helpers/aggregate/stringifyFunctionOperators.js:3— stringifyFunctionOperators.stringifyFunctionOperators has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
model.Model.translateAliases (cyclomatic 16) lib/model.js:1947— model.Model.translateAliases has cyclomatic complexity 16 (threshold 15). Of this number, 8 points are the body's own statements and 8 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
api.buildMarkdown (cyclomatic 16) docs/source/api.js:280— api.buildMarkdown has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
toString (cyclomatic 16) lib/query.js:1377— toString has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
Deprecated: lodash.isequal package.json:51— lodash.isequal 4.5.0, declared in package.json, is marked deprecated by its publisher: "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.". Replace it with the package or version that message names, or record why this one must stay.
cast (cognitive 305) lib/cast.js:38— cast has cognitive complexity 305 (threshold 15). Drivers by points: if/else 70 (236 pts), loops 7 (30 pts), boolean chains 24, ternaries 3 (15 pts) (nesting depth added 201). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
$set (cognitive 274) lib/document.js:1103— $set has cognitive complexity 274 (threshold 15). Drivers by points: if/else 84 (150 pts), boolean chains 61, ternaries 17 (37 pts), loops 11 (25 pts), error handling 1 (nesting depth added 100). Of this number, 260 points are the body's own statements and 14 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
walkUpdatePath (cognitive 238) lib/helpers/query/castUpdate.js:222— walkUpdatePath has cognitive complexity 238 (threshold 15). Drivers by points: if/else 52 (156 pts), error handling 8 (38 pts), boolean chains 28, ternaries 5 (14 pts), loops 1, other 1 (nesting depth added 143). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
applyDefaults (cognitive 189) lib/helpers/document/applyDefaults.js:5— applyDefaults has cognitive complexity 189 (threshold 15). Drivers by points: if/else 42 (137 pts), boolean chains 26, error handling 4 (20 pts), loops 2 (3 pts), ternaries 1 (3 pts) (nesting depth added 114). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
_getPathsToValidate (cognitive 172) lib/document.js:3102— _getPathsToValidate has cognitive complexity 172 (threshold 15). Drivers by points: if/else 39 (100 pts), boolean chains 27, loops 13 (25 pts), ternaries 5 (15 pts), error handling 1 (4 pts), other 1 (nesting depth added 86). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
getSchemaTypes::search (cognitive 171) lib/helpers/populate/getSchemaTypes.js:49— getSchemaTypes::search has cognitive complexity 171 (threshold 15). Drivers by points: if/else 24 (85 pts), ternaries 11 (55 pts), boolean chains 15, loops 4 (15 pts), other 1 (nesting depth added 116). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
interpretAsType (cognitive 133) lib/schema.js:1600— interpretAsType has cognitive complexity 133 (threshold 15). Drivers by points: if/else 47 (100 pts), boolean chains 18, ternaries 6 (13 pts), other 2 (nesting depth added 60). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
updateValidators (cognitive 119) lib/helpers/updateValidators.js:23— updateValidators has cognitive complexity 119 (threshold 15). Drivers by points: if/else 23 (62 pts), loops 7 (19 pts), error handling 5 (18 pts), boolean chains 13, ternaries 2 (7 pts) (nesting depth added 69). Of this number, 92 points are the body's own statements and 27 belong to 7 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_insertMany (cognitive 111) lib/model.js:3089— _insertMany has cognitive complexity 111 (threshold 15). Drivers by points: if/else 37 (70 pts), loops 6 (14 pts), boolean chains 12, ternaries 8 (9 pts), error handling 4 (6 pts) (nesting depth added 44). Of this number, 87 points are the body's own statements and 24 belong to 8 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
add (cognitive 107) lib/schema.js:793— add has cognitive complexity 107 (threshold 15). Drivers by points: if/else 31 (73 pts), boolean chains 19, loops 4 (13 pts), other 2 (nesting depth added 51). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model._populatePath (cognitive 106) lib/model.js:4574— model._populatePath has cognitive complexity 106 (threshold 15). Drivers by points: if/else 33 (62 pts), loops 12 (24 pts), ternaries 4 (11 pts), boolean chains 9 (nesting depth added 48). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
$__save (cognitive 102) lib/model.js:385— $__save has cognitive complexity 102 (threshold 15). Drivers by points: if/else 21 (55 pts), ternaries 11 (20 pts), boolean chains 11, loops 2 (9 pts), error handling 4 (7 pts) (nesting depth added 53). Of this number, 99 points are the body's own statements and 3 belong to 4 function literals inside it that branch. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
getModelsMapForPopulate (cognitive 102) lib/helpers/populate/getModelsMapForPopulate.js:25— getModelsMapForPopulate has cognitive complexity 102 (threshold 15). Drivers by points: if/else 49 (94 pts), boolean chains 27, ternaries 8 (21 pts), error handling 4 (13 pts), loops 4 (12 pts), other 2 (nesting depth added 75). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
$__delta (cognitive 100) lib/document.js:5406— $__delta has cognitive complexity 100 (threshold 15). Drivers by points: if/else 32 (59 pts), ternaries 9 (29 pts), boolean chains 9, loops 2 (3 pts) (nesting depth added 48). Of this number, 86 points are the body's own statements and 14 belong to 5 function literals inside it that branch. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
api.processFile (cognitive 96) docs/source/api.js:373— api.processFile has cognitive complexity 96 (threshold 15). Drivers by points: if/else 26 (72 pts), boolean chains 13, loops 3 (8 pts), match/switch 1 (3 pts) (nesting depth added 53). Of this number, 94 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
init (cognitive 93) lib/document.js:751— init has cognitive complexity 93 (threshold 15). Drivers by points: if/else 30 (64 pts), boolean chains 17, ternaries 2 (6 pts), error handling 1 (5 pts), loops 1 (nesting depth added 42). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
_getSchema::search (cognitive 88) lib/schema.js:3044— _getSchema::search has cognitive complexity 88 (threshold 15). Drivers by points: if/else 15 (66 pts), ternaries 2 (15 pts), boolean chains 6, loops 1 (nesting depth added 64). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
create (cognitive 87) lib/model.js:2733— create has cognitive complexity 87 (threshold 15). Drivers by points: if/else 25 (45 pts), boolean chains 19, ternaries 8 (16 pts), error handling 2 (5 pts), loops 1 (2 pts) (nesting depth added 32). Of this number, 64 points are the body's own statements and 23 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
validate (cognitive 79) lib/document.js:2747— validate has cognitive complexity 79 (threshold 15). Drivers by points: if/else 36 (52 pts), boolean chains 17, ternaries 4 (7 pts), loops 2, error handling 1 (nesting depth added 19). Of this number, 75 points are the body's own statements and 4 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cast (cognitive 77) lib/schema/array.js:333— cast has cognitive complexity 77 (threshold 15). Drivers by points: if/else 17 (47 pts), boolean chains 11, loops 3 (10 pts), ternaries 2 (5 pts), error handling 1 (3 pts), other 1 (nesting depth added 42). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
assignVals (cognitive 75) lib/helpers/populate/assignVals.js:16— assignVals has cognitive complexity 75 (threshold 15). Drivers by points: if/else 29 (62 pts), ternaries 7 (19 pts), boolean chains 17, loops 6 (12 pts) (nesting depth added 51). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
schema.Schema.virtual (cognitive 74) lib/schema.js:2652— schema.Schema.virtual has cognitive complexity 74 (threshold 15). Drivers by points: if/else 22 (47 pts), ternaries 2 (11 pts), boolean chains 8, loops 3 (8 pts) (nesting depth added 39). Of this number, 29 points are the body's own statements and 45 belong to 4 function literals inside it that branch. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
_assign (cognitive 74) lib/model.js:4928— _assign has cognitive complexity 74 (threshold 15). Drivers by points: if/else 16 (49 pts), ternaries 3 (13 pts), loops 3 (7 pts), boolean chains 5 (nesting depth added 47). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
$__set (cognitive 73) lib/document.js:1747— $__set has cognitive complexity 73 (threshold 15). Drivers by points: if/else 26 (52 pts), boolean chains 10, ternaries 4 (10 pts), loops 1 (nesting depth added 32). Of this number, 69 points are the body's own statements and 4 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
clone (cognitive 73) REDACTED:33— clone has cognitive complexity 73 (threshold 15). Drivers by points: if/else 27 (51 pts), boolean chains 13, loops 1 (4 pts), other 3, match/switch 1 (2 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
getIndexes::collectIndexes (cognitive 73) lib/helpers/schema/getIndexes.js:23— getIndexes::collectIndexes has cognitive complexity 73 (threshold 15). Drivers by points: if/else 21 (43 pts), ternaries 4 (13 pts), boolean chains 12, loops 2 (5 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bulkWrite (cognitive 71) lib/connection.js:456— bulkWrite has cognitive complexity 71 (threshold 15). Drivers by points: if/else 19 (43 pts), error handling 3 (8 pts), boolean chains 7, ternaries 3 (7 pts), loops 3 (6 pts) (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
getVirtual (cognitive 71) lib/helpers/populate/getVirtual.js:9— getVirtual has cognitive complexity 71 (threshold 15). Drivers by points: if/else 16 (47 pts), loops 4 (12 pts), ternaries 3 (8 pts), boolean chains 4 (nesting depth added 44). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
documentArray.SchemaDocumentArray.cast (cognitive 69) lib/schema/documentArray.js:404— documentArray.SchemaDocumentArray.cast has cognitive complexity 69 (threshold 15). Drivers by points: if/else 23 (49 pts), boolean chains 13, error handling 1 (5 pts), loops 1, ternaries 1 (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
depopulate (cognitive 69) lib/document.js:5236— depopulate has cognitive complexity 69 (threshold 15). Drivers by points: if/else 15 (38 pts), loops 5 (15 pts), ternaries 4 (15 pts), boolean chains 1 (nesting depth added 44). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
applyTimestampsToUpdate (cognitive 69) lib/helpers/update/applyTimestampsToUpdate.js:16— applyTimestampsToUpdate has cognitive complexity 69 (threshold 15). Drivers by points: if/else 24 (49 pts), boolean chains 12, loops 2 (7 pts), other 1 (nesting depth added 30). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
castObject (cognitive 68) lib/model.js:3867— castObject has cognitive complexity 68 (threshold 15). Drivers by points: if/else 16 (41 pts), boolean chains 8, loops 4 (7 pts), ternaries 2 (6 pts), error handling 2 (5 pts), other 1 (nesting depth added 35). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
path (cognitive 68) lib/schema.js:1285— path has cognitive complexity 68 (threshold 15). Drivers by points: if/else 20 (34 pts), loops 10 (19 pts), boolean chains 9, ternaries 4 (6 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
getModelsMapForPopulate.getModelsMapForPopulate::_getModelNames (cognitive 67) lib/helpers/populate/getModelsMapForPopulate.js:226— getModelsMapForPopulate.getModelsMapForPopulate::_getModelNames has cognitive complexity 67 (threshold 15). Drivers by points: if/else 27 (43 pts), ternaries 2 (9 pts), boolean chains 7, error handling 1 (4 pts), loops 1 (4 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyPaths (cognitive 65) lib/queryHelpers.js:139— applyPaths has cognitive complexity 65 (threshold 15). Drivers by points: if/else 38 (72 pts), boolean chains 25, loops 10 (18 pts), ternaries 3 (6 pts), match/switch 1 (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
castUpdate (cognitive 61) lib/helpers/query/castUpdate.js:51— castUpdate has cognitive complexity 61 (threshold 15). Drivers by points: if/else 20 (33 pts), boolean chains 21, loops 4 (7 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
$toObject (cognitive 60) lib/document.js:4221— $toObject has cognitive complexity 60 (threshold 15). Drivers by points: if/else 24 (34 pts), boolean chains 10, loops 3 (8 pts), other 6, ternaries 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
mergeDiscriminatorSchema (cognitive 59) lib/helpers/discriminator/mergeDiscriminatorSchema.js:17— mergeDiscriminatorSchema has cognitive complexity 59 (threshold 15). Drivers by points: if/else 19 (45 pts), boolean chains 10, ternaries 1 (3 pts), loops 1 (nesting depth added 28). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity· iter (cognitive 58) · ×1
iter (cognitive 58) lib/drivers/node-mongodb-native/collection.js:89— iter has cognitive complexity 58 (threshold 15). Drivers by points: if/else 27 (43 pts), ternaries 4 (10 pts), boolean chains 4, error handling 1 (nesting depth added 22). None of this is in the body itself: all 58 points belong to 6 function literals inside it that branch (lines 90, 198, 207, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
_bulkWrite (cognitive 55) lib/model.js:3483— _bulkWrite has cognitive complexity 55 (threshold 15). Drivers by points: if/else 21 (38 pts), error handling 3 (5 pts), loops 2 (5 pts), boolean chains 4, ternaries 2, other 1 (nesting depth added 22). Of this number, 46 points are the body's own statements and 9 belong to 15 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.deepEqual (cognitive 54) lib/utils.js:77— utils.deepEqual has cognitive complexity 54 (threshold 15). Drivers by points: if/else 25 (34 pts), boolean chains 16, loops 3 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SchemaType (cognitive 54) lib/schemaType.js:43— SchemaType has cognitive complexity 54 (threshold 15). Drivers by points: if/else 14 (40 pts), boolean chains 7, ternaries 3 (5 pts), loops 2 (nesting depth added 28). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
castComparison (cognitive 54) lib/helpers/query/cast$expr.js:216— castComparison has cognitive complexity 54 (threshold 15). Drivers by points: if/else 17 (35 pts), boolean chains 8, error handling 2 (8 pts), loops 1 (3 pts) (nesting depth added 26). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
castArrayFilters._castArrayFilters (cognitive 52) lib/helpers/update/castArrayFilters.js:59— castArrayFilters._castArrayFilters has cognitive complexity 52 (threshold 15). Drivers by points: if/else 13 (31 pts), ternaries 4 (11 pts), loops 3 (6 pts), boolean chains 4 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
mongoose.Mongoose.set (cognitive 52) lib/mongoose.js:256— mongoose.Mongoose.set has cognitive complexity 52 (threshold 15). Drivers by points: if/else 22 (40 pts), boolean chains 7, ternaries 2 (4 pts), loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
getsetOptions (cognitive 52) lib/mongoose.js:256— getsetOptions has cognitive complexity 52 (threshold 15). Drivers by points: if/else 22 (40 pts), boolean chains 7, ternaries 2 (4 pts), loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
assignRawDocsToIdStructure.assignRawDocsToIdStructure (cognitive 50) lib/helpers/populate/assignRawDocsToIdStructure.js:34— assignRawDocsToIdStructure.assignRawDocsToIdStructure has cognitive complexity 50 (threshold 15). Drivers by points: if/else 18 (35 pts), boolean chains 7, ternaries 2 (5 pts), loops 2 (3 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_virtualPopulate (cognitive 49) lib/helpers/populate/getModelsMapForPopulate.js:487— _virtualPopulate has cognitive complexity 49 (threshold 15). Drivers by points: if/else 17 (29 pts), boolean chains 9, ternaries 2 (5 pts), loops 2 (4 pts), error handling 1 (2 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
getEmbeddedDiscriminatorPath.getEmbeddedDiscriminatorPath (cognitive 48) lib/helpers/query/getEmbeddedDiscriminatorPath.js:20— getEmbeddedDiscriminatorPath.getEmbeddedDiscriminatorPath has cognitive complexity 48 (threshold 15). Drivers by points: if/else 12 (37 pts), boolean chains 5, loops 2 (4 pts), ternaries 2 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
validate (cognitive 48) lib/model.js:4360— validate has cognitive complexity 48 (threshold 15). Drivers by points: if/else 13 (26 pts), boolean chains 9, loops 4 (6 pts), ternaries 2 (4 pts), error handling 2 (3 pts) (nesting depth added 18). Of this number, 28 points are the body's own statements and 20 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
eachAsync.eachAsync (cognitive 47) lib/helpers/cursor/eachAsync.js:26— eachAsync.eachAsync has cognitive complexity 47 (threshold 15). Drivers by points: if/else 27 (32 pts), boolean chains 7, ternaries 3 (6 pts), error handling 1, loops 1 (nesting depth added 8). Most of this is not in the body itself: 1 of the 47 points is its own statement and the rest belongs to 8 function items inside it that branch (a function literal at line 88, a function literal at line 139, a function literal at line 36, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
Document (cognitive 47) lib/document.js:92— Document has cognitive complexity 47 (threshold 15). Drivers by points: if/else 23 (29 pts), boolean chains 13, ternaries 3 (4 pts), loops 1 (nesting depth added 7). Of this number, 42 points are the body's own statements and 5 belong to one function literal inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
query.Query._optionsForExec (cognitive 46) lib/query.js:2133— query.Query._optionsForExec has cognitive complexity 46 (threshold 15). Drivers by points: if/else 17 (37 pts), loops 2 (6 pts), boolean chains 3 (nesting depth added 24). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
$__validateSync (cognitive 46) lib/document.js:3564— $__validateSync has cognitive complexity 46 (threshold 15). Drivers by points: if/else 17 (27 pts), boolean chains 8, ternaries 4 (8 pts), loops 2 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model._execPopulateQuery (cognitive 45) lib/model.js:4804— model._execPopulateQuery has cognitive complexity 45 (threshold 15). Drivers by points: if/else 22 (32 pts), loops 4 (7 pts), boolean chains 6 (nesting depth added 13). Of this number, 42 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_castExpression (cognitive 45) lib/helpers/query/cast$expr.js:82— _castExpression has cognitive complexity 45 (threshold 15). Drivers by points: if/else 23 (39 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
buffer.SchemaBuffer.cast (cognitive 44) lib/schema/buffer.js:145— buffer.SchemaBuffer.cast has cognitive complexity 44 (threshold 15). Drivers by points: if/else 21 (39 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document.Document.modifiedPaths (cognitive 43) lib/document.js:2277— document.Document.modifiedPaths has cognitive complexity 43 (threshold 15). Drivers by points: if/else 7 (22 pts), loops 5 (18 pts), boolean chains 3 (nesting depth added 28). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
query.Query.select (cognitive 43) lib/query.js:1140— query.Query.select has cognitive complexity 43 (threshold 15). Drivers by points: if/else 17 (34 pts), boolean chains 5, loops 1 (3 pts), ternaries 1 (nesting depth added 19). Of this number, 17 points are the body's own statements and 26 belong to 5 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
setOptions (cognitive 43) lib/query.js:1739— setOptions has cognitive complexity 43 (threshold 15). Drivers by points: if/else 24 (27 pts), boolean chains 6, error handling 2 (4 pts), loops 2 (3 pts), ternaries 1 (3 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
merge (cognitive 43) lib/query.js:2609— merge has cognitive complexity 43 (threshold 15). Drivers by points: if/else 16 (28 pts), boolean chains 10, ternaries 2 (4 pts), other 1 (nesting depth added 14). Of this number, 39 points are the body's own statements and 4 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sort (cognitive 43) lib/query.js:3169— sort has cognitive complexity 43 (threshold 15). Drivers by points: if/else 15 (27 pts), loops 4 (8 pts), ternaries 2 (5 pts), boolean chains 3 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.merge (cognitive 42) lib/utils.js:285— utils.merge has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (30 pts), boolean chains 8, ternaries 1 (3 pts), loops 1 (nesting depth added 17). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
model._ensureIndexes (cognitive 42) lib/model.js:1698— model._ensureIndexes has cognitive complexity 42 (threshold 15). Drivers by points: if/else 16 (24 pts), boolean chains 10, loops 3 (5 pts), ternaries 2, error handling 1 (nesting depth added 10). Of this number, 18 points are the body's own statements and 24 belong to 4 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_getModelNamesFromFunctionRefPath::walkSubdocs (cognitive 42) lib/helpers/populate/getModelsMapForPopulate.js:384— _getModelNamesFromFunctionRefPath::walkSubdocs has cognitive complexity 42 (threshold 15). Drivers by points: if/else 10 (20 pts), ternaries 3 (11 pts), loops 3 (8 pts), boolean chains 2, other 1 (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
document.applyGetters (cognitive 41) lib/document.js:4637— document.applyGetters has cognitive complexity 41 (threshold 15). Drivers by points: if/else 11 (24 pts), loops 4 (12 pts), boolean chains 5 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bulkSave (cognitive 40) lib/model.js:3651— bulkSave has cognitive complexity 40 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 4 (10 pts), boolean chains 6, ternaries 2 (6 pts), other 2 (nesting depth added 15). Of this number, 37 points are the body's own statements and 3 belong to 6 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
valueFilter (cognitive 40) lib/helpers/populate/assignVals.js:267— valueFilter has cognitive complexity 40 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 4 (10 pts), ternaries 4 (9 pts), boolean chains 6 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
castUpdateVal (cognitive 39) lib/helpers/query/castUpdate.js:586— castUpdateVal has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (17 pts), loops 4 (8 pts), boolean chains 7, error handling 2 (5 pts), ternaries 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_next (cognitive 39) lib/cursor/queryCursor.js:465— _next has cognitive complexity 39 (threshold 15). Drivers by points: if/else 21 (35 pts), boolean chains 4 (nesting depth added 14). Of this number, 17 points are the body's own statements and 22 belong to 12 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyDefaultsToPOJO (cognitive 39) lib/helpers/model/applyDefaultsToPOJO.js:3— applyDefaultsToPOJO has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (31 pts), loops 2 (3 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document.Document.get (cognitive 38) lib/document.js:1978— document.Document.get has cognitive complexity 38 (threshold 15). Drivers by points: if/else 19 (26 pts), ternaries 4 (6 pts), boolean chains 5, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
addModelNamesToMap (cognitive 38) lib/helpers/populate/getModelsMapForPopulate.js:607— addModelNamesToMap has cognitive complexity 38 (threshold 15). Drivers by points: if/else 13 (24 pts), boolean chains 5, ternaries 2 (4 pts), error handling 1 (3 pts), loops 1, other 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyPaths::analyzePath (cognitive 38) lib/queryHelpers.js:307— applyPaths::analyzePath has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 12, ternaries 3 (6 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_registerAtomic (cognitive 37) lib/types/array/methods/index.js:346— _registerAtomic has cognitive complexity 37 (threshold 15). Drivers by points: if/else 16 (22 pts), boolean chains 11, loops 1 (4 pts) (nesting depth added 9). Of this number, 33 points are the body's own statements and 4 belong to 4 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity· set (cognitive 37) · ×1
set (cognitive 37) lib/types/map.js:90— set has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (24 pts), boolean chains 8, ternaries 2 (3 pts), error handling 1 (2 pts) (nesting depth added 12). Of this number, 33 points are the body's own statements and 4 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyTimestampsToUpdateKey (cognitive 37) lib/helpers/update/applyTimestampsToChildren.js:127— applyTimestampsToUpdateKey has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (24 pts), boolean chains 6, ternaries 1 (4 pts), loops 2 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
exports (cognitive 37) lib/helpers/setDefaultsOnInsert.js:17— exports has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 7, loops 4 (7 pts), ternaries 1 (2 pts), other 1 (nesting depth added 12). Of this number, 29 points are the body's own statements and 8 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
isIndexEqual (cognitive 37) lib/helpers/indexes/isIndexEqual.js:18— isIndexEqual has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (25 pts), loops 4 (7 pts), boolean chains 3, other 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
schemaType.SchemaType.doValidate (cognitive 36) lib/schemaType.js:1468— schemaType.SchemaType.doValidate has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (23 pts), boolean chains 8, error handling 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 13). Of this number, 30 points are the body's own statements and 6 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
array.SchemaArray (cognitive 36) lib/schema/array.js:45— array.SchemaArray has cognitive complexity 36 (threshold 15). Drivers by points: if/else 14 (24 pts), ternaries 4 (9 pts), boolean chains 3 (nesting depth added 15). Of this number, 31 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
setDefaultsOnInsert.default (cognitive 36) lib/helpers/setDefaultsOnInsert.js:17— setDefaultsOnInsert.default has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 7, loops 4 (7 pts), ternaries 1 (2 pts) (nesting depth added 12). Of this number, 28 points are the body's own statements and 8 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PathTrie._walk (cognitive 35) lib/helpers/pathTrie.js:114— PathTrie._walk has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (30 pts), loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
schema.Schema._getPathType::search (cognitive 35) lib/schema.js:3149— schema.Schema._getPathType::search has cognitive complexity 35 (threshold 15). Drivers by points: if/else 7 (25 pts), boolean chains 5, ternaries 1 (4 pts), loops 1 (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
virtual::virtualPreInit (cognitive 34) lib/schema.js:2676— virtual::virtualPreInit has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (17 pts), ternaries 3 (9 pts), boolean chains 4, loops 1 (4 pts) (nesting depth added 18). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
createClient (cognitive 34) lib/drivers/node-mongodb-native/connection.js:232— createClient has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (26 pts), boolean chains 5, error handling 1, loops 1, other 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
collection.format (cognitive 33) lib/drivers/node-mongodb-native/collection.js:340— collection.format has cognitive complexity 33 (threshold 15). Drivers by points: if/else 16 (24 pts), error handling 1 (5 pts), loops 1 (2 pts), boolean chains 1, ternaries 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document.applyVirtuals (cognitive 33) lib/document.js:4548— document.applyVirtuals has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 5, loops 3 (5 pts), ternaries 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyVirtualsToDoc (cognitive 33) lib/helpers/document/applyVirtuals.js:94— applyVirtualsToDoc has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 4 (7 pts), ternaries 3 (7 pts), boolean chains 4 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
discriminator::merge (cognitive 32) lib/helpers/model/discriminator.js:131— discriminator::merge has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (19 pts), loops 5 (6 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
createPopulateQueryFilter.createPopulateQueryFilter (cognitive 31) lib/helpers/populate/createPopulateQueryFilter.js:8— createPopulateQueryFilter.createPopulateQueryFilter has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (15 pts), ternaries 2 (7 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
$applyDefaultsToNested (cognitive 31) lib/document.js:488— $applyDefaultsToNested has cognitive complexity 31 (threshold 15). Drivers by points: if/else 7 (19 pts), error handling 1 (4 pts), ternaries 2 (4 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity· model (cognitive 31) · ×1
model (cognitive 31) lib/connection.js:1441— model has cognitive complexity 31 (threshold 15). Drivers by points: if/else 17 (22 pts), boolean chains 7, error handling 1 (2 pts) (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
flatten (cognitive 31) lib/helpers/common.js:20— flatten has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 3 (7 pts), boolean chains 5, ternaries 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document.Document.$__buildDoc (cognitive 30) lib/document.js:563— document.Document.$__buildDoc has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (25 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
schemaType.SchemaType.doValidateSync (cognitive 30) lib/schemaType.js:1581— schemaType.SchemaType.doValidateSync has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (22 pts), boolean chains 3, error handling 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
toJSONSchema (cognitive 30) lib/schema.js:3295— toJSONSchema has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (18 pts), ternaries 2 (6 pts), loops 2 (4 pts), boolean chains 1, other 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
mergeClone (cognitive 30) lib/utils.js:909— mergeClone has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
defineKey (cognitive 30) lib/helpers/document/compile.js:68— defineKey has cognitive complexity 30 (threshold 15). Drivers by points: boolean chains 14, if/else 8 (14 pts), ternaries 2 (nesting depth added 6). Most of this is not in the body itself: 6 of the 30 points are its own statements and the rest belongs to 8 function items inside it that branch (get, get::value, set, …). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
document.Document.isSelected (cognitive 29) lib/document.js:2563— document.Document.isSelected has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (21 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
markArraySubdocsPopulated (cognitive 29) lib/helpers/populate/markArraySubdocsPopulated.js:19— markArraySubdocsPopulated has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (7 pts), ternaries 1 (6 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity· near (cognitive 28) · ×1
near (cognitive 28) lib/query.js:5595— near has cognitive complexity 28 (threshold 15). Drivers by points: if/else 16 (23 pts), boolean chains 5 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_setClient (cognitive 28) lib/drivers/node-mongodb-native/connection.js:436— _setClient has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 5, loops 4, ternaries 2 (nesting depth added 5). Most of this is not in the body itself: 9 of the 28 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 484, a function literal at line 470, a function literal at line 461, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
selectPopulatedFields.selectPopulatedFields (cognitive 27) lib/helpers/query/selectPopulatedFields.js:10— selectPopulatedFields.selectPopulatedFields has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model.Model.translateAliases (cognitive 27) lib/model.js:1947— model.Model.translateAliases has cognitive complexity 27 (threshold 15). Drivers by points: if/else 17 (30 pts), loops 4 (13 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (model.Model.translateAliases::translate) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
stringifyFunctionOperators (cognitive 27) lib/helpers/aggregate/stringifyFunctionOperators.js:3— stringifyFunctionOperators has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (10 pts), boolean chains 4 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
index.MongooseArray (cognitive 26) lib/types/array/index.js:32— index.MongooseArray has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (17 pts), boolean chains 6, loops 1 (3 pts) (nesting depth added 3). Of this number, 14 points are the body's own statements and 12 belong to 2 function literals inside it that branch. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
schema.aliasFields (cognitive 26) lib/schema.js:188— schema.aliasFields has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 2 (4 pts) (nesting depth added 15). Of this number, 20 points are the body's own statements and 6 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generateSearch.generateContents (cognitive 26) scripts/generateSearch.js:35— generateSearch.generateContents has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (14 pts), ternaries 2 (6 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 14). Most of this is not in the body itself: 12 of the 26 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 69, 106). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
_findRefPathForDiscriminators (cognitive 26) lib/helpers/populate/getModelsMapForPopulate.js:825— _findRefPathForDiscriminators has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (16 pts), boolean chains 4, loops 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 14). Of this number, 21 points are the body's own statements and 5 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
api.buildMarkdown (cognitive 25) docs/source/api.js:280— api.buildMarkdown has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (7 pts), boolean chains 4 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
createCollection (cognitive 25) lib/model.js:1222— createCollection has cognitive complexity 25 (threshold 15). Drivers by points: if/else 16 (20 pts), boolean chains 3, error handling 2 (nesting depth added 4). Of this number, 23 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
findOneAndUpdate (cognitive 25) lib/query.js:3518— findOneAndUpdate has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 8, match/switch 1, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
validate (cognitive 25) lib/schemaType.js:1026— validate has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 5, ternaries 1 (3 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document.Document.$getAllSubdocs::getSubdocs (cognitive 24) lib/document.js:4138— document.Document.$getAllSubdocs::getSubdocs has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 4 (8 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_mergeUpdate (cognitive 24) lib/query.js:4145— _mergeUpdate has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Schema (cognitive 24) lib/schema.js:110— Schema has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 6, loops 2 (4 pts), ternaries 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_clone (cognitive 24) lib/schema.js:431— _clone has cognitive complexity 24 (threshold 15). Drivers by points: loops 6 (14 pts), if/else 5 (7 pts), boolean chains 2, ternaries 1 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity· model (cognitive 24) · ×1
model (cognitive 24) lib/mongoose.js:591— model has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 7, ternaries 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
id (cognitive 24) lib/types/documentArray/methods/index.js:132— id has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 6, error handling 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
schema.getPositionalPathType (cognitive 23) lib/schema.js:2034— schema.getPositionalPathType has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 2, ternaries 1 (2 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyPlugins.applyPlugins (cognitive 23) lib/helpers/schema/applyPlugins.js:3— applyPlugins.applyPlugins has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (5 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
exec (cognitive 23) lib/query.js:4778— exec has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 4, error handling 2, loops 1, ternaries 1 (nesting depth added 3). Of this number, 13 points are the body's own statements and 10 belong to 2 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity· next (cognitive 23) · ×1
next (cognitive 23) lib/cursor/changeStream.js:119— next has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (23 pts) (nesting depth added 11). Most of this is not in the body itself: 10 of the 23 points are its own statements and the rest belongs to 6 function items inside it that branch (cb, a function literal at line 143, a function literal at line 152, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
setupTimestamps (cognitive 23) lib/helpers/timestamps/setupTimestamps.js:14— setupTimestamps has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 7, ternaries 4, other 2, loops 1 (nesting depth added 1). Most of this is not in the body itself: 11 of the 23 points are its own statements and the rest belongs to 2 function items inside it that branch (initializeTimestamps, withTimestamp). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
applyWriteConcern (cognitive 23) lib/helpers/schema/applyWriteConcern.js:5— applyWriteConcern has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 6, other 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
getEmbeddedDiscriminatorPath.getEmbeddedDiscriminatorPath (cognitive 22) lib/helpers/document/getEmbeddedDiscriminatorPath.js:17— getEmbeddedDiscriminatorPath.getEmbeddedDiscriminatorPath has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (9 pts), ternaries 4 (7 pts), boolean chains 5, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document.Document.$__init (cognitive 22) lib/document.js:694— document.Document.$__init has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (5 pts), boolean chains 3, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
query._completeOneLean (cognitive 22) lib/query.js:4075— query._completeOneLean has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (6 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyHooks.applyHooks (cognitive 22) lib/helpers/model/applyHooks.js:39— applyHooks.applyHooks has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 3 (5 pts), ternaries 2 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
assignVals.assignVals::setValue (cognitive 22) lib/helpers/populate/assignVals.js:44— assignVals.assignVals::setValue has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (10 pts), loops 3 (6 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model.Model.buildBulkWriteOperations (cognitive 22) lib/model.js:3987— model.Model.buildBulkWriteOperations has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 3, loops 1 (3 pts) (nesting depth added 8). Most of this is not in the body itself: 1 of the 22 points is its own statement and the rest belongs to 2 function items inside it that branch (a function literal at line 3994, setDefaultOptions). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
isModified (cognitive 22) lib/document.js:2359— isModified has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 4, ternaries 1 (3 pts), loops 1 (2 pts) (nesting depth added 10). Of this number, 17 points are the body's own statements and 5 belong to 4 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
checkDivergentArray (cognitive 22) lib/document.js:5568— checkDivergentArray has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 10 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_cast (cognitive 22) lib/types/documentArray/methods/index.js:60— _cast has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 5, ternaries 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
(anonymous) (cognitive 22) lib/schema/number.js:318— (anonymous) has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 6, loops 1, ternaries 1 (nesting depth added 5). Of this number, 21 points are the body's own statements and 1 belongs to 5 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cloneArray (cognitive 22) REDACTED:199— cloneArray has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (13 pts), loops 2 (4 pts), ternaries 2 (3 pts), boolean chains 1, other 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cast (cognitive 22) lib/schema/map.js:41— cast has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (6 pts), other 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
modelNamesFromRefPath (cognitive 22) lib/helpers/populate/modelNamesFromRefPath.js:12— modelNamesFromRefPath has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (13 pts), ternaries 2 (4 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
get.get (cognitive 21) lib/helpers/get.js:9— get.get has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 1, loops 1, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
index.MongooseDocumentArray (cognitive 21) lib/types/documentArray/index.js:30— index.MongooseDocumentArray has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (13 pts), boolean chains 6, loops 1 (2 pts) (nesting depth added 2). Most of this is not in the body itself: 8 of the 21 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 69, 91). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
applyVirtuals.applyVirtualsToChildren (cognitive 21) lib/helpers/document/applyVirtuals.js:49— applyVirtuals.applyVirtualsToChildren has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
website.renderFile (cognitive 21) scripts/website.js:464— website.renderFile has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
getDefault (cognitive 21) lib/schemaType.js:1306— getDefault has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 6, other 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
discriminator (cognitive 21) lib/helpers/model/discriminator.js:70— discriminator has cognitive complexity 21 (threshold 15). Drivers by points: if/else 26 (34 pts), boolean chains 11, loops 5 (6 pts), ternaries 3 (5 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document._getAllPathsToValidate (cognitive 20) lib/document.js:3020— document._getAllPathsToValidate has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (8 pts), boolean chains 1 (nesting depth added 10). Of this number, 19 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
number.SchemaNumber.enum (cognitive 20) lib/schema/number.js:318— number.SchemaNumber.enum has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 5, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
documentArray.SchemaDocumentArray.doValidate (cognitive 20) lib/schema/documentArray.js:233— documentArray.SchemaDocumentArray.doValidate has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, error handling 2, ternaries 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
castFilterPath.castFilterPath (cognitive 20) lib/helpers/query/castFilterPath.js:5— castFilterPath.castFilterPath has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
connection.Connection._close (cognitive 20) lib/connection.js:1251— connection.Connection._close has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 1, match/switch 1 (nesting depth added 9). Of this number, 14 points are the body's own statements and 6 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyMethods.applyMethods (cognitive 20) lib/helpers/model/applyMethods.js:14— applyMethods.applyMethods has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 4, loops 3 (nesting depth added 6). Of this number, 19 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_find (cognitive 20) lib/query.js:2457— _find has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 4, ternaries 2 (4 pts) (nesting depth added 5). Of this number, 17 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
required (cognitive 20) lib/schemaType.js:1139— required has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 8, if/else 8, ternaries 2 (4 pts) (nesting depth added 2). Of this number, 10 points are the body's own statements and 10 belong to 3 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
handleSpreadDoc.handleSpreadDoc (cognitive 19) lib/helpers/document/handleSpreadDoc.js:13— handleSpreadDoc.handleSpreadDoc has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
array.cast$elemMatch (cognitive 19) lib/schema/array.js:610— array.cast$elemMatch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 2 (5 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
schema.Schema.remove (cognitive 19) lib/schema.js:2819— schema.Schema.remove has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 10). Most of this is not in the body itself: 2 of the 19 points are its own statements and the rest belongs to one function literal inside it that branches (line 2824). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
castUpdate.castPipelineOperator (cognitive 19) lib/helpers/query/castUpdate.js:177— castUpdate.castPipelineOperator has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 7 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sanitizeFilter.sanitizeFilter (cognitive 19) lib/helpers/query/sanitizeFilter.js:7— sanitizeFilter.sanitizeFilter has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
query.Query._updateForExec (cognitive 19) lib/query.js:2068— query.Query._updateForExec has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model.Model.discriminator (cognitive 19) lib/model.js:1000— model.Model.discriminator has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (7 pts), boolean chains 6, ternaries 4, loops 1 (2 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
applyTimestampsToDoc (cognitive 19) lib/helpers/document/applyTimestamps.js:64— applyTimestampsToDoc has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 4). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
getPath (cognitive 19) lib/helpers/schema/getPath.js:13— getPath has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, ternaries 1 (2 pts), loops 1, other 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
isExclusive (cognitive 19) lib/helpers/projection/isExclusive.js:10— isExclusive has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 1 (4 pts), boolean chains 2, loops 1 (2 pts), other 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
clone.cloneObject (cognitive 18) REDACTED:160— clone.cloneObject has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 8, if/else 6 (8 pts), loops 1, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
document.Document.populated (cognitive 18) lib/document.js:5123— document.Document.populated has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 2 (5 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
array.SchemaArray._castForPopulate (cognitive 18) lib/schema/array.js:440— array.SchemaArray._castForPopulate has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (7 pts), boolean chains 3, error handling 1 (3 pts), loops 1 (3 pts), ternaries 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model._createSaveOptions (cognitive 18) lib/model.js:339— model._createSaveOptions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
loadClass (cognitive 18) lib/schema.js:2978— loadClass has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 2 (nesting depth added 5). Most of this is not in the body itself: 4 of the 18 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 3003, 2991). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
convertTo_id (cognitive 18) lib/helpers/populate/getModelsMapForPopulate.js:778— convertTo_id has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 2 (4 pts), boolean chains 3, other 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
prepareDiscriminatorPipeline (cognitive 18) lib/helpers/aggregate/prepareDiscriminatorPipeline.js:3— prepareDiscriminatorPipeline has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 6, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyTimestampsToChildren.applyTimestampsToChildren (cognitive 17) lib/helpers/update/applyTimestampsToChildren.js:12— applyTimestampsToChildren.applyTimestampsToChildren has cognitive complexity 17 (threshold 15). Drivers by points: if/else 13 (32 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (applyTimestampsToChildren.applyTimestampsToChildren::_applyTimestampToUpdateOperator) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
setDefaultsOnInsert.isModified (cognitive 17) lib/helpers/setDefaultsOnInsert.js:111— setDefaultsOnInsert.isModified has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
castBulkWrite.castBulkWrite (cognitive 17) lib/helpers/model/castBulkWrite.js:24— castBulkWrite.castBulkWrite has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9, error handling 4 (8 pts) (nesting depth added 4). Of this number, 9 points are the body's own statements and 8 belong to 4 function literals inside it that branch. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
queryCursor.QueryCursor::onPreComplete (cognitive 17) lib/cursor/queryCursor.js:57— queryCursor.QueryCursor::onPreComplete has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 5 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
query.Query._completeOne (cognitive 17) lib/query.js:2717— query.Query._completeOne has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 4). Of this number, 16 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model.Model.translateAliases::translate (cognitive 17) lib/model.js:1950— model.Model.translateAliases::translate has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (model.Model.translateAliases) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
getIndexesToCreate (cognitive 17) lib/model.js:1491— getIndexesToCreate has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (3 pts), boolean chains 1, other 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compile (cognitive 17) lib/model.js:5044— compile has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 6 (nesting depth added 3). Most of this is not in the body itself: 8 of the 17 points are its own statements and the rest belongs to 3 function items inside it that branch (model, model, Query). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
$__shouldModify (cognitive 17) lib/document.js:1683— $__shouldModify has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8, boolean chains 7, ternaries 1 (2 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
applySchemaTypeTransforms (cognitive 17) lib/document.js:4731— applySchemaTypeTransforms has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (4 pts), other 2, boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity· set (cognitive 17) · ×1
set (cognitive 17) lib/schema.js:2487— set has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 4, match/switch 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
openUri (cognitive 17) lib/connection.js:1058— openUri has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (9 pts), error handling 4 (5 pts), boolean chains 2, loops 1 (nesting depth added 4). Of this number, 15 points are the body's own statements and 2 belong to 4 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_model (cognitive 17) lib/mongoose.js:661— _model has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 4, loops 1 (2 pts), error handling 1, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
push (cognitive 17) lib/types/array/methods/index.js:718— push has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 4, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
applyExclusiveProjection (cognitive 17) lib/helpers/projection/applyProjection.js:34— applyExclusiveProjection has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 4, ternaries 2 (3 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
applyInclusiveProjection (cognitive 17) lib/helpers/projection/applyProjection.js:59— applyInclusiveProjection has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 4, ternaries 2 (3 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
castDouble (cognitive 17) lib/cast/double.js:17— castDouble has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (10 pts), error handling 2 (5 pts), boolean chains 1, other 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
_toObjectRecursive (cognitive 17) lib/helpers/document/toObjectRecursive.js:16— _toObjectRecursive has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (5 pts), boolean chains 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document._completeValidate (cognitive 16) lib/document.js:2979— document._completeValidate has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document.operand (cognitive 16) lib/document.js:5626— document.operand has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 3, match/switch 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
applyTimestampsToChildren.applyTimestampsToChildren::_applyTimestampToUpdateOperator (cognitive 16) lib/helpers/update/applyTimestampsToChildren.js:46— applyTimestampsToChildren.applyTimestampsToChildren::_applyTimestampToUpdateOperator has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (applyTimestampsToChildren.applyTimestampsToChildren) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
array.SchemaArray._applySetters (cognitive 16) lib/schema/array.js:297— array.SchemaArray._applySetters has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (6 pts), loops 2 (6 pts), boolean chains 4 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
subdocument.SchemaSubdocument.cast (cognitive 16) lib/schema/subdocument.js:177— subdocument.SchemaSubdocument.cast has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 4, ternaries 2 (nesting depth added 3). Of this number, 13 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
schema.Schema.removeIndex (cognitive 16) lib/schema.js:1130— schema.Schema.removeIndex has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
schema.getMapPath (cognitive 16) lib/schema.js:1548— schema.getMapPath has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 6, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
query.Query._findOneAndUpdate (cognitive 16) lib/query.js:3600— query.Query._findOneAndUpdate has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 2, loops 1, ternaries 1 (nesting depth added 2). Of this number, 15 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
convert-old-anchorid.window.addEventListener("DOMContentLoaded") (cognitive 16) docs/js/convert-old-anchorid.js:3— convert-old-anchorid.window.addEventListener("DOMContentLoaded") has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (13 pts), loops 2, boolean chains 1 (nesting depth added 2). Of this number, 12 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
website.mapURLs (cognitive 16) scripts/website.js:411— website.mapURLs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
orFail (cognitive 16) lib/query.js:4690— orFail has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, match/switch 1 (nesting depth added 6). None of this is in the body itself: all 16 points belong to one function literal inside it that branches (line 4691). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
_addArrayPathsToValidate (cognitive 16) lib/document.js:3384— _addArrayPathsToValidate has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 2 (4 pts), boolean chains 3, other 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D22 · Internal API Consistency· Redundant validation methods with overlapping intent. Both methods appear to validate whether a value is a valid MongoDB ObjectId or a valid hex string representation of one. Having two distinct public methods for the same logical check creates confusion for consumers. · ×1
Redundant validation methods with overlapping intent. Both methods appear to validate whether a value is a valid MongoDB ObjectId or a valid hex string representation of one. Having two distinct public methods for the same logical check creates confusion for consumers. — Deprecate one of the methods (likely `isObjectIdOrHexString` if `isValidObjectId` is the preferred semantic, or vice versa) and keep a single canonical validation method. (signatures: mongoose.Mongoose.isValidObjectId(v) | mongoose.Mongoose.isObjectIdOrHexString(v))
Change coupling: getIndexes.js ↔ model.js lib/helpers/schema/getIndexes.js:1— `lib/helpers/schema/getIndexes.js` and `lib/model.js` change together 80% of the time (8 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `0d0d06aa` BREAKING CHANGE: remove background option from indexes; `7f84bf6e` WIP remove some more caster usages for #15179; `ff188185` feat: allow specifying error message override for duplicate key error… — run `git show` on any of them.
Coverage not measured — JavaScript/TypeScript suite — Coverage NOT MEASURED: the JavaScript/TypeScript half could not be measured — the mocha suite in the repository root ran and not one test passed (Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:), so the coverage report describes the failed run, not the code. Coverage is excluded from the score rather than counted as a near-zero. The named suite step is one the repository's maintainers can perform; once it passes, the real number is measured on the next scan. Alternatively, commit the lcov/Cobertura report your CI produces and it is read without a re-run.
IC1 · Incompleteness & stubs· Guard cannot change the result · ×1
Guard cannot change the result — returns what the code already falls through to lib/schema/bigint.js:254— The guard above `return v;` also returns `v`, so no input can make it matter. Implement the distinction that was intended, or delete the guard.
Duplicated block (64 lines × 2 locations) lib/schema/bigint.js:83— lib/schema/bigint.js:83 · lib/schema/int32.js:101 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication· Duplicated block with local edits (44 matched lines × 2 locations) · ×1
Duplicated block with local edits (44 matched lines × 2 locations) lib/schema/double.js:39— lib/schema/double.js:39 · lib/schema/int32.js:40 — the two spans are one implementation copied and then locally edited — 274 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (36 lines × 2 locations) lib/query.js:4246— lib/query.js:4246 · lib/query.js:4292 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
R10 · Code Duplication· Duplicated block with local edits (34 matched lines × 2 locations) · ×1
Duplicated block with local edits (34 matched lines × 2 locations) lib/helpers/document/applyTimestamps.js:39— lib/helpers/document/applyTimestamps.js:39 · lib/helpers/document/applyVirtuals.js:51 — the two spans are one implementation copied and then locally edited — 222 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (30 lines × 2 locations) lib/types/array/index.js:82— lib/types/array/index.js:82 · lib/types/documentArray/index.js:76 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another.
Duplicated block (29 lines × 3 locations) lib/schema/date.js:368— lib/schema/date.js:368 · lib/schema/decimal128.js:194 · lib/schema/double.js:177 — the 3 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. There is one copy in each of 3 separate files rather than several in one place, so check first whether these are sibling modules that each declare their own version of one shape — one per entity, per provider, per language. Where they are, no single extracted module collapses them: each module still has to be written, and what recurs is the TEMPLATE. The moves that do collapse a template are to generate these modules from the set they enumerate, or to replace the repeated construction with one factory each site calls with its own values — and where the set is the point, each module pinning one distinct thing, the repetition IS the enumeration and there is nothing to delete.
Duplicated block (27 lines × 2 locations) lib/connection.js:607— lib/connection.js:607 · lib/connection.js:1749 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication· Duplicated block with local edits (26 matched lines × 2 locations) · ×1
Duplicated block with local edits (26 matched lines × 2 locations) lib/helpers/model/castBulkWrite.js:103— lib/helpers/model/castBulkWrite.js:103 · lib/helpers/model/castBulkWrite.js:167 — the two spans are one implementation copied and then locally edited — 197 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (25 lines × 2 locations) scripts/generateSearch.js:55— scripts/generateSearch.js:55 · scripts/generateSearch.js:92 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (24 lines × 2 locations) lib/cast.js:338— lib/cast.js:338 · lib/helpers/query/castFilterPath.js:28 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another.
Duplicated block (23 lines × 2 locations) lib/schema/number.js:434— lib/schema/number.js:434 · lib/schema/uuid.js:225 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (22 lines × 3 locations) lib/query.js:4359— lib/query.js:4359 · lib/query.js:4430 · lib/query.js:4506 — all 3 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (22 lines × 2 locations) lib/schema/buffer.js:260— lib/schema/buffer.js:260 · lib/schema/uuid.js:226 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (21 lines × 2 locations) lib/schema/buffer.js:148— lib/schema/buffer.js:148 · lib/schema/buffer.js:181 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2 locations) lib/helpers/populate/getVirtual.js:31— lib/helpers/populate/getVirtual.js:31 · lib/helpers/populate/getVirtual.js:63 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
R10 · Code Duplication· Duplicated block with local edits (15 matched lines × 2 locations) · ×1
Duplicated block with local edits (15 matched lines × 2 locations) lib/types/array/methods/index.js:315— lib/types/array/methods/index.js:315 · lib/types/documentArray/methods/index.js:480 — the two spans are one implementation copied and then locally edited — 81 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication· Duplicated block with local edits (14 matched lines × 2 locations) · ×1
Duplicated block with local edits (14 matched lines × 2 locations) lib/helpers/setDefaultsOnInsert.js:113— lib/helpers/setDefaultsOnInsert.js:113 · lib/helpers/setDefaultsOnInsert.js:152 — the two spans are one implementation copied and then locally edited — 57 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Complex function $set (cyclomatic 164, cognitive 260) lib/document.js:1103— $set has cyclomatic complexity 164 and cognitive complexity 260; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function cast (cyclomatic 103, cognitive 305) lib/cast.js:38— cast has cyclomatic complexity 103 and cognitive complexity 305; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function walkUpdatePath (cyclomatic 96, cognitive 238) lib/helpers/query/castUpdate.js:222— walkUpdatePath has cyclomatic complexity 96 and cognitive complexity 238; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function _getPathsToValidate (cyclomatic 86, cognitive 172) lib/document.js:3102— _getPathsToValidate has cyclomatic complexity 86 and cognitive complexity 172; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function applyDefaults (cyclomatic 76, cognitive 189) lib/helpers/document/applyDefaults.js:5— applyDefaults has cyclomatic complexity 76 and cognitive complexity 189; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function interpretAsType (cyclomatic 76, cognitive 133) lib/schema.js:1600— interpretAsType has cyclomatic complexity 76 and cognitive complexity 133; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function _populatePath (cyclomatic 61, cognitive 106) lib/model.js:4574— _populatePath has cyclomatic complexity 61 and cognitive complexity 106; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function add (cyclomatic 57, cognitive 107) lib/schema.js:793— add has cyclomatic complexity 57 and cognitive complexity 107; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function getModelsMapForPopulate (cyclomatic 57, cognitive 102) lib/helpers/populate/getModelsMapForPopulate.js:25— getModelsMapForPopulate has cyclomatic complexity 57 and cognitive complexity 102; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function search (cyclomatic 56, cognitive 171) lib/helpers/populate/getSchemaTypes.js:49— search has cyclomatic complexity 56 and cognitive complexity 171; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function validate (cyclomatic 56, cognitive 75) lib/document.js:2747— validate has cyclomatic complexity 56 and cognitive complexity 75; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function _insertMany (cyclomatic 55, cognitive 87) lib/model.js:3089— _insertMany has cyclomatic complexity 55 and cognitive complexity 87; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function $toObject (cyclomatic 54, cognitive 60) lib/document.js:4221— $toObject has cyclomatic complexity 54 and cognitive complexity 60; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function init (cyclomatic 52, cognitive 93) lib/document.js:751— init has cyclomatic complexity 52 and cognitive complexity 93; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function deepEqual (cyclomatic 51, cognitive 54) lib/utils.js:77— deepEqual has cyclomatic complexity 51 and cognitive complexity 54; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function castUpdate (cyclomatic 50, cognitive 61) lib/helpers/query/castUpdate.js:51— castUpdate has cyclomatic complexity 50 and cognitive complexity 61; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function clone (cyclomatic 47, cognitive 73) REDACTED:33— clone has cyclomatic complexity 47 and cognitive complexity 73; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function $__save (cyclomatic 46, cognitive 99) lib/model.js:385— $__save has cyclomatic complexity 46 and cognitive complexity 99; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function path (cyclomatic 44, cognitive 68) lib/schema.js:1285— path has cyclomatic complexity 44 and cognitive complexity 68; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function $__delta (cyclomatic 43, cognitive 86) lib/document.js:5406— $__delta has cyclomatic complexity 43 and cognitive complexity 86; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
lib/query.js: 5306 lines of code lib/query.js:1— lib/query.js has 5306 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/document.js: 5300 lines of code lib/document.js:1— lib/document.js has 5300 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/model.js: 4810 lines of code lib/model.js:1— lib/model.js has 4810 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/schema.js: 3042 lines of code lib/schema.js:1— lib/schema.js has 3042 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/schemaType.js: 1747 lines of code lib/schemaType.js:1— lib/schemaType.js has 1747 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/connection.js: 1642 lines of code lib/connection.js:1— lib/connection.js has 1642 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/mongoose.js: 1261 lines of code lib/mongoose.js:1— lib/mongoose.js has 1261 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/aggregate.js: 1122 lines of code lib/aggregate.js:1— lib/aggregate.js has 1122 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· lib/types/array/methods/index.js · ×1
lib/types/array/methods/index.js: 960 lines of code lib/types/array/methods/index.js:1— lib/types/array/methods/index.js has 960 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/utils.js: 914 lines of code lib/utils.js:1— lib/utils.js has 914 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· lib/helpers/populate/getModelsMapForPopulate.js · ×1
lib/helpers/populate/getModelsMapForPopulate.js: 788 lines of code lib/helpers/populate/getModelsMapForPopulate.js:1— lib/helpers/populate/getModelsMapForPopulate.js has 788 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/schema/string.js: 665 lines of code lib/schema/string.js:1— lib/schema/string.js has 665 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· lib/helpers/query/castUpdate.js · ×1
lib/helpers/query/castUpdate.js: 617 lines of code lib/helpers/query/castUpdate.js:1— lib/helpers/query/castUpdate.js has 617 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/schema/array.js: 611 lines of code lib/schema/array.js:1— lib/schema/array.js has 611 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/cursor/queryCursor.js: 594 lines of code lib/cursor/queryCursor.js:1— lib/cursor/queryCursor.js has 594 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· lib/schema/documentArray.js · ×1
lib/schema/documentArray.js: 576 lines of code lib/schema/documentArray.js:1— lib/schema/documentArray.js has 576 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· lib/cursor/aggregationCursor.js · ×1
lib/cursor/aggregationCursor.js: 461 lines of code lib/cursor/aggregationCursor.js:1— lib/cursor/aggregationCursor.js has 461 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· lib/types/documentArray/methods/index.js · ×1
lib/types/documentArray/methods/index.js: 457 lines of code lib/types/documentArray/methods/index.js:1— lib/types/documentArray/methods/index.js has 457 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/schema/number.js: 448 lines of code lib/schema/number.js:1— lib/schema/number.js has 448 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· lib/drivers/node-mongodb-native/connection.js · ×1
lib/drivers/node-mongodb-native/connection.js: 436 lines of code lib/drivers/node-mongodb-native/connection.js:1— lib/drivers/node-mongodb-native/connection.js has 436 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
lib/schema/date.js: 411 lines of code lib/schema/date.js:1— lib/schema/date.js has 411 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
Dead file (~46 LoC) tools/sharded.js— no import path from any entry point (44 application, 33 tooling, 188 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~31 LoC) tools/auth.js— no import path from any entry point (44 application, 33 tooling, 188 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~29 LoC) lib/error/browserMissingSchema.js— no import path from any entry point (44 application, 33 tooling, 188 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~12 LoC) lib/helpers/once.js— no import path from any entry point (44 application, 33 tooling, 188 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~3 LoC) lib/helpers/query/validOps.js— no import path from any entry point (44 application, 33 tooling, 188 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Benchmark script nothing runs (~154 LoC) benchmarks/hydrateComplex.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/hydrateComplex.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~117 LoC) benchmarks/saveSimple.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/saveSimple.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~114 LoC) benchmarks/findOneAndUpdateSimple.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/findOneAndUpdateSimple.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~72 LoC) benchmarks/get.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/get.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~70 LoC) benchmarks/findOneWithCast.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/findOneWithCast.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~68 LoC) benchmarks/insertManySimple.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/insertManySimple.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~60 LoC) benchmarks/recursiveToObject.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/recursiveToObject.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~53 LoC) benchmarks/mapOfSubdocs.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/mapOfSubdocs.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~51 LoC) benchmarks/nestedArrayLarge.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/nestedArrayLarge.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Benchmark script nothing runs (~37 LoC) benchmarks/createDeepNestedDocArray.js— This script imports the product ('../'), so it is an authored benchmark, not measurement input — but nothing invokes it: no package.json script, no CI workflow or build recipe, no Dockerfile, no other file under benchmarks/, and no in-repo reference to its name at all. It runs only if someone remembers to type `node benchmarks/createDeepNestedDocArray.js`, and it silently rots against the API it measures. Wire it into a script or workflow the way its wired siblings are, or delete it.
Unused dependency 'mongodb-client-encryption' — Declared in the root package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
SC1 · Supply-chain hygiene· JavaScript dependencies are not locked · ×1
JavaScript dependencies are not locked — No package-lock.json / yarn.lock / pnpm-lock.yaml / bun.lock — JS installs aren't reproducible (SSDF PW.4.4). Commit your package manager's lockfile and install from it (`npm ci`, `yarn --immutable`, `pnpm i --frozen-lockfile` or `bun i --frozen-lockfile`). Advisory — never scored.
Duplicated predicate lib/aggregate.js:109— `!Object.hasOwn(options, 'session') && asyncLocalStorage?.session != null` appears character-identically in 2 files — lib/aggregate.js, lib/model.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/types/array/methods/index.js:273— `Buffer.isBuffer(value) || isBsonType(value, 'ObjectId') || !utils.isObject(value)` appears character-identically in 2 files — lib/types/array/methods/index.js, lib/types/documentArray/methods/index.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/helpers/document/applyTimestamps.js:46— `_obj == null || (Array.isArray(_obj) && _obj.flat(Infinity).length === 0)` appears character-identically in 2 files — lib/helpers/document/applyTimestamps.js, lib/helpers/document/applyVirtuals.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/types/array/methods/index.js:326— `dirtyPath != null && dirtyPath.endsWith('.$')` appears character-identically in 2 files — lib/types/array/methods/index.js, lib/types/documentArray/methods/index.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/schema/bigint.js:235— `err instanceof CastError && err.path === this.path && this.$fullPath != null` appears character-identically in 9 files — lib/schema/bigint.js, lib/schema/boolean.js, lib/schema/buffer.js, lib/schema/date.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/document.js:613— `exclude === false && fields && !included` appears character-identically in 2 files — lib/document.js, lib/helpers/document/applyDefaults.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/helpers/update/castArrayFilters.js:74— `firstKey === '$and' || firstKey === '$or'` appears character-identically in 2 files — lib/helpers/update/castArrayFilters.js, lib/helpers/update/removeUnusedArrayFilters.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/cursor/aggregationCursor.js:86— `model.collection._shouldBufferCommands() && model.collection.buffer` appears character-identically in 2 files — lib/cursor/aggregationCursor.js, lib/cursor/queryCursor.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/cursor/aggregationCursor.js:131— `resultValue != null && (!Array.isArray(resultValue) || resultValue.length)` appears character-identically in 2 files — lib/cursor/aggregationCursor.js, lib/cursor/queryCursor.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/drivers/node-mongodb-native/connection.js:379— `schema.discriminatorMapping && !schema.discriminatorMapping.isRoot` appears character-identically in 2 files — lib/drivers/node-mongodb-native/connection.js, lib/helpers/model/castBulkWrite.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/helpers/document/applyTimestamps.js:75— `schema.discriminators && utils.hasOwnKeys(schema.discriminators)` appears character-identically in 2 files — lib/helpers/document/applyTimestamps.js, lib/helpers/document/applyVirtuals.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/types/array/index.js:88— `schematype?.virtuals && Object.hasOwn(schematype.virtuals, prop)` appears character-identically in 2 files — lib/types/array/index.js, lib/types/documentArray/index.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/cursor/aggregationCursor.js:261— `this.listeners('error').length > 0 && this.emit('error', error)` appears character-identically in 2 files — lib/cursor/aggregationCursor.js, lib/cursor/queryCursor.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/schema/union.js:139— `this.options.required && typeof this.options.required !== 'function'` appears character-identically in 2 files — lib/schema/union.js, lib/schemaType.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/aggregate.js:247— `typeof arg === 'object' && !Array.isArray(arg)` appears character-identically in 2 files — lib/aggregate.js, lib/query.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/model.js:639— `typeof options === 'function' || typeof arguments[1] === 'function'` appears character-identically in 2 files — lib/model.js, lib/query.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/types/array/index.js:98— `typeof prop === 'string' && numberRE.test(prop)` appears character-identically in 2 files — lib/types/array/index.js, lib/types/documentArray/index.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/schema/array.js:234— `typeof value === 'object' && SchemaType._isRef(this, value, doc, true)` appears character-identically in 4 files — lib/schema/array.js, lib/schema/date.js, lib/schema/number.js, lib/schema/string.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/helpers/common.js:73— `update == null || typeof update !== 'object'` appears character-identically in 2 files — lib/helpers/common.js, lib/helpers/setDefaultsOnInsert.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/schema/documentArrayElement.js:107— `value && !(value instanceof Constructor)` appears character-identically in 2 files — lib/schema/documentArrayElement.js, lib/schema/subdocument.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lib/schema/buffer.js:171— `value == null || utils.isNonBuiltinObject(value)` appears character-identically in 3 files — lib/schema/buffer.js, lib/schema/number.js, lib/schema/objectId.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Documentation: no architecture or design documentation README.md— The README gives a high-level overview but does not link to or describe the architecture/Docs markdown files, which cover advanced topics like async/await, Atlas search/vector search, and change streams in detail. Link the root README's overview to the architecture/Docs directory so readers can find the full reference there.
Documentation: no project overview docs/defaults.md— The defaults tutorial explains how to declare default values on a schema, with code examples, but it does not state what the project is or what it does overall. Add an overview paragraph describing Mongoose's purpose and the scope of the documentation so readers can find this guide among many.
Documentation: no project overview docs/enterprise.md— The enterprise section describes Tidelift subscription benefits but does not explain what the project is or what it does. Add an overview paragraph stating Mongoose's purpose and where each document fits so readers can find this guide among many.
README/code drift CONTRIBUTING.md:48— CONTRIBUTING.md runs `npm run ts-benchmark-watch`, but no package.json declares a `ts-benchmark-watch` script. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift docs/atlas-vector-search.md:110— docs/atlas-vector-search.md names MongoDB 8, but the manifest declares `mongodb` ~7.7. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift docs/nextjs.md:54— docs/nextjs.md documents the environment variable `MONGODB_URI`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
Disabled test test/model.test.js:3753— A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
Disabled test test/model.test.js:3787— A test is skipped/ignored — coverage that looks present but never runs. Re-enable it or delete it so the green run means something.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 7 significant file(s) lose their only recent owner: lib/helpers/document/applyDefaults.js, lib/cursor/changeStream.js, lib/helpers/pathTrie.js, lib/helpers/indexes/isIndexEqual.js, benchmarks/findOneAndUpdateSimple.js, benchmarks/saveSimple.js, lib/options/schemaSubdocumentOptions.js. Pair on, review, or document these before any departure.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 1 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (8 single-owned of 91 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 91 of the 285 production source files in this repository met that bar). They are anonymized user #2 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: lib/helpers/projection/applyProjection.js.
D26 · Project Cohesion· Projects may be oversized for their cohesion · ×1
Projects may be oversized for their cohesion — 1 of 1 project(s) overshoot their size bounds, lowering Project Cohesion to 0.0/10. The most over is `(repository root)` (52643 LoC, 285 module-visible types across 38 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D30 · Dependency Vulnerabilities· Scanner failed to run · ×1
No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
M2 · Architecture documentation· No architecture diagram/doc · ×1
No architecture diagram/doc — No C4/Structurizr/PlantUML/Mermaid/Graphviz/D2 diagram, no drawn diagram named for the architecture, no file named `architecture` or `design` in any markup this check reads, and nothing in the README, docs or contributor guides that announces the shape — no `## Architecture` heading, no "architecture overview"/"high-level design" phrasing, no "the architecture is …" introduction, no guided code tour. A shape laid out in prose that never names itself as the architecture is not visible to this check, and neither is one kept outside the repository, so this row reports the absence of a re-findable shape document — not evidence that nobody wrote the shape down.
No release approval gate — The release is automated and no gate that pauses it for a human is DECLARED IN THIS REPOSITORY'S PIPELINE FILES. What was read: every file under `.github/workflows/`, `.forgejo/workflows/`, `.gitea/workflows/`, `.azuredevops/` and `.azure-pipelines/`, plus `.gitlab-ci*` and `azure-pipelines*` — with comment text stripped, so documenting a gate is not declaring one. What would have counted: GitLab's `when: manual`, CircleCI's `type: approval`, an Azure `ManualValidation@` task or an `approvals:` block, a Jenkins `input` step, a `uses:` step naming an approval action, an `environment:` paired with `reviewers` / `required_reviewers` / `protection` / `wait-timer` / `deployment_branch_policy`, a draft-release step, a `workflow_dispatch` promotion, or a release-event gate. ★ What this cannot see, because none of it is a file: a GitHub environment whose required reviewers are configured in repo SETTINGS, a branch protection rule, or an organisation deployment policy — all of them real, enforced gates that live outside the repository. If yours is one of those, this row is wrong and nothing in the tree could have told us. Otherwise: whatever the release trigger points at is published to users unreviewed, so a mistagged or unverified commit ships and the only remedy is a follow-up release.
R7 · Dead Code· Unused module-local declaration 'handleValidationError' · ×1
Unused module-local declaration 'handleValidationError' test/types/Errors.test.ts:8— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'gh11838' · ×1
Unused module-local declaration 'gh11838' test/types/Errors.test.ts:18— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'addFields1' · ×1
Unused module-local declaration 'addFields1' test/types/PipelineStage.test.ts:9— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'addFields2' · ×1
Unused module-local declaration 'addFields2' test/types/PipelineStage.test.ts:16— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'addFields3' · ×1
Unused module-local declaration 'addFields3' test/types/PipelineStage.test.ts:23— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'addFields4' · ×1
Unused module-local declaration 'addFields4' test/types/PipelineStage.test.ts:29— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'addFields5' · ×1
Unused module-local declaration 'addFields5' test/types/PipelineStage.test.ts:33— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'addFields6' · ×1
Unused module-local declaration 'addFields6' test/types/PipelineStage.test.ts:40— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'bucket1' · ×1
Unused module-local declaration 'bucket1' test/types/PipelineStage.test.ts:50— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'bucket2' · ×1
Unused module-local declaration 'bucket2' test/types/PipelineStage.test.ts:68— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unionWith1' · ×1
Unused module-local declaration 'unionWith1' test/types/PipelineStage.test.ts:106— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unionWith2' · ×1
Unused module-local declaration 'unionWith2' test/types/PipelineStage.test.ts:107— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unionWith3' · ×1
Unused module-local declaration 'unionWith3' test/types/PipelineStage.test.ts:108— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unionWith4' · ×1
Unused module-local declaration 'unionWith4' test/types/PipelineStage.test.ts:109— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unset1' · ×1
Unused module-local declaration 'unset1' test/types/PipelineStage.test.ts:116— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unset2' · ×1
Unused module-local declaration 'unset2' test/types/PipelineStage.test.ts:117— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unset3' · ×1
Unused module-local declaration 'unset3' test/types/PipelineStage.test.ts:118— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unwind1' · ×1
Unused module-local declaration 'unwind1' test/types/PipelineStage.test.ts:127— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unwind2' · ×1
Unused module-local declaration 'unwind2' test/types/PipelineStage.test.ts:128— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unwind3' · ×1
Unused module-local declaration 'unwind3' test/types/PipelineStage.test.ts:129— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unwind4' · ×1
Unused module-local declaration 'unwind4' test/types/PipelineStage.test.ts:130— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'unwind5' · ×1
Unused module-local declaration 'unwind5' test/types/PipelineStage.test.ts:131— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'redact1' · ×1
Unused module-local declaration 'redact1' test/types/PipelineStage.test.ts:133— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
R7 · Dead Code· Unused module-local declaration 'redact2' · ×1
Unused module-local declaration 'redact2' test/types/PipelineStage.test.ts:143— This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
No app-layer HTTPS enforcement detected scripts/static.js:22— `app.listen(…)` serves plain HTTP on a network address, and nothing in its package enforces HTTPS: no TLS served (`https.createServer`, Fastify `https`, Nest `httpsOptions`), no redirect of plain requests to `https://`, no `Strict-Transport-Security` (helmet sends it by default), and no TLS-terminating proxy configuration committed beside it — so a browser may talk to it in clear text. (−2.0 on this card.)
X2 · Cancellation propagation· Not all async functions that make a request accept an AbortSignal · ×1
Not all async functions that make a request accept an AbortSignal — Only 0/2 async functions that make a cancellable request (fetch, axios, ky, ofetch) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
Silent fallback default in catch lib/helpers/populate/createPopulateQueryFilter.js:84— `_filterInvalidIds` swallows every exception into `return false` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Skipped (documented): flat test/types.array.test.js:1863— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): flatMap test/types.array.test.js:1876— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): work test/schema.test.js:1195— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): includes calling file for filter cast errors (gh-8691) test/query.test.js:3166— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): does not apply sibling path defaults if using nested projection (gh-14115) test/query.test.js:4509— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): updateOne with top level key that starts with $ (gh-13786) test/model.updateOne.test.js:3442— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): createCollection() respects timeseries (gh-10611) test/model.test.js:6250— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): createCollection() enforces expireAfterSeconds (gh-11229) test/model.test.js:6288— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): createCollection() enforces expires (gh-11229) test/model.test.js:6315— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): createCollection() enforces expireAfterSeconds when set by Schema (gh-11229) test/model.test.js:6343— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): createCollection() enforces expires when set by Schema (gh-11229) test/model.test.js:6371— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): createCollection() respects clusteredIndex test/model.test.js:6399— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): (unnamed test) test/model.test.js:7239— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): avoids trying to drop timeseries collections (gh-14984) test/model.test.js:9880— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): with replica set test/index.test.js:870— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): (unnamed test) test/index.test.js:967— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): (unnamed test) test/index.test.js:986— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): (unnamed test) test/index.test.js:990— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): (unnamed test) test/index.test.js:997— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): should not fail test/errors.validation.test.js:277— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): applies subdocument defaults when projecting dotted subdocument fields test/document.test.js:11460— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): `watch()` on a whole collection (gh-8425) test/connection.test.js:1116— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): should demonstrate the withSession() function (gh-14330) test/connection.test.js:1803— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): connection bulkWrite() ordered (gh-15028) test/connection.test.js:1856— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Skipped (documented): connection bulkWrite() unordered (gh-15028) test/connection.test.js:1889— Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
Dependency hygiene PARTLY measured — npm pinning read, dependency currency not (no committed lockfile, so no resolved version to grade) — This repository's npm dependencies were read for PINNING discipline: 9 production declaration(s) plus 37 development one(s) across 2 package.json (1 of them the product — the rest are example, documentation or fixture manifests, which are read and counted but screened off the rules below, because both prescribe a MOVE and "align your example apps" is not a remedy), against 0 committed lockfile(s). No pinning defect was found. That is only PART of dependency hygiene, so this dimension is NOT SCORED: whether any of these packages has a newer, deprecated or abandoned release is the dependency-CURRENCY question, and answering it needs a lockfile resolved to concrete versions, which this repository does not commit: a package.json states version RANGES, and a range names no particular release to be behind. So there was nothing here for the registry to grade — that is a fact about the repository, not a reader we are missing, and no lockfile reader we could write would change it. A clean pinning pass is NOT an all-clear for these dependencies, and it is not a finding that they are all USED. Note also what is deliberately NOT charged here: a workspace legitimately carries ONE lockfile for many manifests, so no row is raised off the lockfile count, only reported. Known CVEs in the same dependency graph are a separate question again, reported under D30 wherever the manifest is OSV-readable.
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 5 file(s) — `types/index.d.ts`, `types/inferhydrateddoctype.d.ts`, `types/models.d.ts`, `types/populate.d.ts`, `types/query.d.ts` — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
Run 01a16ec1-a8eb-7c97-859e-50eb2e479467 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 20 · Warnings: 705 · Recommendations: 67 · Info: 37 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 24-10-2026 @ 16:32 UTC.
Downloadable artifacts
Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.