Public report of terrastruct/d2, 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, 03:18 UTC · Survey ID cd_6f06acd7031f47fda704a716614d10d5
terrastruct/d2
Measured 24 October 2026, 03:05 UTC, at code version 6a7b483
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).
Test reliability is not measured: A declared JavaScript/TypeScript suite never runs a test case.
CAI scoreAdequate
CriticalWeakAdequateStrongExemplary
Down 2 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 large codebase: 175,454 lines of product code in 1 project, tests not counted · Estimated rebuild effort: about 3.6 person-years · Weakest lens: Production Readiness, 66
Findings by how serious they are
2 critical2884 serious65 minor
15 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, 03:05 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 ▸
66of 69 dimensions measured by tools. The other 3 are advisory notes from an AI model, which explain the code but don't count towards the score.
2928of 2951 findings point to an exact file and line, so you can open each one in the code. The other 23 concern the repository as a whole, such as missing documentation.
69dimensions across 7 lenses, read from 175,454 lines of product code in 1 project.
terrastruct/d2 scores 71 out of 100, which would normally be rated Strong, but it is rated Adequate because its weakest group of dimensions, Code quality, is rated Weak. The standard never rates a score more than one step above its weakest group, so a high average can't hide a weak area. The project hasn't declared a stable release yet, so its lenses are rated against a lower bar than a released product's, while the score itself is worked out as for any repository.
The weakest lens counts most in the score, and here that is Production Readiness, which scores 66 and is rated Adequate. Its Security & performance tooling dimension scores 2 out of 10, and until that reaches 4, Production Readiness can't be rated higher than Adequate. The first actions are to resolve the 1 Dependency pinned to a stale untagged commit finding(s) in Dependency Hygiene and to add a SAST step to CI running what this repository's stack ships: gosec / govulncheck (or golangci-lint) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing, and if Production Readiness rose to 70, the score would rise from 71 to about 73.
Two findings are critical: one in Secrets (history) and one in Test Reliability.
Watchdog couldn't measure 14 dimensions in this code, among them Internal API Consistency, Navigability and Data Protection, so they are left out of the score. The product code is 175,454 lines, which would take an estimated 3.6 person-years, around €530,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.
If Production Readiness rose from 66 to 70, the lowest score rated Strong, the score would rise from 71 to about 73.
Code composition: what the lines of code are
Product code 54%Tests 46%
New since the last survey: 240 findings
These 240 critical or serious findings weren't in the previous survey, on 10 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.
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: 11 findings
These 11 critical or serious findings were in the previous survey, on 10 October 2026, and are gone from this one.
Exception handling · Swallowed exception (caught, then discarded) lib/version/version.go
Rebuild cost: about €530,000 · Estimate
Cost to rebuild
€180,000 to €880,000, for 2,918 to 9,258 hours of work, about 3.6 person-years for 2 to 7 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
×1.0 at a score of 71. 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
Large: 175,454 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
Resolve the 1 Dependency pinned to a stale untagged commit finding(s) in Dependency Hygiene.
Add a SAST step to CI running what this repository's stack ships: gosec / govulncheck (or golangci-lint) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Enforce accessibility in the test suite you already have: assert the accessibility invariants over the HTML your app renders — parse the rendered output in an existing test, or drive a real browser from one — and gate that test in CI so a regression blocks the merge.
Raises the score by about 3 points · Medium effort · A11y enforcement
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.
If you do one thing first · First action
Resolve the 1 Dependency pinned to a stale untagged commit finding(s) in Dependency Hygiene. Of all the actions in this report, it raises the score most for the work it takes: about 3 points for low effort, because it clears the 1 Dependency Hygiene findings. 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 5.5 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 6% to 14% on every change. The history of the code shows how much it changes: about 557,447 lines over the last 90 days, which is about 2,260,757 lines a year. At that pace, the extra work comes to an estimated 349.7 to 2098.4 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 · Code Duplication · 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.
115 modules, with 212 dependencies between them. 2 loops run through 10 of the modules, marked above the diagonal.
The table shows the 40 modules with the most connections; 75 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.
com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds uses a module listed above it, which is the healthy direction.
6→23 com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraphpart of a loop✕
Connections
2 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can break com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds can't break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
com/d2lang/d2/d2renderers/d2ascii/asciicanvas uses com/d2lang/d2/d2renderers/d2ascii/charset, so a change to com/d2lang/d2/d2renderers/d2ascii/charset can break com/d2lang/d2/d2renderers/d2ascii/asciicanvas, while a change to com/d2lang/d2/d2renderers/d2ascii/asciicanvas can't break com/d2lang/d2/d2renderers/d2ascii/charset.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii/asciicanvas uses a module listed above it, which is the healthy direction.
98 pairs of types, where a type in com/d2lang/d2/d2renderers/d2raster uses a type in com/d2lang/d2/d2renderers/d2scene. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
com/d2lang/d2/d2renderers/d2raster uses com/d2lang/d2/d2renderers/d2scene, so a change to com/d2lang/d2/d2renderers/d2scene can break com/d2lang/d2/d2renderers/d2raster, while a change to com/d2lang/d2/d2renderers/d2raster can't break com/d2lang/d2/d2renderers/d2scene.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2raster uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2raster uses com/d2lang/d2/d2renderers/internal/fontface, so a change to com/d2lang/d2/d2renderers/internal/fontface can break com/d2lang/d2/d2renderers/d2raster, while a change to com/d2lang/d2/d2renderers/d2raster can't break com/d2lang/d2/d2renderers/internal/fontface.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2raster uses a module listed above it, which is the healthy direction.
44 pairs of types, where a type in com/d2lang/d2/d2renderers/d2svgimport uses a type in com/d2lang/d2/d2renderers/d2scene. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
com/d2lang/d2/d2renderers/d2svgimport uses com/d2lang/d2/d2renderers/d2scene, so a change to com/d2lang/d2/d2renderers/d2scene can break com/d2lang/d2/d2renderers/d2svgimport, while a change to com/d2lang/d2/d2renderers/d2svgimport can't break com/d2lang/d2/d2renderers/d2scene.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svgimport uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/internal/fontfallback uses com/d2lang/d2/d2renderers/d2scene, so a change to com/d2lang/d2/d2renderers/d2scene can break com/d2lang/d2/d2renderers/internal/fontfallback, while a change to com/d2lang/d2/d2renderers/internal/fontfallback can't break com/d2lang/d2/d2renderers/d2scene.
Position
Below the diagonal: com/d2lang/d2/d2renderers/internal/fontfallback uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/internal/fontfallback uses com/d2lang/d2/d2renderers/internal/fontface, so a change to com/d2lang/d2/d2renderers/internal/fontface can break com/d2lang/d2/d2renderers/internal/fontfallback, while a change to com/d2lang/d2/d2renderers/internal/fontfallback can't break com/d2lang/d2/d2renderers/internal/fontface.
Position
Below the diagonal: com/d2lang/d2/d2renderers/internal/fontfallback uses a module listed above it, which is the healthy direction.
com/d2lang/d2/lib/imgbundler uses com/d2lang/d2/lib/imageasset, so a change to com/d2lang/d2/lib/imageasset can break com/d2lang/d2/lib/imgbundler, while a change to com/d2lang/d2/lib/imgbundler can't break com/d2lang/d2/lib/imageasset.
Position
Below the diagonal: com/d2lang/d2/lib/imgbundler uses a module listed above it, which is the healthy direction.
com/d2lang/d2/lib/label uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/lib/label, while a change to com/d2lang/d2/lib/label can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/lib/label uses a module listed above it, which is the healthy direction.
com/d2lang/d2/lib/svg uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/lib/svg, while a change to com/d2lang/d2/lib/svg can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/lib/svg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2ast uses com/d2lang/d2/lib/label, so a change to com/d2lang/d2/lib/label can break com/d2lang/d2/d2ast, while a change to com/d2lang/d2/d2ast can't break com/d2lang/d2/lib/label.
Position
Below the diagonal: com/d2lang/d2/d2ast uses a module listed above it, which is the healthy direction.
2 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/limits uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds.
com/d2lang/d2/d2layouts/d2talalayout/internal/limits uses com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds can break com/d2lang/d2/d2layouts/d2talalayout/internal/limits, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/limits can't break com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/limits uses a module listed above it, which is the healthy direction.
15→23 com/d2lang/d2/d2layouts/d2talalayout/internal/limits uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraphpart of a loop✕
Connections
4 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/limits uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
com/d2lang/d2/d2layouts/d2talalayout/internal/limits uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can break com/d2lang/d2/d2layouts/d2talalayout/internal/limits, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/limits can't break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
com/d2lang/d2/d2renderers/d2fonts uses com/d2lang/d2/d2renderers/internal/fontface, so a change to com/d2lang/d2/d2renderers/internal/fontface can break com/d2lang/d2/d2renderers/d2fonts, while a change to com/d2lang/d2/d2renderers/d2fonts can't break com/d2lang/d2/d2renderers/internal/fontface.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2fonts uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2fonts uses com/d2lang/d2/d2renderers/internal/fontfallback, so a change to com/d2lang/d2/d2renderers/internal/fontfallback can break com/d2lang/d2/d2renderers/d2fonts, while a change to com/d2lang/d2/d2renderers/d2fonts can't break com/d2lang/d2/d2renderers/internal/fontfallback.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2fonts uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2sketch uses com/d2lang/d2/d2renderers/d2scene, so a change to com/d2lang/d2/d2renderers/d2scene can break com/d2lang/d2/d2renderers/d2sketch, while a change to com/d2lang/d2/d2renderers/d2sketch can't break com/d2lang/d2/d2renderers/d2scene.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2sketch uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2sketch uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2renderers/d2sketch, while a change to com/d2lang/d2/d2renderers/d2sketch can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2sketch uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2sketch uses com/d2lang/d2/lib/svg, so a change to com/d2lang/d2/lib/svg can break com/d2lang/d2/d2renderers/d2sketch, while a change to com/d2lang/d2/d2renderers/d2sketch can't break com/d2lang/d2/lib/svg.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2sketch uses a module listed above it, which is the healthy direction.
17→31 com/d2lang/d2/d2renderers/d2sketch uses com/d2lang/d2/d2targetpart of a loop✕
Connections
3 pairs of types, where a type in com/d2lang/d2/d2renderers/d2sketch uses a type in com/d2lang/d2/d2target.
com/d2lang/d2/d2renderers/d2sketch uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2renderers/d2sketch, while a change to com/d2lang/d2/d2renderers/d2sketch can't break com/d2lang/d2/d2target.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
com/d2lang/d2/d2themes uses com/d2lang/d2/lib/svg, so a change to com/d2lang/d2/lib/svg can break com/d2lang/d2/d2themes, while a change to com/d2lang/d2/d2themes can't break com/d2lang/d2/lib/svg.
Position
Below the diagonal: com/d2lang/d2/d2themes uses a module listed above it, which is the healthy direction.
18→31 com/d2lang/d2/d2themes uses com/d2lang/d2/d2targetpart of a loop✕
Connections
2 pairs of types, where a type in com/d2lang/d2/d2themes uses a type in com/d2lang/d2/d2target.
com/d2lang/d2/d2themes uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2themes, while a change to com/d2lang/d2/d2themes can't break com/d2lang/d2/d2target.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
43 pairs of types, where a type in com/d2lang/d2/lib/shape uses a type in com/d2lang/d2/lib/geo. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
com/d2lang/d2/lib/shape uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/lib/shape, while a change to com/d2lang/d2/lib/shape can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/lib/shape uses a module listed above it, which is the healthy direction.
com/d2lang/d2/lib/shape uses com/d2lang/d2/lib/svg, so a change to com/d2lang/d2/lib/svg can break com/d2lang/d2/lib/shape, while a change to com/d2lang/d2/lib/shape can't break com/d2lang/d2/lib/svg.
Position
Below the diagonal: com/d2lang/d2/lib/shape uses a module listed above it, which is the healthy direction.
54 pairs of types, where a type in com/d2lang/d2/d2ir uses a type in com/d2lang/d2/d2ast. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
com/d2lang/d2/d2ir uses com/d2lang/d2/d2ast, so a change to com/d2lang/d2/d2ast can break com/d2lang/d2/d2ir, while a change to com/d2lang/d2/d2ir can't break com/d2lang/d2/d2ast.
Position
Below the diagonal: com/d2lang/d2/d2ir uses a module listed above it, which is the healthy direction.
30 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape uses a type in com/d2lang/d2/lib/geo. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape uses com/d2lang/d2/lib/label, so a change to com/d2lang/d2/lib/label can break com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape can't break com/d2lang/d2/lib/label.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape uses com/d2lang/d2/lib/shape, so a change to com/d2lang/d2/lib/shape can break com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape can't break com/d2lang/d2/lib/shape.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape uses a module listed above it, which is the healthy direction.
com/d2lang/d2/lib/textmeasure uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/lib/textmeasure, while a change to com/d2lang/d2/lib/textmeasure can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/lib/textmeasure uses a module listed above it, which is the healthy direction.
com/d2lang/d2/lib/textmeasure uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/lib/textmeasure, while a change to com/d2lang/d2/lib/textmeasure can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/lib/textmeasure uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a module listed above it, which is the healthy direction.
2 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds.
com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds can break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can't break com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses com/d2lang/d2/lib/label, so a change to com/d2lang/d2/lib/label can break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can't break com/d2lang/d2/lib/label.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a module listed above it, which is the healthy direction.
7 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/limits.
com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses com/d2lang/d2/d2layouts/d2talalayout/internal/limits, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/limits can break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can't break com/d2lang/d2/d2layouts/d2talalayout/internal/limits.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses com/d2lang/d2/lib/shape, so a change to com/d2lang/d2/lib/shape can break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can't break com/d2lang/d2/lib/shape.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a module listed above it, which is the healthy direction.
3 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape.
com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape can break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can't break com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph uses a module listed above it, which is the healthy direction.
52 pairs of types, where a type in com/d2lang/d2/d2renderers/d2scenebuild uses a type in com/d2lang/d2/d2renderers/d2scene. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2renderers/d2scene, so a change to com/d2lang/d2/d2renderers/d2scene can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/d2renderers/d2scene.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2renderers/internal/fontface, so a change to com/d2lang/d2/d2renderers/internal/fontface can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/d2renderers/internal/fontface.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/lib/imageasset, so a change to com/d2lang/d2/lib/imageasset can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/lib/imageasset.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2renderers/d2svgimport, so a change to com/d2lang/d2/d2renderers/d2svgimport can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/d2renderers/d2svgimport.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2renderers/internal/fontfallback, so a change to com/d2lang/d2/d2renderers/internal/fontfallback can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/d2renderers/internal/fontfallback.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/lib/label, so a change to com/d2lang/d2/lib/label can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/lib/label.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/lib/svg, so a change to com/d2lang/d2/lib/svg can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/lib/svg.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2renderers/d2sketch, so a change to com/d2lang/d2/d2renderers/d2sketch can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/d2renderers/d2sketch.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2themes, so a change to com/d2lang/d2/d2themes can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/d2themes.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/lib/shape, so a change to com/d2lang/d2/lib/shape can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/lib/shape.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/lib/textmeasure, so a change to com/d2lang/d2/lib/textmeasure can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/lib/textmeasure.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2scenebuild uses a module listed above it, which is the healthy direction.
24→31 com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2targetpart of a loop✕
Connections
16 pairs of types, where a type in com/d2lang/d2/d2renderers/d2scenebuild uses a type in com/d2lang/d2/d2target.
com/d2lang/d2/d2renderers/d2scenebuild uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2renderers/d2scenebuild, while a change to com/d2lang/d2/d2renderers/d2scenebuild can't break com/d2lang/d2/d2target.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses a module listed above it, which is the healthy direction.
4 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/limits.
com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses com/d2lang/d2/d2layouts/d2talalayout/internal/limits, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/limits can break com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy can't break com/d2lang/d2/d2layouts/d2talalayout/internal/limits.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses a module listed above it, which is the healthy direction.
1 pair of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape.
com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape can break com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy can't break com/d2lang/d2/d2layouts/d2talalayout/internal/nodeshape.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses a module listed above it, which is the healthy direction.
12 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can break com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy can't break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/hierarchy uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout/internal/labeling uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2layouts/d2talalayout/internal/labeling, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/labeling can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/labeling uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout/internal/labeling uses com/d2lang/d2/lib/label, so a change to com/d2lang/d2/lib/label can break com/d2lang/d2/d2layouts/d2talalayout/internal/labeling, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/labeling can't break com/d2lang/d2/lib/label.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/labeling uses a module listed above it, which is the healthy direction.
11 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/labeling uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
com/d2lang/d2/d2layouts/d2talalayout/internal/labeling uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can break com/d2lang/d2/d2layouts/d2talalayout/internal/labeling, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/labeling can't break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/labeling uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2layouts/d2talalayout/internal/packing, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/packing can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses a module listed above it, which is the healthy direction.
1 pair of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds.
com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds can break com/d2lang/d2/d2layouts/d2talalayout/internal/packing, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/packing can't break com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses a module listed above it, which is the healthy direction.
2 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/limits.
com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses com/d2lang/d2/d2layouts/d2talalayout/internal/limits, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/limits can break com/d2lang/d2/d2layouts/d2talalayout/internal/packing, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/packing can't break com/d2lang/d2/d2layouts/d2talalayout/internal/limits.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses a module listed above it, which is the healthy direction.
14 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can break com/d2lang/d2/d2layouts/d2talalayout/internal/packing, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/packing can't break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/packing uses a module listed above it, which is the healthy direction.
40 pairs of types, where a type in com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a type in com/d2lang/d2/d2renderers/d2scene. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/d2renderers/d2scene, so a change to com/d2lang/d2/d2renderers/d2scene can break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, while a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can't break com/d2lang/d2/d2renderers/d2scene.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/d2renderers/internal/fontface, so a change to com/d2lang/d2/d2renderers/internal/fontface can break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, while a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can't break com/d2lang/d2/d2renderers/internal/fontface.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/lib/imageasset, so a change to com/d2lang/d2/lib/imageasset can break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, while a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can't break com/d2lang/d2/lib/imageasset.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/d2renderers/d2raster, so a change to com/d2lang/d2/d2renderers/d2raster can break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, while a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can't break com/d2lang/d2/d2renderers/d2raster.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/d2renderers/d2svgimport, so a change to com/d2lang/d2/d2renderers/d2svgimport can break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, while a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can't break com/d2lang/d2/d2renderers/d2svgimport.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, while a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/d2renderers/d2scenebuild, so a change to com/d2lang/d2/d2renderers/d2scenebuild can break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, while a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can't break com/d2lang/d2/d2renderers/d2scenebuild.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a module listed above it, which is the healthy direction.
28→31 com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/d2targetpart of a loop✕
Connections
13 pairs of types, where a type in com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses a type in com/d2lang/d2/d2target.
com/d2lang/d2/d2renderers/d2isometric/d2isometricimg uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, while a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can't break com/d2lang/d2/d2target.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2layouts/d2talalayout/internal/routing, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/routing can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses a module listed above it, which is the healthy direction.
1 pair of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds.
com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds can break com/d2lang/d2/d2layouts/d2talalayout/internal/routing, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/routing can't break com/d2lang/d2/d2layouts/d2talalayout/internal/graphbounds.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses a module listed above it, which is the healthy direction.
42 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can break com/d2lang/d2/d2layouts/d2talalayout/internal/routing, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/routing can't break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses a module listed above it, which is the healthy direction.
2 pairs of types, where a type in com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses a type in com/d2lang/d2/d2layouts/d2talalayout/internal/labeling.
com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses com/d2lang/d2/d2layouts/d2talalayout/internal/labeling, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/labeling can break com/d2lang/d2/d2layouts/d2talalayout/internal/routing, while a change to com/d2lang/d2/d2layouts/d2talalayout/internal/routing can't break com/d2lang/d2/d2layouts/d2talalayout/internal/labeling.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout/internal/routing uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/lib/label, so a change to com/d2lang/d2/lib/label can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/lib/label.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/lib/svg, so a change to com/d2lang/d2/lib/svg can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/lib/svg.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/d2themes, so a change to com/d2lang/d2/d2themes can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/d2themes.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/lib/shape, so a change to com/d2lang/d2/lib/shape can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/lib/shape.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/lib/textmeasure, so a change to com/d2lang/d2/lib/textmeasure can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/lib/textmeasure.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svg uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, so a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2svg uses a module listed above it, which is the healthy direction.
30→31 com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/d2targetpart of a loop✕
Connections
7 pairs of types, where a type in com/d2lang/d2/d2renderers/d2svg uses a type in com/d2lang/d2/d2target.
com/d2lang/d2/d2renderers/d2svg uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2renderers/d2svg, while a change to com/d2lang/d2/d2renderers/d2svg can't break com/d2lang/d2/d2target.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
com/d2lang/d2/d2target uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2target, while a change to com/d2lang/d2/d2target can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2target uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2target uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/d2target, while a change to com/d2lang/d2/d2target can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/d2target uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2target uses com/d2lang/d2/d2renderers/d2svg, so a change to com/d2lang/d2/d2renderers/d2svg can break com/d2lang/d2/d2target, while a change to com/d2lang/d2/d2target can't break com/d2lang/d2/d2renderers/d2svg.
Position
Below the diagonal: com/d2lang/d2/d2target uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2graph uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2graph, while a change to com/d2lang/d2/d2graph can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2graph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2graph uses com/d2lang/d2/lib/label, so a change to com/d2lang/d2/lib/label can break com/d2lang/d2/d2graph, while a change to com/d2lang/d2/d2graph can't break com/d2lang/d2/lib/label.
Position
Below the diagonal: com/d2lang/d2/d2graph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2graph uses com/d2lang/d2/d2ast, so a change to com/d2lang/d2/d2ast can break com/d2lang/d2/d2graph, while a change to com/d2lang/d2/d2graph can't break com/d2lang/d2/d2ast.
Position
Below the diagonal: com/d2lang/d2/d2graph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2graph uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/d2graph, while a change to com/d2lang/d2/d2graph can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/d2graph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2graph uses com/d2lang/d2/d2themes, so a change to com/d2lang/d2/d2themes can break com/d2lang/d2/d2graph, while a change to com/d2lang/d2/d2graph can't break com/d2lang/d2/d2themes.
Position
Below the diagonal: com/d2lang/d2/d2graph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2graph uses com/d2lang/d2/lib/shape, so a change to com/d2lang/d2/lib/shape can break com/d2lang/d2/d2graph, while a change to com/d2lang/d2/d2graph can't break com/d2lang/d2/lib/shape.
Position
Below the diagonal: com/d2lang/d2/d2graph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2graph uses com/d2lang/d2/lib/textmeasure, so a change to com/d2lang/d2/lib/textmeasure can break com/d2lang/d2/d2graph, while a change to com/d2lang/d2/d2graph can't break com/d2lang/d2/lib/textmeasure.
Position
Below the diagonal: com/d2lang/d2/d2graph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2graph uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2graph, while a change to com/d2lang/d2/d2graph can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2graph uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2ascii/asciiroute uses com/d2lang/d2/d2renderers/d2ascii/charset, so a change to com/d2lang/d2/d2renderers/d2ascii/charset can break com/d2lang/d2/d2renderers/d2ascii/asciiroute, while a change to com/d2lang/d2/d2renderers/d2ascii/asciiroute can't break com/d2lang/d2/d2renderers/d2ascii/charset.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii/asciiroute uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2ascii/asciiroute uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2renderers/d2ascii/asciiroute, while a change to com/d2lang/d2/d2renderers/d2ascii/asciiroute can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii/asciiroute uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2ascii/asciiroute uses com/d2lang/d2/d2renderers/d2ascii/asciicanvas, so a change to com/d2lang/d2/d2renderers/d2ascii/asciicanvas can break com/d2lang/d2/d2renderers/d2ascii/asciiroute, while a change to com/d2lang/d2/d2renderers/d2ascii/asciiroute can't break com/d2lang/d2/d2renderers/d2ascii/asciicanvas.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii/asciiroute uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2ascii/asciiroute uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2renderers/d2ascii/asciiroute, while a change to com/d2lang/d2/d2renderers/d2ascii/asciiroute can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii/asciiroute uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2renderers/d2scene, so a change to com/d2lang/d2/d2renderers/d2scene can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2renderers/d2scene.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/lib/imageasset, so a change to com/d2lang/d2/lib/imageasset can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/lib/imageasset.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2renderers/d2raster, so a change to com/d2lang/d2/d2renderers/d2raster can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2renderers/d2raster.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2renderers/d2svgimport, so a change to com/d2lang/d2/d2renderers/d2svgimport can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2renderers/d2svgimport.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/lib/textmeasure, so a change to com/d2lang/d2/lib/textmeasure can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/lib/textmeasure.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2renderers/d2scenebuild, so a change to com/d2lang/d2/d2renderers/d2scenebuild can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2renderers/d2scenebuild.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2renderers/d2isometric/d2isometricimg, so a change to com/d2lang/d2/d2renderers/d2isometric/d2isometricimg can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2renderers/d2isometric/d2isometricimg.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2renderers/d2svg, so a change to com/d2lang/d2/d2renderers/d2svg can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2renderers/d2svg.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2cli uses com/d2lang/d2/d2graph, so a change to com/d2lang/d2/d2graph can break com/d2lang/d2/d2cli, while a change to com/d2lang/d2/d2cli can't break com/d2lang/d2/d2graph.
Position
Below the diagonal: com/d2lang/d2/d2cli uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2compiler uses com/d2lang/d2/d2ast, so a change to com/d2lang/d2/d2ast can break com/d2lang/d2/d2compiler, while a change to com/d2lang/d2/d2compiler can't break com/d2lang/d2/d2ast.
Position
Below the diagonal: com/d2lang/d2/d2compiler uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2compiler uses com/d2lang/d2/d2ir, so a change to com/d2lang/d2/d2ir can break com/d2lang/d2/d2compiler, while a change to com/d2lang/d2/d2compiler can't break com/d2lang/d2/d2ir.
Position
Below the diagonal: com/d2lang/d2/d2compiler uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2compiler uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2compiler, while a change to com/d2lang/d2/d2compiler can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2compiler uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2compiler uses com/d2lang/d2/d2graph, so a change to com/d2lang/d2/d2graph can break com/d2lang/d2/d2compiler, while a change to com/d2lang/d2/d2compiler can't break com/d2lang/d2/d2graph.
Position
Below the diagonal: com/d2lang/d2/d2compiler uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2exporter uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/d2exporter, while a change to com/d2lang/d2/d2exporter can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/d2exporter uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2exporter uses com/d2lang/d2/d2themes, so a change to com/d2lang/d2/d2themes can break com/d2lang/d2/d2exporter, while a change to com/d2lang/d2/d2exporter can't break com/d2lang/d2/d2themes.
Position
Below the diagonal: com/d2lang/d2/d2exporter uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2exporter uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2exporter, while a change to com/d2lang/d2/d2exporter can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2exporter uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2exporter uses com/d2lang/d2/d2graph, so a change to com/d2lang/d2/d2graph can break com/d2lang/d2/d2exporter, while a change to com/d2lang/d2/d2exporter can't break com/d2lang/d2/d2graph.
Position
Below the diagonal: com/d2lang/d2/d2exporter uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2js/d2wasm uses com/d2lang/d2/d2ast, so a change to com/d2lang/d2/d2ast can break com/d2lang/d2/d2js/d2wasm, while a change to com/d2lang/d2/d2js/d2wasm can't break com/d2lang/d2/d2ast.
Position
Below the diagonal: com/d2lang/d2/d2js/d2wasm uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2js/d2wasm uses com/d2lang/d2/lib/textmeasure, so a change to com/d2lang/d2/lib/textmeasure can break com/d2lang/d2/d2js/d2wasm, while a change to com/d2lang/d2/d2js/d2wasm can't break com/d2lang/d2/lib/textmeasure.
Position
Below the diagonal: com/d2lang/d2/d2js/d2wasm uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2js/d2wasm uses com/d2lang/d2/d2renderers/d2svg, so a change to com/d2lang/d2/d2renderers/d2svg can break com/d2lang/d2/d2js/d2wasm, while a change to com/d2lang/d2/d2js/d2wasm can't break com/d2lang/d2/d2renderers/d2svg.
Position
Below the diagonal: com/d2lang/d2/d2js/d2wasm uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2js/d2wasm uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2js/d2wasm, while a change to com/d2lang/d2/d2js/d2wasm can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2js/d2wasm uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2js/d2wasm uses com/d2lang/d2/d2graph, so a change to com/d2lang/d2/d2graph can break com/d2lang/d2/d2js/d2wasm, while a change to com/d2lang/d2/d2js/d2wasm can't break com/d2lang/d2/d2graph.
Position
Below the diagonal: com/d2lang/d2/d2js/d2wasm uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2layouts/d2talalayout, while a change to com/d2lang/d2/d2layouts/d2talalayout can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout uses com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph, so a change to com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph can break com/d2lang/d2/d2layouts/d2talalayout, while a change to com/d2lang/d2/d2layouts/d2talalayout can't break com/d2lang/d2/d2layouts/d2talalayout/internal/layoutgraph.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2layouts/d2talalayout, while a change to com/d2lang/d2/d2layouts/d2talalayout can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2layouts/d2talalayout uses com/d2lang/d2/d2graph, so a change to com/d2lang/d2/d2graph can break com/d2lang/d2/d2layouts/d2talalayout, while a change to com/d2lang/d2/d2layouts/d2talalayout can't break com/d2lang/d2/d2graph.
Position
Below the diagonal: com/d2lang/d2/d2layouts/d2talalayout uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2lib uses com/d2lang/d2/lib/geo, so a change to com/d2lang/d2/lib/geo can break com/d2lang/d2/d2lib, while a change to com/d2lang/d2/d2lib can't break com/d2lang/d2/lib/geo.
Position
Below the diagonal: com/d2lang/d2/d2lib uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2lib uses com/d2lang/d2/d2ast, so a change to com/d2lang/d2/d2ast can break com/d2lang/d2/d2lib, while a change to com/d2lang/d2/d2lib can't break com/d2lang/d2/d2ast.
Position
Below the diagonal: com/d2lang/d2/d2lib uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2lib uses com/d2lang/d2/d2renderers/d2fonts, so a change to com/d2lang/d2/d2renderers/d2fonts can break com/d2lang/d2/d2lib, while a change to com/d2lang/d2/d2lib can't break com/d2lang/d2/d2renderers/d2fonts.
Position
Below the diagonal: com/d2lang/d2/d2lib uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2lib uses com/d2lang/d2/lib/textmeasure, so a change to com/d2lang/d2/lib/textmeasure can break com/d2lang/d2/d2lib, while a change to com/d2lang/d2/d2lib can't break com/d2lang/d2/lib/textmeasure.
Position
Below the diagonal: com/d2lang/d2/d2lib uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2lib uses com/d2lang/d2/d2renderers/d2svg, so a change to com/d2lang/d2/d2renderers/d2svg can break com/d2lang/d2/d2lib, while a change to com/d2lang/d2/d2lib can't break com/d2lang/d2/d2renderers/d2svg.
Position
Below the diagonal: com/d2lang/d2/d2lib uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2lib uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2lib, while a change to com/d2lang/d2/d2lib can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2lib uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2lib uses com/d2lang/d2/d2graph, so a change to com/d2lang/d2/d2graph can break com/d2lang/d2/d2lib, while a change to com/d2lang/d2/d2lib can't break com/d2lang/d2/d2graph.
Position
Below the diagonal: com/d2lang/d2/d2lib uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2ascii uses com/d2lang/d2/d2renderers/d2ascii/charset, so a change to com/d2lang/d2/d2renderers/d2ascii/charset can break com/d2lang/d2/d2renderers/d2ascii, while a change to com/d2lang/d2/d2renderers/d2ascii can't break com/d2lang/d2/d2renderers/d2ascii/charset.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2ascii uses com/d2lang/d2/d2renderers/d2ascii/asciicanvas, so a change to com/d2lang/d2/d2renderers/d2ascii/asciicanvas can break com/d2lang/d2/d2renderers/d2ascii, while a change to com/d2lang/d2/d2renderers/d2ascii can't break com/d2lang/d2/d2renderers/d2ascii/asciicanvas.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2ascii uses com/d2lang/d2/d2target, so a change to com/d2lang/d2/d2target can break com/d2lang/d2/d2renderers/d2ascii, while a change to com/d2lang/d2/d2renderers/d2ascii can't break com/d2lang/d2/d2target.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii uses a module listed above it, which is the healthy direction.
com/d2lang/d2/d2renderers/d2ascii uses com/d2lang/d2/d2renderers/d2ascii/asciiroute, so a change to com/d2lang/d2/d2renderers/d2ascii/asciiroute can break com/d2lang/d2/d2renderers/d2ascii, while a change to com/d2lang/d2/d2renderers/d2ascii can't break com/d2lang/d2/d2renderers/d2ascii/asciiroute.
Position
Below the diagonal: com/d2lang/d2/d2renderers/d2ascii uses a module listed above it, which is the healthy direction.
At a glance — Code Health · 77% · Adequate · gated by D1, D2 ·
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
35
Medium
A02:2025 — Security Misconfiguration
4
Medium
A03:2025 — Software Supply Chain Failures
3
Medium
A07:2025 — Authentication Failures
2
High / Critical
Roadmap
First, integrate automated security scanning into the CI pipeline to block regressions and resolve the single stale dependency commit. Next, enforce accessibility standards by adding invariant checks to existing tests and ensuring visual elements meet contrast and motion safety requirements. Finally, enhance operational visibility by implementing health checks and adopting OpenTelemetry for tracing and metrics.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Resolve the 1 Dependency pinned to a stale untagged commit finding(s) in Dependency Hygiene.
Add a SAST step to CI running what this repository's stack ships: gosec / govulncheck (or golangci-lint) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Enforce accessibility in the test suite you already have: assert the accessibility invariants over the HTML your app renders — parse the rendered output in an existing test, or drive a real browser from one — and gate that test in CI so a regression blocks the merge.
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.
Bring the 1040 bodies over 15 down to 15 or less in Cognitive Complexity — start with placementcost.evaluateNodeEdgeLength (cognitive 819), packing.packGuarded (cognitive 718), ovgEdgeRouter.search (cognitive 683).
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 — 2
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 — 2884
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 — 65
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 15
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. 66 of 69 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 3 documentation/naming judgement(s) are LLM-assisted and labelled advisory. Overall confidence is 0.9 — 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 — 69 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, 2928 of 2951 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.
D10 Test Quality — 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. The 50 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 590 test source file(s) (.go) that it cannot: it reads JavaScript/TypeScript test declarations off disk, so a JUnit/pytest-style suite is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
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 bun:test suite in d2js/js/ aborted while loading its own test files, before a single case could run (bun test v1.3.14 (0d9b296a)). This is OUR limitation, not a defect in the repo — it is excluded from the score.
D22 Internal API Consistency — 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. D22 identifies the intentionally-exposed surface from `IsPackable` and `.Contracts` project names, MSBuild conventions read off the loaded project set. This target exposed no such projects, so the probe never ran; this says nothing about whether the repository has a public API. This repository commits no C#/VB source at all, so there was never an MSBuild project set to read these conventions off. That is OUR side and it is a COLLECTOR gap, not an environment fault: it declares a published package (REDACTED), but no published-package marker D22 reads admitted any project here, so this ecosystem's public API has no collector, and the remedy is to write one — no change to the scan image can close it.
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.
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. `d2js/js/src/platform.browser.js`, `d2layouts/d2talalayout/adapter.go`, `d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go`, `d2layouts/d2talalayout/internal/packing/combine.go`, `d2layouts/d2talalayout/internal/routing/snapshot.go`, … (+1 more) 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.
AXR1 Runtime accessibility — 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. Render strategy: boot via REDACTED (REDACTED). docker build failed (exit 1) — DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
Install the buildx component to build images with BuildKit:
https://docs.docker.com/go/bui…; runtime evidence skipped.
C1 Data Protection — 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. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
C2 Access Controls — 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. These authorization controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks authorization controls.
C3 Audit Trail — 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. These audit controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks audit controls.
C4 Data Retention — 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. These retention controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks retention controls.
C5 Data-Subject Rights — 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. These data-subject rights controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks data-subject rights controls.
ED5 Idempotency — 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 decides whether a handler's mutation is safe to re-run by recognising its persistence writes (a database save, a repository write, an event publish) and its guards. Those markers are .NET member names, so in this repository's language a write such as `repository.save(order)` is not recognised and a same-named call on an unrelated library type could be. The handlers were found; their idempotency was neither confirmed nor ruled out.
GD1 Unfinished & placeholder code — 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, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and this repository's Go, Python is most of its product and is not read yet, 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.
IC1 Incompleteness & stubs — 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, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and this repository's Go, Python is most of its product and is not read yet, 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.
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 no production persistence was detected either (no data-access packages, no data-store services, no database resources), so there is nothing in this repository whose loss a DR control would recover. If this system's data lives in a platform or ops repo we can't see, that's where the DR evidence belongs.
S1 Web-Security Posture — 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. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
X3 Exception handling — 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. 1 further occurrence(s) are not listed individually; the score already reflects all 41.
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.
X5 Nullable reference types — 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 MSBuild project configuration, TypeScript source and its tsconfig files, Java source and its package and module declarations, PHP source and its PHPStan and Psalm configuration, Dart source and its pubspec language version, Ruby source and its Sorbet and Steep configuration, Scala source and its build's explicit-nulls, WartRemover and Scalafix settings, and Kotlin source only, and no C# was loaded, no TypeScript was found, and this repository's Python is not read yet, 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: 10 pattern(s) declared (.gitattributes linguist-generated/vendored, .editorconfig generated_code) excluded 0 source file(s) from code-quality scoring. Declarations are the repo's own visible statement that a tree is machine-written or vendored — auditable in any diff, honored by GitHub the same way.
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.
D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
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.
D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
D13 REDACTED Scanning: REDACTED 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").
D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
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.
D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
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.
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.
D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
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 REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (REDACTED, 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 (3): D19, D21, 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.
741 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was placementcost.evaluateNodeEdgeLength at 268. A further 17 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 label.FromString at 37 — they are counted neither in the figure above nor in this dimension's score. 4 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold functions was excluded, so the exclusion is disclosed nowhere in the file itself: lib/label/label.go (label.FromString at 37), d2layouts/d2talalayout/internal/nodeshape/shape.go (nodeshape.New at 25), lib/shape/shape.go (shape.NewShape at 24), d2renderers/d2scenebuild/latex.go (builder.validateLatexImportOptions at 19). They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.
+ 736 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 62 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with placementcost.evaluateNodeEdgeLength (cyclomatic 268), packing.packGuarded (cyclomatic 250), ovgEdgeRouter.search (cyclomatic 230). — 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 62 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.
+ 1035 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 1040 bodies over 15 down to 15 or less in Cognitive Complexity — start with placementcost.evaluateNodeEdgeLength (cognitive 819), packing.packGuarded (cognitive 718), ovgEdgeRouter.search (cognitive 683). — 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 1040 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 Classes6.8 / 10Adequate✓ 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.
+ 1 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 83 FunctionTooLong finding(s) in God Classes — start with d2svg.go (8), edit.go (5), layout.go (4). — One of this dimension's main actionable groups (83 warning-level).
Resolve the 62 FileTooLong finding(s) in God Classes — start with layout.go (4), raster.go (3), REDACTED (2). — One of this dimension's main actionable groups (62 warning-level).
Resolve the 49 MethodTooLong finding(s) in God Classes — start with REDACTED (7), text.go (3), transaction.go (3). — One of this dimension's main actionable groups (49 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: Copy-pasted code that should be shared instead.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.
583 duplicated block group(s) detected. A further 35 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted.
+ 160 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 54 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with d2svg.go (4), optimization_guard.go (3), filter.go (3). — One of this dimension's main actionable groups (54 warning-level).
Resolve the 36 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with ovg_hierarchy.go (2), effects.go (2), REDACTED (2). — One of this dimension's main actionable groups (36 warning-level).
Resolve the 35 Duplicated block (12 lines × 2) finding(s) in Code Duplication — start with effects.go (3), REDACTED (2), layout.go (2). — One of this dimension's main actionable groups (35 warning-level).
Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d4_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.
Resolve the 4 Low cohesion finding(s) in Cohesion (LCOM4) — start with node.go, d2graph.go, edge.go. — One of this dimension's main actionable groups (4 warning-level).
Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
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.
2866 test methods: 2848 unit, 17 integration, 0 BDD, 1 e2e. The JavaScript/TypeScript suite contributes 50 `it`/`test` case(s) across 7 test file(s) declaring at least one; its tier split is read from package names and paths only. The Python suite contributes 37 test function(s) across 2 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only. The Go suite contributes 2779 test case(s) across 529 `_test.go` file(s) declaring at least one — every `func Test…(t *testing.T)` that `go test` would collect, plus the suite methods a testify-style runner reaches; a table-driven case list counts once, so this is a floor. Its tier split is INFERRED from file names, paths and build constraints, not declared: 68 of those file(s) use Go's external test package (`package x_test`), which is a visibility boundary rather than a pyramid tier and was not read as one.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality10.0 / 10Exemplary✓ 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.
0 skipped, 0 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 50 tests. Measured on the JavaScript/TypeScript suite only — at least 590 test source file(s) (.go) went unread, so its test quality is unmeasured and is not in these counts.
What it measures: Whether dependencies are current, secure, and not bloated.
Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.
11 outdated, 0 author-deprecated direct Go module(s), 1 pinning or checksum defect(s). 24 of 24 direct requirement(s) were graded against proxy.golang.org (0 not served there, 1 publishing no tagged release to be behind). Whether any of these modules is UNMAINTAINED is not graded — proxy.golang.org publishes no maintenance status, and release age does not stand in for one. Whether any is UNUSED is not graded either: that is a source question, not a registry one. Known CVEs in this module graph are D30's question, read from REDACTED and go.sum there.
Dependency pinned to a stale untagged commit: github.com/ericpauley/go-quantize
Outdated: github.com/PuerkitoBio/goquery · ×11
What to do
Resolve the 1 Dependency pinned to a stale untagged commit finding(s) in Dependency Hygiene. — One of this dimension's main actionable groups (1 warning-level).
Enforce Dependency Hygiene in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d12_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: Whether the licenses of third-party packages are compatible with your policy.
Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.
0 of 38 required Go module(s) use a banned license. Licences were read per module version from the licence files pkg.go.dev detects (via api.deps.dev), over every module this repository's REDACTED requires, direct and indirect, at the version the build uses. Go records no test-only scope at module level, so modules only this repository's own tests import are included.
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: d2cli/main.go (23×102=2346); d2renderers/d2svg/d2svg.go (18×102=1836); d2compiler/compile.go (14×78=1092)
Hotspot: d2cli/main.go · ×24d2cli/main.go:62
What to do
Resolve the 24 Hotspot finding(s) in Churn × Complexity Hotspots — start with REDACTED (2), layout.go (2), raster.go (2). — One of this dimension's main actionable groups (24 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 Factor8.2 / 10Strong✓ 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.
70 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is d2oracle/edit.go. Counted over 394 of the 596 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
What to do
Resolve the 1 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).
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.
151 deducted task-comment markers across 175454 LoC (0.1/KLoC) → score 9.8. 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.
TodoComment · ×151d2ast/keywords.go:79
What to do
Resolve the 151 TodoComment finding(s) in Explicit Debt — start with parse.go (30), edit.go (17), node.go (8). — One of this dimension's main actionable groups (151 warning-level).
Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
This repository's root README is a comprehensive multi-page document that opens with an engaging banner and links to cheat sheets, comparisons, and a live playground. It contains a full table of contents listing every directory (e.g., d2themes, e2etests, ci/nonlayout-perf) and their own sub-READMEs, so each one is judged against its own scope rather than the root's overview. The document is well structured with clear headings and an unbroken outline; it does not suffer from any of the named defects. The repository is well documented with a strong README for each directory (the d2layouts/d2talalayout/internal/testdata/README is the canonical one), an authoritative CONTRIBUTING.md covering welcome, CI, logistics, dev content, tests, and questions, and a dedicated INSTALL.md describing install.sh, security caveats, and every OS/native packaging method. The architecture document fully outlines TALA's runtime boundaries, internal package rules, ownership/mutation, context/errors, determinism, compatibility, and tests.
✓ On the Gold path — maintain.
Detailed fixes: d19_recommendation.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.
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.
1 of 1 build units (Go) 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: REDACTED 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.
1 finding(s): 0 critical, 1 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.
REDACTED
REDACTED
What to do
Resolve the 1 REDACTED finding(s) in Secrets (history) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.
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).
37 finding(s): 0 critical, 0 high, 29 medium, 8 low. semgrep hit a parse error in 14 file(s) — `ci/release/_build.sh` (line 21, line 32, line 36), `ci/release/build.sh` (line 102, line 103, line 151, …), `ci/release/checksum.sh` (line 15, line 61, line 73), `ci/release/docker/image.sh` (line 5), `d2js/js/ci/build.sh`, … (+9 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 2 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
+ 6 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 11 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (11 warning-level).
Resolve the 8 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (4), REDACTED (2), REDACTED. — One of this dimension's main actionable groups (8 warning-level).
Resolve the 4 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (4 warning-level).
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 osv.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.
Resolve the 2 Medium CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (2). — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
Resolve the 2 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (2). — One of this dimension's main actionable groups (2 warning-level).
Resolve the 2 Low IaC finding(s) in IaC & Container Security — start with REDACTED (2). — One of this dimension's main actionable groups (2 recommendation-level).
Detailed fixes: d31_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.
1 of 394 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is d2graph/layout.go. Counted over 394 of the 596 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Orphaned files with no living knowledge
Orphaned filed2graph/layout.go:1
✓ On the Gold path — maintain.
Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
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.
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.
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 1 platform declaration(s) and 0 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 alternatives10.0 / 10Exemplary○ Nothing flagged
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.
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.
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.
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.
`.md .anchor: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. — d2renderers/d2svg/github-markdown.css:358
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 automated accessibility check runs over the HTML your app renders. Assert the accessibility invariants over that HTML in the test suite you already have (parse the output and assert, or drive a browser), and gate that test in CI so a regression blocks the merge. What was searched, so you can tell an absence from a miss: the 1 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 test suite you already have: assert the accessibility invariants over the HTML your app renders — parse the rendered output in an existing test, or drive a real browser from one — and gate that test in CI so a regression blocks the merge.
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 singleton services avoid mutable shared instance state that concurrent callers would race on.
Method: Roslyn scan: singleton field mutations unguarded by lock or Interlocked, per type; syntax-based guard detection. Deterministic, traceable per field.
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 the codebase has a recognisable, scale-appropriate structure (a named architectural style, or modular enough for its size) rather than being an ad-hoc ball of mud.
Method: Roslyn plus csproj analysis: architecture style detection (DDD, clean, vertical-slice, CQRS) and structure fitness for repo size. Deterministic.
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.
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.
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.
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.
README.md links to `./CHANGELOG.md`, but `CHANGELOG.md` does not exist. 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.md:12
d2renderers/d2fonts/README.md names `./ttf/Helvetica-Bold.ttf`, but no file or folder `ttf/Helvetica-Bold.ttf` exists. 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. — d2renderers/d2fonts/README.md:7
d2renderers/d2fonts/README.md names `./ttf/Helvetica-Italic.ttf`, but no file or folder `ttf/Helvetica-Italic.ttf` exists. 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. — d2renderers/d2fonts/README.md:8
d2renderers/d2fonts/README.md names `./ttf/Helvetica-Regular.ttf`, but no file or folder `ttf/Helvetica-Regular.ttf` exists. 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. — d2renderers/d2fonts/README.md:9
d2renderers/d2fonts/README.md names `./ttf/Helvetica-Bold.txt`, but no file or folder `ttf/Helvetica-Bold.txt` exists. 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. — d2renderers/d2fonts/README.md:12
d2renderers/d2fonts/README.md names `./ttf/Helvetica-Italic.txt`, but no file or folder `ttf/Helvetica-Italic.txt` exists. 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. — d2renderers/d2fonts/README.md:13
d2renderers/d2fonts/README.md names `./ttf/Helvetica-Regular.txt`, but no file or folder `ttf/Helvetica-Regular.txt` exists. 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. — d2renderers/d2fonts/README.md:14
What to do
Reconcile the README with reality: README.md links to `./CHANGELOG.md`, but `CHANGELOG.md` does not exist; d2renderers/d2fonts/README.md names `./ttf/Helvetica-Bold.ttf`, but no file or folder `ttf/Helvetica-Bold.ttf` exists; d2renderers/d2fonts/README.md names `./ttf/Helvetica-Italic.ttf`, but no file or folder `ttf/Helvetica-Italic.ttf` exists; d2renderers/d2fonts/README.md names `./ttf/Helvetica-Regular.ttf`, but no file or folder `ttf/Helvetica-Regular.ttf` exists; d2renderers/d2fonts/README.md names `./ttf/Helvetica-Bold.txt`, but no file or folder `ttf/Helvetica-Bold.txt` exists.
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.
Do you agree with this assessment?
P2 · Observability7.0 / 10Strong✓ Tool-verified
Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.
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.
No static application security testing detected. For this repository's stack, add gosec / govulncheck (or golangci-lint) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 35793 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
What to do
Add a SAST step to CI running what this repository's stack ships: gosec / govulncheck (or golangci-lint) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Enable Dependabot/Renovate or a dependency-review gate.
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.
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 the code is written to minimise allocations so it doesn't pressure its host's memory manager — buffer/slice views over copies, object pooling, stack or value-type allocation, and buffer writers. Reward-only: credited where present, never penalised where a simpler style is fine.
Method: Production-source scan: density (per 1k LoC) of allocation-aware APIs — in .NET Span/Memory, ArrayPool/ObjectPool, stackalloc, ValueTask, value-type structs, IBufferWriter, string.Create, SkipLocalsInit; off .NET, with comments and strings blanked, Go's sync.Pool, preallocated slices/maps, Grow, strconv.Append* and buf[:0] reuse; the JVM's NIO buffer views, MemorySegment, primitive collections, pools and literal presizes (plus Kotlin primitive arrays and value classes, Scala AnyVal and @specialized); Swift's reserveCapacity, ContiguousArray, withUnsafe* access and ~Copyable. Activated off .NET on the same floor (400 lines, and benchmarks or 8 uses); Rust and garbage-collected scripting languages are not applicable. Reward-only. Deterministic, syntax/text detection.
What to do
Raise allocation-aware density on the hot paths — currently 570 use(s) across 188,332 production line(s) (~3.0/1k). More of the idioms below on the allocation-heavy paths climbs this toward 10.
Go: on hot paths, reuse buffers and objects through sync.Pool, preallocate slices and maps with make([]T, 0, n) / make(map[K]V, n), size builders with Grow, append with strconv.Append*, and reslice with buf[:0] instead of allocating anew.
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 document10.0 / 10Exemplary○ Nothing flagged
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.
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 functions that make a cancellable request accept or pass on a context.Context (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.
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.
Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.
Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.
Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. 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.
`if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×35) — REDACTED:727, d2compiler/compile.go:1736, d2exporter/export.go:300, …
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. — d2js/d2wasm/api.go:32
`if captureErr != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:382
`if readErr != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — d2renderers/d2fonts/fallback.go:399
`if _, err := face.Outline.LoadGlyph(&buffer, outlineGlyph, fixed.I(1_000), nil); err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — d2renderers/internal/fontface/face.go:227
`if _, err := outline.LoadGlyph(&buffer, outlineGlyph, fixed.I(1_000), nil); err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — d2renderers/internal/fontface/face.go:476
What to do
Swallowed exception (caught, then discarded)
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 — 3 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.
X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X6 Hand-rolled structured-format parsing — 1 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 4 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 4 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.
C3 Audit Trail — Not assessed: these audit controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) 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. Absence of an idiom this check recognises is NOT evidence that this repository lacks audit controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C4 Data Retention — Not assessed: these retention controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) 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. Absence of an idiom this check recognises is NOT evidence that this repository lacks retention controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C5 Data-Subject Rights — Not assessed: these data-subject rights controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) 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. Absence of an idiom this check recognises is NOT evidence that this repository lacks data-subject rights controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 45 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 Go 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.
AX4 Dependency direction — not applicable to a CQRS architecture (the inward-dependency rule is for layered/clean styles)
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
AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
AXR1 Runtime accessibility — docker build failed (exit 1) — DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
Install the buildx component to build images with BuildKit:
https://docs.docker.com/go/bui…; runtime evidence skipped This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) 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. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C2 Access Controls — Not assessed: these authorization controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) 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. Absence of an idiom this check recognises is NOT evidence that this repository lacks authorization controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
D11 Test Reliability — Test reliability not measured — JavaScript/TypeScript suite did not run
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.
D22 Internal API Consistency — The exposed public-API surface could not be collected — no C#/VB projects loaded.
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. Aggregate roots were found in only one source directory (d2raster), which is a layered codebase, not two contexts. 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 (.go), 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.
D32 Data Compliance (PII/GDPR) — 6 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
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.
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 Go 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 bun:test suite in d2js/js/ ran and not one test passed (bun test v1.3.14 (0d9b296a)), so the coverage would describe 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 — applicable but not scored (2 signals for this style, 2 needed — the count is met but a required primary signal is absent): 2 aggregate root(s) (types guarding their own state behind command methods — this language has no AggregateRoot base to inherit); 12 value object(s)
ED1 Event-Driven — applicable but not scored (2 of 3 signals for this style — below the bar we score at): 1 CQRS handler(s); 3 event-sourced shape(s) (event folds / event-recording aggregates)
ED5 Idempotency — Not assessed, and this one is on us: 1 command handler(s) or message consumer(s) were found here, but this check does not yet recognise persistence writes in this repository's language. Idempotency was neither confirmed nor ruled out — this is a limit of the analyzer, not a finding about your code.
ES1 Event Sourcing — not scored — this repository shows only 1 of the 3 signals this lens looks for (3 Go aggregate(s) recording domain events (own events-slice append / raise-record))
GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
IC1 Incompleteness & stubs — 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
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'.
P7 Outbound HTTP resilience — not applicable — no HTTP server, API framework or worker entry point was found in the Go, JavaScript/TypeScript, Python source, so there is no service whose uptime a failing dependency could take down
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 (`go test -coverprofile=coverage.out ./...`) 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
PF3 Async & latency hygiene — Not applicable: Go has no async/await function colour, so there is no asynchronous code for a blocking call to stall.
S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) 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. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
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.
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 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
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.
Critical — 2 finding(s)
D11 · Test Reliability· Test suite aborts before any test executes · ×1
Test suite aborts before any test executes: d2js/js/ — The bun:test suite in d2js/js/ was installed and launched successfully, and then aborted while loading its own test files — the bun:test suite in d2js/js/ aborted while loading its own test files, before a single case could run (bun test v1.3.14 (0d9b296a)). Not one test case ran, so this suite cannot detect a regression and its presence overstates how much of this repository is tested. The module it asks for is named by a RELATIVE path, so it can only come from this repository: the file is missing from the tree, and committing it (or removing the spec that requires it) is the ask. This is not a report that the tests FAIL — they never started.
TodoComment d2ast/keywords.go:79— // TODO maybe autofmt should allow other values, and transform them to conform — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2ast/error.go:3— // TODO: Right now this is here to be available in both the Parser and Compiler but — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2ast/d2ast.go:1— // TODO: Remove boxes and cleanup like d2ir — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2ast/d2ast.go:42— // TODO: add error node for autofmt of incomplete AST — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2ast/d2ast.go:584— // TODO: mistake, move into parse.go — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2ast/d2ast.go:778— // TODO: require @ on import values for readability — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2ast/d2ast.go:1221— // TODO probably should be checking the values, but will wait until something breaks to change — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2ast/d2ast.go:1480— // TODO: implement ScalarString() — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment REDACTED:209— // TODO go back to using xrand.String, currently some incompatibility with — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment REDACTED:512— // TODO: Add cmdlog logging and error reporting middleware — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment REDACTED:513— // TODO: Add standard debug/profiling routes — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2cli/main_test.go:5— // TODO: Use virtual file system with fs.FS in xmain.State when fs.FS supports writes. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2cli/main.go:353— // TODO this is a temporary solution: https://github.com/d2lang/util-go/issues/7
TodoComment d2cli/main.go:901— // TODO it can if composed into one — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2compiler/compile.go:1373— // TODO add more, e.g. C, bash — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2compiler/compile.go:1423— // TODO: Not great, AST should easily allow specifying alternate primary field — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2format/format.go:11— // TODO: edges with shared path should be fmted as <rel>.(x -> y) — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2format/escape_test.go:294— // TODO: chaos test each — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2format/escape.go:16— // TODO: Unified string syntax. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2graph/d2graph.go:155— // TODO consider having different Scalar types — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2graph/d2graph.go:162— // TODO maybe rename to Shape — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2graph/d2graph.go:210— // TODO consider separate Attributes struct for shape-specific and edge-specific — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2graph/d2graph.go:214— // TODO: default to ShapeRectangle instead of empty string — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2graph/d2graph.go:774— // TODO: remove once not used anywhere — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment d2graph/d2graph.go:815— // TODO: remove edges []edge and scope each edge inside Object. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
FunctionTooLong: packing.packGuarded d2layouts/d2talalayout/internal/packing/binpack.go:65— FunctionTooLong — packGuarded runs 629 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 529 over it, 6.29× 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: placementcost.evaluateNodeEdgeLength d2layouts/d2talalayout/internal/placementcost/edge_length.go:345— FunctionTooLong — evaluateNodeEdgeLength runs 586 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 486 over it, 5.86× 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: layoutgraph.validateEngineGraph d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:510— FunctionTooLong — validateEngineGraph runs 507 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 407 over it, 5.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: d2svg.drawShape d2renderers/d2svg/d2svg.go:1688— FunctionTooLong — drawShape runs 418 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 318 over it, 4.18× 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: d2oracle._set d2oracle/edit.go:327— FunctionTooLong — _set runs 394 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 294 over it, 3.94× 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: graphjson.deserializeGraphContext REDACTED:1035— FunctionTooLong — deserializeGraphContext runs 308 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 208 over it, 3.08× 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: d2oracle.move d2oracle/edit.go:1765— FunctionTooLong — move runs 298 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 198 over it, 2.98× 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: placement.Dejitter d2layouts/d2talalayout/internal/placement/dejitter.go:16— FunctionTooLong — Dejitter runs 297 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 197 over it, 2.97× 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: d2elklayout.Layout d2layouts/d2elklayout/layout.go:257— FunctionTooLong — Layout runs 290 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 190 over it, 2.90× 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: labeling.place d2layouts/d2talalayout/internal/labeling/placement.go:28— FunctionTooLong — place runs 286 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 186 over it, 2.86× 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: d2svg.arrowheadMarker d2renderers/d2svg/d2svg.go:531— FunctionTooLong — arrowheadMarker runs 284 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 184 over it, 2.84× 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: d2cli.Run d2cli/main.go:62— FunctionTooLong — Run runs 276 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 176 over it, 2.76× 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: d2svg.renderValidated d2renderers/d2svg/d2svg.go:2896— FunctionTooLong — renderValidated runs 267 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 167 over it, 2.67× 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: d2talalayout.translateGraph d2layouts/d2talalayout/adapter.go:116— FunctionTooLong — translateGraph runs 264 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 164 over it, 2.64× 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: placement.reduceGapToNeighbors d2layouts/d2talalayout/internal/placement/gapreduction.go:273— FunctionTooLong — reduceGapToNeighbors runs 261 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 161 over it, 2.61× 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: layoutgraph.validateCombineNodeTopology d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:129— FunctionTooLong — validateCombineNodeTopology runs 258 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 158 over it, 2.58× 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: layoutgraph.collectRuntimeObjectsContext d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:362— FunctionTooLong — collectRuntimeObjectsContext runs 252 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 152 over it, 2.52× 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: routing.balanceRegularEdgesGuarded d2layouts/d2talalayout/internal/routing/postprocess.go:70— FunctionTooLong — balanceRegularEdgesGuarded runs 246 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 146 over it, 2.46× 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: routing.routeLineChecked d2layouts/d2talalayout/internal/routing/coordinator.go:844— FunctionTooLong — routeLineChecked runs 239 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 139 over it, 2.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: d2cli.compile d2cli/main.go:452— FunctionTooLong — compile runs 226 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 126 over it, 2.26× 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: grouping.AddClusters REDACTED:167— FunctionTooLong — AddClusters runs 224 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 124 over it, 2.24× 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: packing.CombineSubgraphs d2layouts/d2talalayout/internal/packing/combine.go:92— FunctionTooLong — CombineSubgraphs runs 220 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 120 over it, 2.20× 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: d2svg.drawConnection d2renderers/d2svg/d2svg.go:1079— FunctionTooLong — drawConnection runs 216 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 116 over it, 2.16× 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: graphjson.Serialize REDACTED:262— FunctionTooLong — Serialize runs 207 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 107 over it, 2.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: labeling.findBestEdgeLabelPosition d2layouts/d2talalayout/internal/labeling/placement.go:687— FunctionTooLong — findBestEdgeLabelPosition 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.
FileTooLong: d2svg/d2svg.go d2renderers/d2svg/d2svg.go— FileTooLong — 2497 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1997 over it, 4.99× 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: d2oracle/edit.go d2oracle/edit.go— FileTooLong — 2212 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1712 over it, 4.42× 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: REDACTED REDACTED— FileTooLong — 1566 significant lines (blank, comment-only and punctuation-only lines excluded), about 87% of them inside a single declaration: compiler (35 blocks, 33-2373). The bar is 500 significant lines; this is 1066 over it, 3.13× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: REDACTED REDACTED— FileTooLong — 1564 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1064 over it, 3.13× 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: textmeasure/markdown_svg.go lib/textmeasure/markdown_svg.go— FileTooLong — 1429 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 929 over it, 2.86× 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: layoutgraph/node.go d2layouts/d2talalayout/internal/layoutgraph/node.go— FileTooLong — 1428 significant lines (blank, comment-only and punctuation-only lines excluded), about 74% of them inside a single declaration: Node (86 blocks, 29-2443). The bar is 500 significant lines; this is 928 over it, 2.86× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: d2compiler/compile.go d2compiler/compile.go— FileTooLong — 1384 significant lines (blank, comment-only and punctuation-only lines excluded), about 75% of them inside a single declaration: compiler (31 blocks, 145-1998). The bar is 500 significant lines; this is 884 over it, 2.77× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: d2parser/parse.go d2parser/parse.go— FileTooLong — 1287 significant lines (blank, comment-only and punctuation-only lines excluded), about 87% of them inside a single declaration: parser (36 blocks, 159-1930). The bar is 500 significant lines; this is 787 over it, 2.57× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: d2graph/d2graph.go d2graph/d2graph.go— FileTooLong — 1286 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 786 over it, 2.57× 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: d2raster/effects.go d2renderers/d2raster/effects.go— FileTooLong — 1277 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 777 over it, 2.55× 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: routing/coordinator.go d2layouts/d2talalayout/internal/routing/coordinator.go— FileTooLong — 1269 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 769 over it, 2.54× 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: d2dagrelayout/layout.go d2layouts/d2dagrelayout/layout.go— FileTooLong — 1230 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 730 over it, 2.46× 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: xgif/xgif.go lib/xgif/xgif.go— FileTooLong — 1143 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 643 over it, 2.29× 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: routing/ovg_edge_router.go d2layouts/d2talalayout/internal/routing/ovg_edge_router.go— FileTooLong — 1137 significant lines (blank, comment-only and punctuation-only lines excluded), about 83% of them inside a single declaration: ovgEdgeRouter (13 blocks, 46-1832). The bar is 500 significant lines; this is 637 over it, 2.27× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: d2raster/raster.go d2renderers/d2raster/raster.go— FileTooLong — 1118 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 618 over it, 2.24× 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: REDACTED REDACTED— FileTooLong — 1054 significant lines (blank, comment-only and punctuation-only lines excluded), about 90% of them inside a single declaration: OVG (28 blocks, 18-1753). The bar is 500 significant lines; this is 554 over it, 2.11× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: d2ast/d2ast.go d2ast/d2ast.go— FileTooLong — 1048 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 548 over it, 2.10× 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: REDACTED REDACTED— FileTooLong — 1023 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 523 over it, 2.05× 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: d2raster/gradient.go d2renderers/d2raster/gradient.go— FileTooLong — 996 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 496 over it, 1.99× 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: d2target/d2target.go d2target/d2target.go— FileTooLong — 996 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 496 over it, 1.99× 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: d2raster/image.go d2renderers/d2raster/image.go— FileTooLong — 983 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 483 over it, 1.97× 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: d2scenebuild/build.go d2renderers/d2scenebuild/build.go— FileTooLong — 923 significant lines (blank, comment-only and punctuation-only lines excluded), about 64% of them inside a single declaration: builder (9 blocks, 122-1364). The bar is 500 significant lines; this is 423 over it, 1.85× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: layoutgraph/transaction.go d2layouts/d2talalayout/internal/layoutgraph/transaction.go— FileTooLong — 913 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 413 over it, 1.83× 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: REDACTED REDACTED— FileTooLong — 904 significant lines (blank, comment-only and punctuation-only lines excluded), about 78% of them inside a single declaration: Rasterizer (36 blocks, 99-1384). The bar is 500 significant lines; this is 404 over it, 1.81× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: d2raster/filter.go d2renderers/d2raster/filter.go— FileTooLong — 903 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 403 over it, 1.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.
Duplicated block (5 lines × 2) d2graph/d2graph.go:1943— d2graph/d2graph.go:1943-1947 | d2graph/layout.go:341-345 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2graph/d2graph.go:1943` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2layouts/d2grid/layout.go:156— d2layouts/d2grid/layout.go:156-160 | d2layouts/d2layouts.go:380-384 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2grid/layout.go:156` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/graphbounds/bounds.go:130— d2layouts/d2talalayout/internal/graphbounds/bounds.go:130-134 | d2layouts/d2talalayout/internal/labeling/guard.go:398-402 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/graphbounds/bounds.go:130` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/hierarchy/crossing.go:142— d2layouts/d2talalayout/internal/hierarchy/crossing.go:142-146 | d2layouts/d2talalayout/internal/hierarchy/crossing.go:150-154 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/hierarchy/crossing.go:142` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/node.go:558— d2layouts/d2talalayout/internal/layoutgraph/node.go:558-562 | d2layouts/d2talalayout/internal/routing/ovg_resource.go:403-407 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/node.go:558` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:91— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:91-95 | d2layouts/d2talalayout/internal/nodeshape/shape_step.go:97-101 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_step.go` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 122 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:91` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/placement/dejitter.go:181— d2layouts/d2talalayout/internal/placement/dejitter.go:181-185 | d2layouts/d2talalayout/internal/placement/dejitter.go:410-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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/dejitter.go:181` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/placement/optimization_guard.go:374— d2layouts/d2talalayout/internal/placement/optimization_guard.go:374-378 | d2layouts/d2talalayout/internal/placement/optimization_guard.go:389-393 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/optimization_guard.go:374` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/placement/optimization_guard.go:441— d2layouts/d2talalayout/internal/placement/optimization_guard.go:441-445 | d2layouts/d2talalayout/internal/placement/optimizer_spatial_index.go:288-292 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/optimization_guard.go:441` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/placement/optimization_guard.go:482— d2layouts/d2talalayout/internal/placement/optimization_guard.go:482-486 | d2layouts/d2talalayout/internal/placement/optimizer_spatial_index.go:341-345 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/optimization_guard.go:482` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) REDACTED:293— REDACTED:293-297 | REDACTED:373-377 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:293` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2layouts/d2talalayout/internal/placement/swap.go:200— d2layouts/d2talalayout/internal/placement/swap.go:200-204 | d2layouts/d2talalayout/internal/placement/swap.go:219-223 — 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 (5 lines × 2) d2layouts/d2talalayout/internal/placement/swap.go:206— d2layouts/d2talalayout/internal/placement/swap.go:206-210 | d2layouts/d2talalayout/internal/placement/swap.go:213-217 — 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 (5 lines × 2) d2oracle/edit.go:1575— d2oracle/edit.go:1575-1579 | d2oracle/edit.go:1582-1586 — 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 (5 lines × 2) d2renderers/d2isometric/d2isometricimg/framing.go:138— d2renderers/d2isometric/d2isometricimg/framing.go:138-142 | d2renderers/d2isometric/d2isometricimg/framing.go:165-169 — 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 (5 lines × 2) d2renderers/d2isometric/d2isometricimg/native_edges.go:381— d2renderers/d2isometric/d2isometricimg/native_edges.go:381-385 | d2renderers/d2isometric/d2isometricimg/native_ink_joins.go:28-32 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (5 lines × 2) d2renderers/d2isometric/d2isometricimg/route_bridges.go:164— d2renderers/d2isometric/d2isometricimg/route_bridges.go:164-168 | d2renderers/d2isometric/d2isometricimg/route_lanes.go:200-204 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2isometric/d2isometricimg/route_bridges.go:164` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) d2renderers/d2raster/filter.go:930— d2renderers/d2raster/filter.go:930-934 | d2renderers/d2raster/filter.go:1093-1097 — 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 (5 lines × 2) d2renderers/d2raster/filter.go:1138— d2renderers/d2raster/filter.go:1138-1142 | d2renderers/d2raster/filter.go:1169-1173 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:1138` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (5 lines × 2) d2renderers/d2raster/geometry.go:30— d2renderers/d2raster/geometry.go:30-34 | d2renderers/d2raster/image.go:434-438 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/geometry.go:30` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2renderers/d2raster/geometry.go:236— d2renderers/d2raster/geometry.go:236-240 | d2renderers/d2raster/geometry.go:268-272 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/geometry.go:236` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) d2renderers/d2raster/gradient.go:765— d2renderers/d2raster/gradient.go:765-769 | d2renderers/d2raster/gradient.go:1065-1069 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:765` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) d2renderers/d2sketch/sketch.go:177— d2renderers/d2sketch/sketch.go:177-181 | d2renderers/d2sketch/sketch.go:223-227 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2sketch/sketch.go:177` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) d2renderers/d2sketch/sketch.go:588— d2renderers/d2sketch/sketch.go:588-592 | d2renderers/d2svg/class.go:107-111 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (5 lines × 2) d2renderers/d2svg/class.go:133— d2renderers/d2svg/class.go:133-138 | d2renderers/d2svg/table.go:163-167 — before extracting anything, compare `d2renderers/d2svg/class.go` and `d2renderers/d2svg/table.go` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/class.go:133` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
MethodTooLong: ovgEdgeRouter.search d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:558— MethodTooLong — search runs 495 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 395 over it, 4.95× 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.
MethodTooLong: Ruler.measureMarkdownNode lib/textmeasure/markdown.go:330— MethodTooLong — measureMarkdownNode runs 311 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 211 over it, 3.11× 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.
MethodTooLong: compiler.compileReserved d2compiler/compile.go:863— MethodTooLong — compileReserved runs 215 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 115 over it, 2.15× 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.
MethodTooLong: builder.resolveFontFallbacks d2renderers/d2scenebuild/font_fallback.go:131— MethodTooLong — resolveFontFallbacks runs 208 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 108 over it, 2.08× 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.
MethodTooLong: ovgEdgeRouter.findSShapedRoute d2layouts/d2talalayout/internal/routing/slingshot.go:891— MethodTooLong — findSShapedRoute runs 207 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 107 over it, 2.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.
MethodTooLong: ShapingWorkspace.ShapeTextTransient d2renderers/internal/fontface/shaping.go:111— MethodTooLong — ShapeTextTransient runs 202 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 102 over it, 2.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.
MethodTooLong: textPainter.texture d2renderers/d2isometric/d2isometricimg/text.go:145— MethodTooLong — texture runs 198 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 98 over it, 1.98× 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.
MethodTooLong: builder.buildDocument d2renderers/d2scenebuild/build.go:542— MethodTooLong — buildDocument runs 189 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 89 over it, 1.89× 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.
MethodTooLong: preflight.text d2renderers/d2raster/text.go:183— MethodTooLong — text runs 188 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 88 over it, 1.88× 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.
MethodTooLong: builder.arrowhead d2renderers/d2scenebuild/connection.go:430— MethodTooLong — arrowhead runs 179 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 79 over it, 1.79× 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.
MethodTooLong: svgImporter.computeStyle d2renderers/d2svgimport/style.go:266— MethodTooLong — computeStyle runs 172 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 72 over it, 1.72× 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.
MethodTooLong: Map.ensureField REDACTED:1216— MethodTooLong — ensureField runs 163 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 63 over it, 1.63× 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.
MethodTooLong: Rasterizer.DrawRGBA REDACTED:491— MethodTooLong — DrawRGBA runs 160 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 60 over it, 1.60× 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.
MethodTooLong: compiler.ampersandFilter REDACTED:1364— MethodTooLong — ampersandFilter runs 154 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 54 over it, 1.54× 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.
MethodTooLong: ovgEdgeRouter.findLShapedRoute d2layouts/d2talalayout/internal/routing/slingshot.go:666— MethodTooLong — findLShapedRoute 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.
MethodTooLong: svgImporter.instantiate d2renderers/d2svgimport/compile.go:386— MethodTooLong — instantiate runs 147 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 47 over it, 1.47× 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.
MethodTooLong: compiler.resolveSubstitutions REDACTED:415— MethodTooLong — resolveSubstitutions runs 146 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 46 over it, 1.46× 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.
MethodTooLong: compiler._compileField REDACTED:1704— MethodTooLong — _compileField runs 144 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 44 over it, 1.44× 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.
MethodTooLong: ASCIIartist.Render d2renderers/d2ascii/d2ascii.go:215— MethodTooLong — Render runs 142 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 42 over it, 1.42× 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.
MethodTooLong: builder.shapeTextRuns d2renderers/d2scenebuild/font_fallback.go:432— MethodTooLong — shapeTextRuns 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.
MethodTooLong: Style.Apply d2graph/d2graph.go:313— MethodTooLong — Apply 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.
MethodTooLong: meshBuilder.edges d2renderers/d2isometric/d2isometricimg/geometry_routes.go:332— MethodTooLong — edges 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.
MethodTooLong: parser.parseUnquotedString d2parser/parse.go:1129— MethodTooLong — parseUnquotedString runs 133 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 33 over it, 1.33× 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.
MethodTooLong: pathParser.parseGroup d2renderers/d2svgimport/path.go:131— MethodTooLong — parseGroup runs 132 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 32 over it, 1.32× 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.
MethodTooLong: compiler._compileEdges REDACTED:2088— MethodTooLong — _compileEdges runs 128 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 28 over it, 1.28× 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.
Swallowed exception (caught, then discarded) REDACTED:727— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2compiler/compile.go:1736— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2exporter/export.go:300— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2graph/d2graph.go:826— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2graph/d2graph.go:830— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2ir/import.go:252— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:1465— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:1533— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:1572— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:1615— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:1950— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:1998— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:382— `if captureErr != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2layouts/d2talalayout/internal/packing/routed_container.go:283— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2layouts/d2talalayout/internal/routing/coordinator.go:448— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2oracle/get.go:206— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2oracle/get.go:221— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2oracle/edit.go:3302— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2oracle/edit.go:3306— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2renderers/d2fonts/fallback.go:237— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2renderers/d2fonts/fallback.go:399— `if readErr != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2renderers/d2fonts/fallback.go:564— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2renderers/d2isometric/d2isometricimg/native_structured.go:84— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2renderers/d2scenebuild/shape_effects.go:509— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) d2renderers/d2svg/font_corpus.go:101— `if err != nil` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Duplicated block (8 lines × 2) d2cli/isometric_image.go:156— d2cli/isometric_image.go:156-163 | d2cli/isometric_image.go:167-174 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2cli/isometric_image.go:156` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) d2ir/pattern.go:74— d2ir/pattern.go:74-81 | d2ir/pattern.go:109-116 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2ir/pattern.go:74` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) d2layouts/d2dagrelayout/layout.go:343— d2layouts/d2dagrelayout/layout.go:343-350 | d2layouts/d2elklayout/layout.go:643-650 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:343` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/edge.go:388— d2layouts/d2talalayout/internal/layoutgraph/edge.go:388-395 | d2layouts/d2talalayout/internal/layoutgraph/edge.go:402-409 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/edge.go:388` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:172— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:172-179 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:549-556 — 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 (8 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:26— d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:26-33 | d2layouts/d2talalayout/internal/packing/combine.go:21-28 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8 lines × 2) REDACTED:126— REDACTED:126-133 | REDACTED:40-47 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:126` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) d2layouts/d2talalayout/internal/routing/balance_route_guard.go:56— d2layouts/d2talalayout/internal/routing/balance_route_guard.go:56-63 | d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:162-169 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/balance_route_guard.go:56` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:62— d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:62-69 | d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:71-78 — 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 (8 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:87— d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:87-94 | d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:96-103 — 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 (8 lines × 2) d2renderers/d2fonts/bundled_fallback.go:286— d2renderers/d2fonts/bundled_fallback.go:286-293 | d2renderers/d2fonts/fallback.go:286-293 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8 lines × 2) d2renderers/d2raster/effects.go:1363— d2renderers/d2raster/effects.go:1363-1370 | d2renderers/d2raster/effects.go:1376-1383 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1363` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) d2renderers/d2raster/effects.go:1848— d2renderers/d2raster/effects.go:1848-1855 | lib/xgif/xgif.go:1431-1438 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1848` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) d2renderers/d2raster/filter.go:789— d2renderers/d2raster/filter.go:789-796 | d2renderers/d2raster/filter.go:816-823 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:789` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) REDACTED:210— REDACTED:210-217 | REDACTED:235-242 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:210` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:243` calls `releaseLoad` and `REDACTED:218` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) REDACTED:345— REDACTED:345-352 | REDACTED:372-379 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:345` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:380` calls `releaseLoad` and `REDACTED:353` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) d2renderers/d2scenebuild/build.go:872— d2renderers/d2scenebuild/build.go:872-879 | d2renderers/d2scenebuild/build.go:910-917 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/build.go:872` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) d2renderers/d2scenebuild/metadata.go:107— d2renderers/d2scenebuild/metadata.go:107-114 | d2renderers/d2scenebuild/metadata.go:133-140 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/metadata.go:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) d2renderers/d2scenebuild/shape_effects.go:261— d2renderers/d2scenebuild/shape_effects.go:261-268 | d2renderers/d2scenebuild/sketch_shapes.go:481-488 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/shape_effects.go:261` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) d2renderers/d2scenebuild/sketch_shapes.go:110— d2renderers/d2scenebuild/sketch_shapes.go:110-117 | d2renderers/d2scenebuild/sketch_shapes.go:563-570 — 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 (8 lines × 2) d2renderers/d2svg/d2svg.go:1477— d2renderers/d2svg/d2svg.go:1477-1484 | d2renderers/d2svg/d2svg.go:1597-1604 — 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 (8 lines × 2) d2renderers/d2svgimport/geometry.go:95— d2renderers/d2svgimport/geometry.go:95-102 | d2renderers/d2svgimport/geometry.go:109-116 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) d2renderers/d2svgimport/path.go:214— d2renderers/d2svgimport/path.go:214-221 | d2renderers/d2svgimport/path.go:229-236 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svgimport/path.go:214` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) d2renderers/d2svgimport/stylesheet.go:93— d2renderers/d2svgimport/stylesheet.go:93-100 | d2renderers/d2svgimport/stylesheet.go:117-124 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svgimport/stylesheet.go:93` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) d2renderers/internal/fontface/face.go:197— d2renderers/internal/fontface/face.go:197-204 | d2renderers/internal/fontface/face.go:418-425 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) d2cli/paged.go:461— d2cli/paged.go:461-472 | d2cli/paged.go:543-554 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2cli/paged.go:461` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) REDACTED:1517— REDACTED:1517-1528 | REDACTED:1553-1564 — 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 (12 lines × 2) REDACTED:337— REDACTED:337-348 | REDACTED:355-366 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:337` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) REDACTED:1618— REDACTED:1618-1629 | REDACTED:1745-1756 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1618` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) d2layouts/d2dagrelayout/layout.go:1159— d2layouts/d2dagrelayout/layout.go:1159-1170 | d2layouts/d2dagrelayout/layout.go:1200-1212 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:1159` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) d2layouts/d2dagrelayout/layout.go:1724— d2layouts/d2dagrelayout/layout.go:1724-1735 | d2layouts/d2dagrelayout/layout.go:1818-1829 — 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 (12 lines × 2) d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:205— d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:205-216 | d2layouts/d2talalayout/internal/packing/guard.go:58-69 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:205` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:310— d2layouts/d2talalayout/internal/layoutgraph/transaction.go:310-321 | d2layouts/d2talalayout/internal/layoutgraph/transaction.go:331-342 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/transaction.go:310` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/tree_access.go:82— d2layouts/d2talalayout/internal/layoutgraph/tree_access.go:82-93 | d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:685-696 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/tree_access.go:82` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) d2layouts/d2talalayout/internal/packing/binpack.go:390— d2layouts/d2talalayout/internal/packing/binpack.go:390-401 | d2layouts/d2talalayout/internal/packing/binpack.go:405-416 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/binpack.go:390` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) d2layouts/d2talalayout/internal/packing/combine.go:248— d2layouts/d2talalayout/internal/packing/combine.go:248-259 | d2layouts/d2talalayout/internal/packing/combine.go:388-399 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/combine.go:248` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/packing/combine.go:387` calls `MoveWithChildren` and `d2layouts/d2talalayout/internal/packing/combine.go:247` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 2) d2layouts/d2talalayout/internal/placement/dejitter.go:337— d2layouts/d2talalayout/internal/placement/dejitter.go:337-348 | d2layouts/d2talalayout/internal/placement/dejitter.go:368-379 — 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 (12 lines × 2) d2layouts/d2talalayout/internal/placement/metrics.go:55— d2layouts/d2talalayout/internal/placement/metrics.go:55-66 | d2layouts/d2talalayout/internal/placement/optimization_guard.go:377-388 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2layouts/d2talalayout/internal/placement/optimization_guard.go:389` calls `AddSort` and `d2layouts/d2talalayout/internal/placement/metrics.go:67` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 2) d2layouts/d2talalayout/internal/quality/labels.go:531— d2layouts/d2talalayout/internal/quality/labels.go:531-542 | d2layouts/d2talalayout/internal/routing/route_stage_guard.go:566-578 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/quality/labels.go:531` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:126— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:126-137 | d2layouts/d2talalayout/internal/routing/tunnel.go:371-382 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (12 lines × 2) d2layouts/d2talalayout/internal/routing/slingshot.go:715— d2layouts/d2talalayout/internal/routing/slingshot.go:715-726 | d2layouts/d2talalayout/internal/routing/slingshot.go:940-951 — 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 (12 lines × 2) d2layouts/d2talalayout/internal/trees/geometry.go:683— d2layouts/d2talalayout/internal/trees/geometry.go:683-694 | d2layouts/d2talalayout/internal/trees/geometry.go:812-823 — 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 (12 lines × 2) d2layouts/d2talalayout/internal/trees/geometry.go:740— d2layouts/d2talalayout/internal/trees/geometry.go:740-751 | d2layouts/d2talalayout/internal/trees/geometry.go:825-836 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/trees/geometry.go:740` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) d2parser/parse.go:640— d2parser/parse.go:640-651 | d2parser/parse.go:1495-1506 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2parser/parse.go:640` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (12 lines × 2) d2renderers/d2raster/effects.go:621— d2renderers/d2raster/effects.go:621-632 | d2renderers/d2raster/effects.go:642-653 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:621` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2renderers/d2raster/effects.go:620` calls `addFillSubpath` and `d2renderers/d2raster/effects.go:641` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 2) d2renderers/d2raster/effects.go:705— d2renderers/d2raster/effects.go:705-716 | d2renderers/d2raster/effects.go:755-766 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:705` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) d2renderers/d2raster/effects.go:1720— d2renderers/d2raster/effects.go:1720-1731 | d2renderers/d2raster/effects.go:1859-1870 — 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 (12 lines × 2) d2renderers/d2raster/gradient.go:793— d2renderers/d2raster/gradient.go:793-804 | d2renderers/d2raster/gradient.go:1127-1138 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:793` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) d2renderers/d2raster/image.go:941— d2renderers/d2raster/image.go:941-952 | d2renderers/d2raster/image.go:960-971 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:941` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) REDACTED:509— REDACTED:509-520 | REDACTED:615-626 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:509` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2graph/d2graph.go:1913— d2graph/d2graph.go:1913-1921 | d2graph/layout.go:298-306 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2graph/d2graph.go:1913` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2graph/layout.go:144— d2graph/layout.go:144-152 | d2layouts/d2elklayout/descendant_shifter.go:119-127 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2graph/layout.go:144` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) REDACTED:1643— REDACTED:1643-1651 | REDACTED:1788-1796 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1643` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) d2ir/import.go:27— d2ir/import.go:27-35 | d2ir/import.go:197-205 — 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 (9 lines × 2) d2layouts/d2dagrelayout/layout.go:351— d2layouts/d2dagrelayout/layout.go:351-359 | d2layouts/d2elklayout/layout.go:651-659 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:351` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2layouts/d2grid/layout.go:282— d2layouts/d2grid/layout.go:282-290 | d2layouts/d2grid/layout.go:297-305 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2grid/layout.go:282` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1039— d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1039-1047 | d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1050-1058 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1039` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:304— d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:304-312 | d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:733-741 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:304` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2layouts/d2talalayout/internal/placement/alignment.go:89— d2layouts/d2talalayout/internal/placement/alignment.go:89-97 | d2layouts/d2talalayout/internal/placement/alignment.go:162-170 — 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 (9 lines × 2) d2layouts/d2talalayout/internal/placementcost/symmetry.go:626— d2layouts/d2talalayout/internal/placementcost/symmetry.go:626-634 | d2layouts/d2talalayout/internal/routing/turns.go:13-21 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (9 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:520— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:520-528 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:529-537 — 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 (9 lines × 2) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:477— d2layouts/d2talalayout/internal/routing/shortcut_routes.go:477-485 | d2layouts/d2talalayout/internal/routing/shortcut_routes.go:495-503 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/shortcut_routes.go:477` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) d2oracle/edit.go:198— d2oracle/edit.go:198-206 | d2oracle/edit.go:2581-2589 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:198` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) d2renderers/d2ascii/asciishapes/class.go:20— d2renderers/d2ascii/asciishapes/class.go:20-28 | d2renderers/d2ascii/asciishapes/sqltable.go:19-27 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2ascii/asciishapes/class.go:20` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2renderers/d2ascii/asciishapes/helpers.go:57— d2renderers/d2ascii/asciishapes/helpers.go:57-65 | d2renderers/d2ascii/asciishapes/helpers.go:71-79 — 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 (9 lines × 2) d2renderers/d2isometric/d2isometricimg/raster.go:723— d2renderers/d2isometric/d2isometricimg/raster.go:723-731 | d2renderers/d2isometric/d2isometricimg/raster.go:955-963 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2isometric/d2isometricimg/raster.go:723` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2renderers/d2isometric/d2isometricimg/route_bridges.go:94— d2renderers/d2isometric/d2isometricimg/route_bridges.go:94-102 | d2renderers/d2isometric/d2isometricimg/route_lanes.go:103-111 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2isometric/d2isometricimg/route_bridges.go:94` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2renderers/d2raster/effects.go:696— d2renderers/d2raster/effects.go:696-704 | d2renderers/d2raster/raster.go:1547-1555 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:696` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2renderers/d2raster/filter.go:576— d2renderers/d2raster/filter.go:576-584 | d2renderers/d2raster/filter.go:619-627 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:576` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2renderers/d2raster/filter.go:707— d2renderers/d2raster/filter.go:707-715 | d2renderers/d2raster/filter.go:877-885 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:707` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) d2renderers/d2raster/geometry.go:449— d2renderers/d2raster/geometry.go:449-457 | d2renderers/d2raster/geometry.go:471-479 — 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 (9 lines × 2) d2renderers/d2raster/image.go:649— d2renderers/d2raster/image.go:649-657 | d2renderers/d2raster/image.go:896-904 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:649` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (9 lines × 2) d2renderers/d2scenebuild/legend.go:133— d2renderers/d2scenebuild/legend.go:133-141 | d2renderers/d2svg/d2svg.go:479-487 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note what the matched lines are: every one of them assigns one field to another, so the block is a hand-written mapper between two data shapes rather than behaviour with a helper inside it. Extracting one shared function only works if both sites map the SAME pair of types in the same direction — check that first, because inverse or differently-typed mappers have no single function they can both call. Where they do not, the moves that exist are a generated or reflective mapper, a common embedded/base type the fields live on once, or accepting the run and covering it with a test that fails when a field is added to one side only.
Duplicated block (9 lines × 2) d2renderers/d2scenebuild/markdown.go:127— d2renderers/d2scenebuild/markdown.go:127-135 | d2renderers/d2scenebuild/tooltip.go:33-41 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) d2renderers/d2scenebuild/patterns.go:268— d2renderers/d2scenebuild/patterns.go:268-276 | d2renderers/d2scenebuild/sketch_shapes.go:214-222 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/patterns.go:268` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) REDACTED:293— REDACTED:293-299 | REDACTED:333-339 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:293` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) REDACTED:673— REDACTED:673-679 | REDACTED:756-762 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:673` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2ir/import_cache.go:54— d2ir/import_cache.go:54-60 | d2ir/import_cache.go:99-105 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2ir/import_cache.go:54` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2js/d2wasm/functions.go:580— d2js/d2wasm/functions.go:580-586 | d2js/d2wasm/functions.go:640-646 — 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 (7 lines × 2) d2layouts/d2dagrelayout/layout.go:802— d2layouts/d2dagrelayout/layout.go:802-808 | d2layouts/d2elklayout/descendant_shifter.go:39-45 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:802` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (7 lines × 2) d2layouts/d2elklayout/layout.go:268— d2layouts/d2elklayout/layout.go:268-274 | d2layouts/d2elklayout/wasm.go:28-34 — before extracting anything, compare `d2layouts/d2elklayout/layout.go` and `d2layouts/d2elklayout/wasm.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2elklayout/layout.go:268` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2elklayout/layout.go:265` calls `CheckGraph` and `d2layouts/d2elklayout/wasm.go:27` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 2) d2layouts/d2talalayout/internal/graphbounds/bounds.go:146— d2layouts/d2talalayout/internal/graphbounds/bounds.go:146-152 | d2layouts/d2talalayout/internal/routing/ovg_resource.go:401-407 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/graphbounds/bounds.go:146` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) REDACTED:156— REDACTED:156-162 | REDACTED:209-215 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:156` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) REDACTED:1170— REDACTED:1170-1176 | REDACTED:1243-1249 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1170` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/graph.go:975— d2layouts/d2talalayout/internal/layoutgraph/graph.go:975-981 | d2layouts/d2talalayout/internal/layoutgraph/graph.go:984-990 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/graph.go:975` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2layouts/d2talalayout/internal/packing/binpack.go:108— d2layouts/d2talalayout/internal/packing/binpack.go:108-114 | d2layouts/d2talalayout/internal/packing/binpack.go:200-206 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/binpack.go:108` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) REDACTED:513— REDACTED:513-519 | REDACTED:522-528 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:305— d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:305-311 | d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:313-319 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:305` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2layouts/d2talalayout/internal/routing/tunnel.go:302— d2layouts/d2talalayout/internal/routing/tunnel.go:302-308 | d2layouts/d2talalayout/internal/routing/tunnel.go:332-338 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/tunnel.go:302` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2oracle/edit.go:1192— d2oracle/edit.go:1192-1198 | d2oracle/edit.go:2040-2046 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:1192` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2oracle/edit.go:1237— d2oracle/edit.go:1237-1244 | d2oracle/edit.go:1256-1262 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:1237` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2renderers/d2fonts/bundled_fallback.go:296— d2renderers/d2fonts/bundled_fallback.go:296-302 | d2renderers/d2scenebuild/font_fallback.go:899-905 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (7 lines × 2) d2renderers/d2raster/effects.go:1486— d2renderers/d2raster/effects.go:1486-1492 | d2renderers/d2raster/effects.go:1598-1604 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1486` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2renderers/d2raster/filter.go:656— d2renderers/d2raster/filter.go:656-662 | d2renderers/d2raster/filter.go:841-847 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:656` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2renderers/d2raster/gradient.go:601— d2renderers/d2raster/gradient.go:601-607 | d2renderers/d2raster/gradient.go:634-640 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:601` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) d2renderers/d2raster/raster.go:1634— d2renderers/d2raster/raster.go:1634-1640 | d2renderers/d2scene/primitive.go:262-268 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/raster.go:1634` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) d2renderers/d2raster/vector_validation.go:906— d2renderers/d2raster/vector_validation.go:906-912 | d2renderers/d2raster/vector_validation.go:914-920 — 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 (7 lines × 2) d2renderers/d2sketch/sketch.go:391— d2renderers/d2sketch/sketch.go:391-397 | d2renderers/d2sketch/sketch.go:400-406 — 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 (7 lines × 2) d2renderers/d2sketch/sketch.go:455— d2renderers/d2sketch/sketch.go:455-461 | d2renderers/d2svg/table.go:131-137 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (7 lines × 2) d2renderers/d2svg/class.go:93— d2renderers/d2svg/class.go:93-99 | d2renderers/d2svg/table.go:116-122 — before extracting anything, compare `d2renderers/d2svg/class.go` and `d2renderers/d2svg/table.go` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 2) d2cli/paged.go:303— d2cli/paged.go:303-308 | d2renderers/d2raster/raster.go:697-703 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2cli/paged.go:303` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2exporter/export.go:153— d2exporter/export.go:153-158 | d2exporter/export.go:388-394 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2exporter/export.go:395` calls `GetStroke` and `d2exporter/export.go:159` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 2) d2layouts/d2dagrelayout/layout.go:1142— d2layouts/d2dagrelayout/layout.go:1142-1147 | d2layouts/d2dagrelayout/layout.go:1184-1189 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:1142` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2layouts/d2elklayout/layout.go:860— d2layouts/d2elklayout/layout.go:860-865 | d2layouts/d2elklayout/layout.go:964-969 — 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 (6 lines × 2) d2layouts/d2elklayout/layout.go:968— d2layouts/d2elklayout/layout.go:968-973 | d2layouts/d2elklayout/layout.go:975-980 — 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 (6 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/graph.go:521— d2layouts/d2talalayout/internal/layoutgraph/graph.go:521-527 | d2layouts/d2talalayout/internal/routing/route_stage_guard.go:449-454 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/graph.go:521` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2layouts/d2talalayout/internal/placement/dejitter.go:232— d2layouts/d2talalayout/internal/placement/dejitter.go:232-237 | d2layouts/d2talalayout/internal/placement/dejitter.go:282-287 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/dejitter.go:232` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (6 lines × 2) REDACTED:318— REDACTED:318-323 | REDACTED:409-414 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:318` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2layouts/d2talalayout/internal/placement/optimization_guard.go:476— d2layouts/d2talalayout/internal/placement/optimization_guard.go:476-481 | d2layouts/d2talalayout/internal/placement/optimizer_spatial_index.go:333-340 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/optimization_guard.go:476` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (6 lines × 2) d2layouts/d2talalayout/internal/placement/optimization_guard.go:752— d2layouts/d2talalayout/internal/placement/optimization_guard.go:752-757 | d2layouts/d2talalayout/internal/placement/optimization_guard.go:1065-1070 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) REDACTED:482— REDACTED:482-487 | REDACTED:503-508 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:482` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) d2oracle/edit.go:1834— d2oracle/edit.go:1834-1839 | d2oracle/edit.go:2797-2802 — 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 (6 lines × 2) d2renderers/d2ascii/asciishapes/parallelogram.go:4— d2renderers/d2ascii/asciishapes/parallelogram.go:4-9 | d2renderers/d2ascii/asciishapes/queue.go:4-9 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2ascii/asciishapes/parallelogram.go:4` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2renderers/d2raster/filter.go:679— d2renderers/d2raster/filter.go:679-684 | d2renderers/d2raster/filter.go:859-864 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:679` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2renderers/d2raster/filter.go:923— d2renderers/d2raster/filter.go:923-928 | d2renderers/d2raster/filter.go:1081-1086 — 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 (6 lines × 2) d2renderers/d2raster/gradient.go:595— d2renderers/d2raster/gradient.go:595-600 | d2renderers/d2raster/gradient.go:628-633 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:595` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2renderers/d2raster/image.go:201— d2renderers/d2raster/image.go:201-206 | d2renderers/d2svgimport/image.go:344-349 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:201` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2renderers/d2scenebuild/build.go:1257— d2renderers/d2scenebuild/build.go:1257-1262 | d2target/render_validation.go:406-411 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/build.go:1257` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) d2renderers/d2svg/d2svg.go:2247— d2renderers/d2svg/d2svg.go:2247-2252 | d2renderers/d2svg/table.go:17-22 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2renderers/d2svg/table.go:24` calls `borderRadiusClipPathID` and `d2renderers/d2svg/d2svg.go:2254` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 2) lib/xgif/xgif.go:723— lib/xgif/xgif.go:723-728 | lib/xgif/xgif.go:797-802 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/xgif/xgif.go:723` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lib/xgif/xgif.go:803` calls `squaredColorDifference` and `lib/xgif/xgif.go:729` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 2) d2layouts/d2talalayout/internal/labeling/guard.go:79— d2layouts/d2talalayout/internal/labeling/guard.go:79-84 | REDACTED:89-94 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) d2layouts/d2talalayout/internal/limits/work.go:153— d2layouts/d2talalayout/internal/limits/work.go:153-158 | d2layouts/d2talalayout/internal/routing/route_stage_guard.go:119-124 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_resource.go:75— d2layouts/d2talalayout/internal/routing/ovg_resource.go:75-80 | d2layouts/d2talalayout/internal/routing/route_search_guard.go:151-156 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (6 lines × 2) d2renderers/d2raster/effects.go:217— d2renderers/d2raster/effects.go:217-222 | REDACTED:898-903 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Check import visibility before settling on that home: `REDACTED` sits under a restricted `internal` directory, which only code inside its own subtree is permitted to import from — so it is reachable from some of these sites and not from others, and being able to see the copies is not the same as being allowed to share them. The home has to be somewhere every one of these sites is permitted to import from; if there is no such place, that restriction may be exactly why the copies are separate.
Duplicated block (6 lines × 2) d2renderers/d2raster/effects.go:224— d2renderers/d2raster/effects.go:224-229 | REDACTED:905-910 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Check import visibility before settling on that home: `REDACTED` sits under a restricted `internal` directory, which only code inside its own subtree is permitted to import from — so it is reachable from some of these sites and not from others, and being able to see the copies is not the same as being allowed to share them. The home has to be somewhere every one of these sites is permitted to import from; if there is no such place, that restriction may be exactly why the copies are separate.
Duplicated block (11 lines × 2) REDACTED:424— REDACTED:424-434 | REDACTED:561-571 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:424` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) REDACTED:1360— REDACTED:1360-1370 | REDACTED:1426-1436 — 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 (11 lines × 2) d2js/d2wasm/functions.go:145— d2js/d2wasm/functions.go:145-155 | d2js/d2wasm/functions.go:197-207 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) d2layouts/d2talalayout/internal/grouping/join.go:306— d2layouts/d2talalayout/internal/grouping/join.go:306-316 | d2layouts/d2talalayout/internal/grouping/join.go:332-342 — 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 (11 lines × 2) d2layouts/d2talalayout/internal/labeling/guard.go:518— d2layouts/d2talalayout/internal/labeling/guard.go:518-528 | d2layouts/d2talalayout/internal/routing/route_stage_guard.go:569-579 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/guard.go:518` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/graph.go:884— d2layouts/d2talalayout/internal/layoutgraph/graph.go:884-894 | d2layouts/d2talalayout/internal/layoutgraph/graph.go:900-910 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/graph.go:884` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:223— d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:223-233 | d2layouts/d2talalayout/internal/packing/combine.go:57-67 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:223` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) d2layouts/d2talalayout/internal/placement/cluster_optimization.go:296— d2layouts/d2talalayout/internal/placement/cluster_optimization.go:296-306 | d2layouts/d2talalayout/internal/placement/cluster_optimization.go:324-334 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/cluster_optimization.go:296` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 2) d2layouts/d2talalayout/internal/placement/metrics.go:136— d2layouts/d2talalayout/internal/placement/metrics.go:136-146 | d2layouts/d2talalayout/internal/placement/metrics.go:177-187 — 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 (11 lines × 2) d2layouts/d2talalayout/internal/placementcost/symmetry.go:653— d2layouts/d2talalayout/internal/placementcost/symmetry.go:653-663 | d2layouts/d2talalayout/internal/placementcost/symmetry.go:675-685 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placementcost/symmetry.go:653` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) d2layouts/d2talalayout/internal/routing/nudge_channels.go:234— d2layouts/d2talalayout/internal/routing/nudge_channels.go:234-244 | d2layouts/d2talalayout/internal/routing/nudge_channels.go:443-453 — 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 (11 lines × 2) REDACTED:347— REDACTED:347-357 | REDACTED:359-369 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:357` calls `Sort` and `REDACTED:345` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 2) REDACTED:1025— REDACTED:1025-1035 | REDACTED:1715-1725 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1025` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:221— d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:221-231 | d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:462-472 — 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 (11 lines × 2) d2oracle/edit.go:186— d2oracle/edit.go:186-196 | d2oracle/edit.go:2568-2578 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:186` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) d2parser/parse.go:580— d2parser/parse.go:580-590 | d2parser/parse.go:1430-1440 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2parser/parse.go:580` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (11 lines × 2) d2parser/parse.go:1824— d2parser/parse.go:1824-1834 | d2parser/parse.go:1874-1884 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2parser/parse.go:1824` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (11 lines × 2) d2renderers/d2raster/bands.go:146— d2renderers/d2raster/bands.go:146-156 | d2renderers/d2raster/effects.go:288-298 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) d2renderers/d2raster/colrv1.go:128— d2renderers/d2raster/colrv1.go:128-138 | d2renderers/d2raster/colrv1.go:161-171 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/colrv1.go:128` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) d2renderers/d2raster/effects.go:1542— d2renderers/d2raster/effects.go:1542-1552 | d2renderers/d2raster/effects.go:1702-1712 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1542` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) d2renderers/d2raster/geometry.go:575— d2renderers/d2raster/geometry.go:575-585 | d2renderers/d2raster/geometry.go:693-703 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) d2renderers/d2raster/image.go:207— d2renderers/d2raster/image.go:207-217 | d2renderers/d2svgimport/image.go:350-360 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:207` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) d2renderers/d2raster/image.go:757— d2renderers/d2raster/image.go:757-767 | d2renderers/d2raster/image.go:791-801 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:757` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) d2renderers/d2scenebuild/build.go:1231— d2renderers/d2scenebuild/build.go:1231-1241 | d2target/render_validation.go:380-390 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/build.go:1231` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) d2renderers/d2svg/d2svg.go:1237— d2renderers/d2svg/d2svg.go:1237-1247 | d2renderers/d2svg/d2svg.go:2100-2110 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/d2svg.go:1237` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2cli/board_output_publish.go:326— d2cli/board_output_publish.go:326-335 | d2cli/board_output_publish.go:339-348 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2cli/board_output_publish.go:326` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (10 lines × 2) d2cli/raster_png_encoder.go:113— d2cli/raster_png_encoder.go:113-122 | d2renderers/d2raster/raster.go:581-590 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2cli/raster_png_encoder.go:113` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) d2layouts/d2dagrelayout/layout.go:583— d2layouts/d2dagrelayout/layout.go:583-592 | d2layouts/d2elklayout/layout.go:1159-1168 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:583` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/graphbounds/bounds.go:114— d2layouts/d2talalayout/internal/graphbounds/bounds.go:114-123 | d2layouts/d2talalayout/internal/labeling/guard.go:382-391 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/graphbounds/bounds.go:114` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:145— d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:145-154 | d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:462-471 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:145` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/packing/binpack.go:256— d2layouts/d2talalayout/internal/packing/binpack.go:256-265 | d2layouts/d2talalayout/internal/packing/binpack.go:894-903 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/binpack.go:256` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/packing/binpack.go:623— d2layouts/d2talalayout/internal/packing/binpack.go:623-632 | d2layouts/d2talalayout/internal/packing/binpack.go:729-738 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/binpack.go:623` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/placement/optimization_guard.go:663— d2layouts/d2talalayout/internal/placement/optimization_guard.go:663-672 | d2layouts/d2talalayout/internal/trees/geometry.go:609-618 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/optimization_guard.go:663` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/quality/crossings.go:92— d2layouts/d2talalayout/internal/quality/crossings.go:92-101 | d2layouts/d2talalayout/internal/routing/cost.go:73-82 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/routing/coordinator.go:1168— d2layouts/d2talalayout/internal/routing/coordinator.go:1168-1177 | d2layouts/d2talalayout/internal/routing/coordinator.go:1181-1190 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/coordinator.go:1168` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) REDACTED:1556— REDACTED:1556-1565 | REDACTED:1597-1606 — 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 (10 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1320— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1320-1329 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1352-1361 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1320` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/routing/slingshot.go:703— d2layouts/d2talalayout/internal/routing/slingshot.go:703-712 | d2layouts/d2talalayout/internal/routing/slingshot.go:928-937 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/slingshot.go:703` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:455— d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:455-464 | d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:466-475 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:455` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2renderers/d2ascii/asciiroute/routing.go:196— d2renderers/d2ascii/asciiroute/routing.go:196-205 | d2renderers/d2ascii/asciiroute/routing.go:270-279 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2ascii/asciiroute/routing.go:196` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2renderers/d2ascii/d2ascii.go:370— d2renderers/d2ascii/d2ascii.go:370-379 | d2renderers/d2ascii/d2ascii.go:387-396 — 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 (10 lines × 2) d2renderers/d2fonts/bundled_fallback.go:119— d2renderers/d2fonts/bundled_fallback.go:119-128 | d2renderers/d2fonts/fallback.go:146-155 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2fonts/bundled_fallback.go:119` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) d2renderers/d2raster/animation_value.go:222— d2renderers/d2raster/animation_value.go:222-231 | d2renderers/d2raster/gradient.go:514-523 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (10 lines × 2) d2renderers/d2raster/geometry.go:198— d2renderers/d2raster/geometry.go:198-207 | d2renderers/d2raster/geometry.go:253-262 — 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 (10 lines × 2) d2renderers/d2raster/gradient.go:728— d2renderers/d2raster/gradient.go:728-737 | d2renderers/d2raster/gradient.go:1027-1038 — 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 (10 lines × 2) d2renderers/d2raster/image.go:994— d2renderers/d2raster/image.go:994-1003 | d2renderers/d2raster/image.go:1026-1035 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:994` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) d2renderers/d2svg/d2svg.go:458— d2renderers/d2svg/d2svg.go:458-467 | d2renderers/d2svg/d2svg.go:507-516 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/d2svg.go:458` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) d2renderers/d2svg/d2svg.go:1884— d2renderers/d2svg/d2svg.go:1884-1893 | d2renderers/d2svg/d2svg.go:1914-1923 — 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 (10 lines × 2) d2layouts/d2layouts.go:611— d2layouts/d2layouts.go:611-620 | d2lib/d2.go:153-162 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (10 lines × 2) d2layouts/d2talalayout/internal/placement/edge_abduction_scratch.go:13— d2layouts/d2talalayout/internal/placement/edge_abduction_scratch.go:13-22 | d2layouts/d2talalayout/internal/placementcost/symmetry.go:33-42 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Hotspot: d2cli/main.go d2cli/main.go:62— d2cli/main.go changed 23 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 102 in d2cli.Run at line 62. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2cli/main.go`: 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: d2renderers/d2svg/d2svg.go d2renderers/d2svg/d2svg.go:1688— d2renderers/d2svg/d2svg.go changed 18 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 102 in d2svg.drawShape at line 1688. 2 of those changes were fix/bug commits, and the other 16 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2renderers/d2svg/d2svg.go`: 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: d2compiler/compile.go d2compiler/compile.go:863— d2compiler/compile.go changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 78 in compiler.compileReserved at line 863. 2 of those changes were fix/bug commits, and the other 12 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2compiler/compile.go`: 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: REDACTED REDACTED:415— REDACTED changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 69 in compiler.resolveSubstitutions at line 415. 1 of those changes was a fix/bug commit, 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- REDACTED`: 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: d2layouts/d2elklayout/layout.go d2layouts/d2elklayout/layout.go:257— d2layouts/d2elklayout/layout.go changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 93 in d2elklayout.Layout at line 257. 1 of those changes was a fix/bug commit, and the other 9 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2layouts/d2elklayout/layout.go`: 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: REDACTED REDACTED:1216— REDACTED changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 87 in Map.ensureField at line 1216. 1 of those changes was a fix/bug commit, and the other 7 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- REDACTED`: 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/textmeasure/markdown.go lib/textmeasure/markdown.go:330— lib/textmeasure/markdown.go changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 121 in Ruler.measureMarkdownNode at line 330. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- lib/textmeasure/markdown.go`: 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: d2js/d2wasm/functions.go d2js/d2wasm/functions.go:351— d2js/d2wasm/functions.go changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 68 in d2wasm.Render at line 351. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2js/d2wasm/functions.go`: 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: d2layouts/d2dagrelayout/layout.go d2layouts/d2dagrelayout/layout.go:53— d2layouts/d2dagrelayout/layout.go changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 66 in d2dagrelayout.Layout at line 53. 1 of those changes was a fix/bug commit, and the other 6 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2layouts/d2dagrelayout/layout.go`: 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: d2themes/element.go d2themes/element.go:138— d2themes/element.go changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 51 in ThemableElement.Render at line 138. 2 of those changes were fix/bug commits, and the other 4 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2themes/element.go`: 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: d2cli/raster.go d2cli/raster.go:555— d2cli/raster.go changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 31 in d2cli.renderGIFWithSession at line 555. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2cli/raster.go`: 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: d2layouts/d2layouts.go d2layouts/d2layouts.go:78— d2layouts/d2layouts.go changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 53 in d2layouts.LayoutNested at line 78. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2layouts/d2layouts.go`: 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: d2layouts/d2elklayout/wasm.go d2layouts/d2elklayout/wasm.go:23— d2layouts/d2elklayout/wasm.go changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 40 in d2elklayout.ConvertGraph at line 23. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2layouts/d2elklayout/wasm.go`: 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/xgif/xgif.go lib/xgif/xgif.go:1341— lib/xgif/xgif.go changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in xgif.validatePalettedImage at line 1341. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- lib/xgif/xgif.go`: 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: d2renderers/d2raster/effects.go d2renderers/d2raster/effects.go:322— d2renderers/d2raster/effects.go changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 51 in d2raster.planNodeResources at line 322. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2renderers/d2raster/effects.go`: 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: d2ir/import.go d2ir/import.go:86— d2ir/import.go changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in compiler.__import at line 86. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2ir/import.go`: 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: d2renderers/internal/fontface/shaping.go d2renderers/internal/fontface/shaping.go:111— d2renderers/internal/fontface/shaping.go changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 75 in ShapingWorkspace.ShapeTextTransient at line 111. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2renderers/internal/fontface/shaping.go`: 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/textmeasure/markdown_svg.go lib/textmeasure/markdown_svg.go:219— lib/textmeasure/markdown_svg.go changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 29 in MarkdownLayout.SVG at line 219. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- lib/textmeasure/markdown_svg.go`: 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: d2renderers/d2raster/raster.go d2renderers/d2raster/raster.go:615— d2renderers/d2raster/raster.go changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 46 in d2raster.prepareWithSessionBands at line 615. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2renderers/d2raster/raster.go`: 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: d2cli/paged.go d2cli/paged.go:509— d2cli/paged.go changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 20 in d2cli.renderPPTXWithRenderer at line 509. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2cli/paged.go`: 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/textmeasure/textmeasure.go lib/textmeasure/textmeasure.go:322— lib/textmeasure/textmeasure.go changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 17 in Ruler.scaleUnicodeFallback at line 322. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- lib/textmeasure/textmeasure.go`: 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/pdf/pdf.go lib/pdf/pdf.go:71— lib/pdf/pdf.go changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 16 in GoFPDF.AddPDFPage at line 71. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- lib/pdf/pdf.go`: 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: d2renderers/d2isometric/d2isometricimg/svg.go d2renderers/d2isometric/d2isometricimg/svg.go:119— d2renderers/d2isometric/d2isometricimg/svg.go changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 16 in d2isometricimg.svgPolygonPath at line 119. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- d2renderers/d2isometric/d2isometricimg/svg.go`: 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/font/subsetFont.go lib/font/subsetFont.go:338— lib/font/subsetFont.go changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 15 in utf8FontFile.GenerateCutFont at line 338. 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-13..2026-10-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-13 16:37:38 -07:00' --until='2026-10-11 16:37:38 -07:00' --full-history --no-merges -- lib/font/subsetFont.go`: 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.
Duplicated block (13 lines × 2) d2format/format.go:258— d2format/format.go:258-270 | d2format/format.go:314-326 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2format/format.go:258` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2layouts/d2layouts.go:623— d2layouts/d2layouts.go:623-635 | d2lib/d2.go:165-177 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (13 lines × 2) REDACTED:299— REDACTED:299-311 | REDACTED:320-332 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:299` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:222— d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:222-234 | d2layouts/d2talalayout/internal/packing/guard.go:72-84 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:222` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:223— d2layouts/d2talalayout/internal/labeling/placement.go:223-235 | d2layouts/d2talalayout/internal/labeling/placement.go:578-590 — 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 (13 lines × 2) d2layouts/d2talalayout/internal/packing/combine_snapshot.go:32— d2layouts/d2talalayout/internal/packing/combine_snapshot.go:32-44 | d2layouts/d2talalayout/internal/placement/types.go:54-66 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/combine_snapshot.go:32` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2layouts/d2talalayout/internal/placement/compaction.go:117— d2layouts/d2talalayout/internal/placement/compaction.go:117-129 | d2layouts/d2talalayout/internal/placement/compaction.go:180-192 — 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 (13 lines × 2) d2layouts/d2talalayout/internal/placement/gapreduction.go:427— d2layouts/d2talalayout/internal/placement/gapreduction.go:427-439 | d2layouts/d2talalayout/internal/placement/gapreduction.go:582-594 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/gapreduction.go:427` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2layouts/d2talalayout/internal/placementcost/axis.go:43— d2layouts/d2talalayout/internal/placementcost/axis.go:43-55 | d2layouts/d2talalayout/internal/placementcost/axis.go:81-93 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placementcost/axis.go:43` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2layouts/d2talalayout/internal/routing/coordinator.go:1226— d2layouts/d2talalayout/internal/routing/coordinator.go:1226-1238 | d2layouts/d2talalayout/internal/routing/coordinator.go:1240-1252 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/coordinator.go:1226` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2layouts/d2talalayout/internal/routing/coordinator.go:1774— d2layouts/d2talalayout/internal/routing/coordinator.go:1774-1786 | d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:438-450 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/coordinator.go:1774` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:435` calls `step` and `d2layouts/d2talalayout/internal/routing/coordinator.go:1773` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1234— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1234-1246 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1555-1567 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1234` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_resource.go:734— d2layouts/d2talalayout/internal/routing/ovg_resource.go:734-746 | d2layouts/d2talalayout/internal/routing/ovg_resource.go:755-767 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/ovg_resource.go:734` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) d2oracle/edit.go:2958— d2oracle/edit.go:2958-2970 | d2oracle/edit.go:3257-3269 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:2958` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) d2renderers/d2isometric/d2isometricimg/raster.go:739— d2renderers/d2isometric/d2isometricimg/raster.go:739-751 | d2renderers/d2isometric/d2isometricimg/svg_lighting.go:237-249 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (13 lines × 2) d2renderers/d2raster/geometry.go:502— d2renderers/d2raster/geometry.go:502-514 | d2renderers/d2raster/gradient.go:1354-1366 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) REDACTED:580— REDACTED:580-592 | REDACTED:683-695 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:580` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) d2renderers/d2scenebuild/build.go:607— d2renderers/d2scenebuild/build.go:607-619 | d2renderers/d2scenebuild/build.go:636-648 — 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 (13 lines × 2) d2renderers/d2svgimport/boilerplate.go:64— d2renderers/d2svgimport/boilerplate.go:64-76 | d2renderers/d2svgimport/clip.go:39-51 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svgimport/boilerplate.go:64` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) lib/xgif/xgif.go:728— lib/xgif/xgif.go:728-740 | lib/xgif/xgif.go:803-815 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/xgif/xgif.go:728` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lib/xgif/xgif.go:802` calls `squaredColorDifference` and `lib/xgif/xgif.go:727` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13 lines × 2) d2cli/paged.go:241— d2cli/paged.go:241-253 | d2cli/raster.go:974-986 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (16 lines × 2) d2ast/d2ast.go:1331— d2ast/d2ast.go:1331-1346 | d2ast/d2ast.go:1435-1450 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2ast/d2ast.go:1331` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) d2format/format.go:106— d2format/format.go:106-121 | d2format/format.go:184-199 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2format/format.go:106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) REDACTED:2123— REDACTED:2123-2138 | REDACTED:2143-2158 — 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) REDACTED:386— REDACTED:386-401 | REDACTED:436-451 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:386` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) d2layouts/d2talalayout/internal/grouping/lifecycle.go:52— d2layouts/d2talalayout/internal/grouping/lifecycle.go:52-67 | d2layouts/d2talalayout/internal/grouping/lifecycle.go:82-97 — 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) d2layouts/d2talalayout/internal/hierarchy/discovery.go:615— d2layouts/d2talalayout/internal/hierarchy/discovery.go:615-630 | d2layouts/d2talalayout/internal/hierarchy/discovery.go:631-646 — 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) d2layouts/d2talalayout/internal/labeling/guard.go:605— d2layouts/d2talalayout/internal/labeling/guard.go:605-620 | d2layouts/d2talalayout/internal/quality/labels.go:554-569 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/guard.go:605` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:1067— d2layouts/d2talalayout/internal/labeling/placement.go:1067-1082 | d2layouts/d2talalayout/internal/quality/labels.go:448-463 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:1067` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) d2layouts/d2talalayout/internal/packing/binpack.go:1150— d2layouts/d2talalayout/internal/packing/binpack.go:1150-1165 | d2layouts/d2talalayout/internal/packing/binpack.go:1168-1183 — 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) REDACTED:311— REDACTED:311-326 | REDACTED:602-617 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:311` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) REDACTED:1032— REDACTED:1032-1047 | REDACTED:1091-1106 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1032` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) REDACTED:1129— REDACTED:1129-1144 | REDACTED:1149-1164 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) REDACTED:889— REDACTED:889-904 | REDACTED:1459-1474 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:889` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) d2layouts/d2talalayout/internal/routing/slingshot.go:677— d2layouts/d2talalayout/internal/routing/slingshot.go:677-692 | d2layouts/d2talalayout/internal/routing/slingshot.go:901-916 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2layouts/d2talalayout/internal/routing/slingshot.go:918` calls `Nodes` and `d2layouts/d2talalayout/internal/routing/slingshot.go:694` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16 lines × 2) d2oracle/edit.go:125— d2oracle/edit.go:125-140 | d2oracle/edit.go:2512-2527 — 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) d2oracle/edit.go:2857— d2oracle/edit.go:2857-2872 | d2oracle/edit.go:3063-3078 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:2857` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) d2renderers/d2raster/effects.go:1733— d2renderers/d2raster/effects.go:1733-1748 | d2renderers/d2raster/effects.go:1872-1887 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1733` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16 lines × 2) d2renderers/d2svgimport/geometry.go:58— d2renderers/d2svgimport/geometry.go:58-73 | d2renderers/d2svgimport/image.go:36-51 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: `d2renderers/d2svgimport/image.go:36` is reached only past guards at line 29 (testing `element.attrs`) and line 32 (testing `element.attrs`) that each leave the function early, and `d2renderers/d2svgimport/geometry.go:58` reads `element.attrs` with no such check. What separates these copies is not which lines they run but which PRECONDITION they enforce, so one of them is operating on state the other one refuses. Decide which is intended BEFORE unifying them — extract the shared part and whichever copy is missing the check keeps running unchecked, and if the guard is the correct behaviour then that hole is already live.
Duplicated block (16 lines × 2) d2renderers/d2svgimport/geometry.go:71— d2renderers/d2svgimport/geometry.go:71-86 | d2renderers/d2svgimport/geometry.go:114-129 — 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.
ClassTooLong: compiler REDACTED:33— ClassTooLong — 1358 significant lines (blank, comment-only and punctuation-only lines excluded), 54 methods, 35 blocks, lines 33-2373. The bar is 400 significant lines; this is 958 over it, 3.40× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: parser d2parser/parse.go:159— ClassTooLong — 1114 significant lines (blank, comment-only and punctuation-only lines excluded), 35 methods, 36 blocks, lines 159-1930. The bar is 400 significant lines; this is 714 over it, 2.79× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Node d2layouts/d2talalayout/internal/layoutgraph/node.go:610— ClassTooLong — 1050 significant lines (blank, comment-only and punctuation-only lines excluded), 156 methods, 86 blocks, lines 29-2443. The bar is 400 significant lines; this is 650 over it, 2.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: compiler d2compiler/compile.go:420— ClassTooLong — 1036 significant lines (blank, comment-only and punctuation-only lines excluded), 30 methods, 31 blocks, lines 145-1998. The bar is 400 significant lines; this is 636 over it, 2.59× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: OVG REDACTED:18— ClassTooLong — 945 significant lines (blank, comment-only and punctuation-only lines excluded), 34 methods, 28 blocks, lines 18-1753. The bar is 400 significant lines; this is 545 over it, 2.36× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ovgEdgeRouter d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:46— ClassTooLong — 939 significant lines (blank, comment-only and punctuation-only lines excluded), 20 methods, 13 blocks, lines 46-1832. The bar is 400 significant lines; this is 539 over it, 2.35× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Map REDACTED:171— ClassTooLong — 844 significant lines (blank, comment-only and punctuation-only lines excluded), 63 methods, 45 blocks, lines 171-2451. The bar is 400 significant lines; this is 444 over it, 2.11× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: markdownPainter lib/textmeasure/markdown_svg.go:524— ClassTooLong — 822 significant lines (blank, comment-only and punctuation-only lines excluded), 21 methods, 22 blocks, lines 524-2040. The bar is 400 significant lines; this is 422 over it, 2.06× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Rasterizer REDACTED:99— ClassTooLong — 707 significant lines (blank, comment-only and punctuation-only lines excluded), 35 methods, 36 blocks, lines 99-1384. The bar is 400 significant lines; this is 307 over it, 1.77× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Graph d2layouts/d2talalayout/internal/layoutgraph/graph.go:25— ClassTooLong — 655 significant lines (blank, comment-only and punctuation-only lines excluded), 94 methods, 42 blocks, lines 25-1255. The bar is 400 significant lines; this is 255 over it, 1.64× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: sizedOptimizer REDACTED:19— ClassTooLong — 603 significant lines (blank, comment-only and punctuation-only lines excluded), 17 methods, 13 blocks, lines 19-1200. The bar is 400 significant lines; this is 203 over it, 1.51× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: builder d2renderers/d2scenebuild/build.go:122— ClassTooLong — 594 significant lines (blank, comment-only and punctuation-only lines excluded), 104 methods, 9 blocks, lines 122-1364. The bar is 400 significant lines; this is 194 over it, 1.49× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Transaction d2layouts/d2talalayout/internal/layoutgraph/transaction.go:61— ClassTooLong — 536 significant lines (blank, comment-only and punctuation-only lines excluded), 17 methods, 17 blocks, lines 61-1442. The bar is 400 significant lines; this is 136 over it, 1.34× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Object d2graph/d2graph.go:163— ClassTooLong — 530 significant lines (blank, comment-only and punctuation-only lines excluded), 50 methods, 30 blocks, lines 163-1968. The bar is 400 significant lines; this is 130 over it, 1.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: retainedVectorValidator d2renderers/d2raster/vector_validation.go:19— ClassTooLong — 515 significant lines (blank, comment-only and punctuation-only lines excluded), 18 methods, 19 blocks, lines 19-802. The bar is 400 significant lines; this is 115 over it, 1.29× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: preflight d2renderers/d2raster/raster.go:155— ClassTooLong — 480 significant lines (blank, comment-only and punctuation-only lines excluded), 30 methods, 19 blocks, lines 155-1471. The bar is 400 significant lines; this is 80 over it, 1.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: graphCloneState REDACTED:65— ClassTooLong — 434 significant lines (blank, comment-only and punctuation-only lines excluded), 14 methods, 15 blocks, lines 65-686. The bar is 400 significant lines; this is 34 over it, 1.09× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: utf8FontFile lib/font/subsetFont.go:35— ClassTooLong — 411 significant lines (blank, comment-only and punctuation-only lines excluded), 24 methods, 25 blocks, lines 35-663. The bar is 400 significant lines; this is 11 over it, 1.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Duplicated block (14 lines × 2) ci/release/releasetool/main.go:221— ci/release/releasetool/main.go:221-234 | ci/release/releasetool/main.go:789-802 — 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. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (14 lines × 2) REDACTED:1277— REDACTED:1277-1290 | REDACTED:1312-1325 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1277` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) d2ir/expansion.go:303— d2ir/expansion.go:303-316 | d2ir/expansion.go:333-346 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2ir/expansion.go:303` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (14 lines × 2) d2layouts/d2dagrelayout/layout.go:596— d2layouts/d2dagrelayout/layout.go:596-609 | d2layouts/d2elklayout/layout.go:1172-1185 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:596` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) d2layouts/d2talalayout/adapter.go:358— d2layouts/d2talalayout/adapter.go:358-371 | d2layouts/d2talalayout/adapter.go:410-423 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/adapter.go:358` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2layouts/d2talalayout/adapter.go:425` calls `Arrowhead` and `d2layouts/d2talalayout/adapter.go:372` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 2) d2layouts/d2talalayout/internal/placement/equidistance.go:105— d2layouts/d2talalayout/internal/placement/equidistance.go:105-118 | d2layouts/d2talalayout/internal/placement/transpose.go:38-51 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/equidistance.go:105` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) d2layouts/d2talalayout/internal/placement/metrics.go:67— d2layouts/d2talalayout/internal/placement/metrics.go:67-80 | d2layouts/d2talalayout/internal/placement/optimization_guard.go:392-405 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (14 lines × 2) d2layouts/d2talalayout/internal/placement/optimization_guard.go:267— d2layouts/d2talalayout/internal/placement/optimization_guard.go:267-280 | d2layouts/d2talalayout/internal/placement/optimization_guard.go:282-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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/optimization_guard.go:267` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) REDACTED:915— REDACTED:915-928 | REDACTED:410-423 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (14 lines × 2) d2layouts/d2talalayout/internal/placementcost/edge_length.go:871— d2layouts/d2talalayout/internal/placementcost/edge_length.go:871-884 | d2layouts/d2talalayout/internal/placementcost/edge_length.go:887-900 — 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) d2oracle/edit.go:1036— d2oracle/edit.go:1036-1049 | d2oracle/edit.go:1091-1105 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:1036` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) d2renderers/d2isometric/d2isometricimg/markdown_cards.go:50— d2renderers/d2isometric/d2isometricimg/markdown_cards.go:50-63 | d2renderers/d2isometric/d2isometricimg/native_structured.go:144-157 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2isometric/d2isometricimg/markdown_cards.go:50` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (14 lines × 2) d2renderers/d2raster/effects.go:1470— d2renderers/d2raster/effects.go:1470-1483 | d2renderers/d2raster/effects.go:1852-1865 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1470` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) d2renderers/d2raster/gradient.go:901— d2renderers/d2raster/gradient.go:901-914 | d2renderers/d2raster/gradient.go:1238-1251 — 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) d2layouts/d2talalayout/adapter.go:538— d2layouts/d2talalayout/adapter.go:538-551 | d2layouts/d2talalayout/internal/graphjson/direction.go:20-33 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Check import visibility before settling on that home: `d2layouts/d2talalayout/internal/graphjson/direction.go` sits under a restricted `internal` directory, which only code inside its own subtree is permitted to import from — so it is reachable from some of these sites and not from others, and being able to see the copies is not the same as being allowed to share them. The home has to be somewhere every one of these sites is permitted to import from; if there is no such place, that restriction may be exactly why the copies are separate.
Duplicated block (14 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:407— d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:407-420 | d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:487-500 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:407` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
TooManyMethods: Node d2layouts/d2talalayout/internal/layoutgraph/node.go:610— TooManyMethods — 156 methods, declared across 13 files: layoutgraph/node.go (85), layoutgraph/placement_access.go (22), layoutgraph/hierarchy_access.go (10), layoutgraph/routing_access.go (10), +9 more file(s). The bar is 30 methods; this is 126 over it, 5.20× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: builder d2renderers/d2scenebuild/build.go:122— TooManyMethods — 104 methods, declared across 19 files: d2scenebuild/sketch_shapes.go (14), d2scenebuild/assets.go (10), d2scenebuild/markdown.go (9), d2scenebuild/build.go (8), +15 more file(s). The bar is 30 methods; this is 74 over it, 3.47× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Graph d2layouts/d2talalayout/internal/layoutgraph/graph.go:25— TooManyMethods — 94 methods, declared across 16 files: layoutgraph/graph.go (41), layoutgraph/placement_access.go (9), layoutgraph/layout.go (8), layoutgraph/hierarchy_access.go (6), +12 more file(s). The bar is 30 methods; this is 64 over it, 3.13× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: svgImporter d2renderers/d2svgimport/import.go:350— TooManyMethods — 69 methods, declared across 11 files: d2svgimport/gradient.go (10), d2svgimport/compile.go (8), d2svgimport/import.go (8), d2svgimport/clip.go (7), +7 more file(s). The bar is 30 methods; this is 39 over it, 2.30× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: meshBuilder d2renderers/d2isometric/d2isometricimg/geometry.go:40— TooManyMethods — 68 methods, declared across 19 files: d2isometricimg/geometry.go (11), d2isometricimg/native_shapes.go (9), d2isometricimg/arrow_visibility.go (7), d2isometricimg/native_solids.go (7), +15 more file(s). The bar is 30 methods; this is 38 over it, 2.27× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Edge d2layouts/d2talalayout/internal/layoutgraph/edge.go:15— TooManyMethods — 64 methods, declared across 7 files: layoutgraph/edge.go (36), layoutgraph/routing_access.go (9), layoutgraph/hierarchy_access.go (7), layoutgraph/placement_access.go (6), +3 more file(s). The bar is 30 methods; this is 34 over it, 2.13× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Map REDACTED:171— TooManyMethods — 63 methods, declared across 4 files: REDACTED (54), d2ir/pattern.go (6), d2ir/query.go (2), REDACTED (1). The bar is 30 methods; this is 33 over it, 2.10× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: compiler REDACTED:33— TooManyMethods — 54 methods, declared across 6 files: REDACTED (34), d2ir/import.go (7), d2ir/expansion.go (5), d2ir/glob_expansion.go (5), +2 more file(s). The bar is 30 methods; this is 24 over it, 1.80× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Object d2graph/d2graph.go:163— TooManyMethods — 50 methods, declared across 4 files: d2graph/d2graph.go (29), d2graph/layout.go (9), d2graph/seqdiagram.go (8), d2graph/grid_diagram.go (4). The bar is 30 methods; this is 20 over it, 1.67× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: pipeline REDACTED:63— TooManyMethods — 40 methods. The bar is 30 methods; this is 10 over it, 1.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: parser d2parser/parse.go:159— TooManyMethods — 35 methods. The bar is 30 methods; this is 5 over it, 1.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Rasterizer REDACTED:99— TooManyMethods — 35 methods. The bar is 30 methods; this is 5 over it, 1.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Nodes d2layouts/d2talalayout/internal/layoutgraph/node.go:201— TooManyMethods — 34 methods, declared across 6 files: layoutgraph/node.go (18), layoutgraph/hierarchy_access.go (5), layoutgraph/graph.go (4), layoutgraph/placement_access.go (4), +2 more file(s). The bar is 30 methods; this is 4 over it, 1.13× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: OVG REDACTED:18— TooManyMethods — 34 methods, declared across 3 files: REDACTED (27), routing/ovg_hierarchy.go (6), routing/ovg_resource.go (1). The bar is 30 methods; this is 4 over it, 1.13× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Duplicated block (15 lines × 2) d2ast/d2ast.go:1364— d2ast/d2ast.go:1364-1378 | d2ast/d2ast.go:1406-1420 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) d2ast/d2ast.go:1400— d2ast/d2ast.go:1400-1414 | d2ast/d2ast.go:1493-1507 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2ast/d2ast.go:1400` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) d2compiler/compile.go:775— d2compiler/compile.go:775-789 | d2compiler/compile.go:958-972 — 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) d2layouts/d2dagrelayout/layout.go:1757— d2layouts/d2dagrelayout/layout.go:1757-1771 | d2layouts/d2dagrelayout/layout.go:1774-1788 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:1757` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:527— d2layouts/d2talalayout/internal/layoutgraph/transaction.go:527-541 | d2layouts/d2talalayout/internal/layoutgraph/transaction.go:928-942 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/transaction.go:527` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) d2layouts/d2talalayout/internal/placement/optimization_guard.go:231— d2layouts/d2talalayout/internal/placement/optimization_guard.go:231-245 | d2layouts/d2talalayout/internal/placement/optimization_guard.go:310-324 — 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) REDACTED:620— REDACTED:620-634 | REDACTED:635-649 — 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) REDACTED:651— REDACTED:651-665 | REDACTED:666-680 — 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) REDACTED:681— REDACTED:681-695 | REDACTED:696-710 — 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) d2layouts/d2talalayout/internal/routing/postprocess.go:609— d2layouts/d2talalayout/internal/routing/postprocess.go:609-623 | d2layouts/d2talalayout/internal/routing/postprocess.go:666-680 — 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) d2renderers/d2raster/effects.go:1419— d2renderers/d2raster/effects.go:1419-1433 | d2renderers/d2raster/effects.go:1477-1491 — 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) d2renderers/d2svg/class.go:149— d2renderers/d2svg/class.go:149-163 | d2renderers/d2svg/table.go:172-186 — before extracting anything, compare `d2renderers/d2svg/class.go` and `d2renderers/d2svg/table.go` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/class.go:149` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) d2renderers/d2svg/d2svg.go:1282— d2renderers/d2svg/d2svg.go:1282-1296 | d2renderers/d2svg/d2svg.go:2165-2179 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/d2svg.go:1282` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) d2renderers/d2svg/d2svg.go:1857— d2renderers/d2svg/d2svg.go:1857-1871 | d2renderers/d2svg/d2svg.go:1906-1920 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/d2svg.go:1857` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) d2compiler/compile.go:1439— d2compiler/compile.go:1439-1455 | d2compiler/compile.go:1480-1496 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2compiler/compile.go:1439` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) REDACTED:240— REDACTED:240-256 | REDACTED:258-274 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:240` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:34— d2layouts/d2talalayout/internal/labeling/placement.go:34-50 | d2layouts/d2talalayout/internal/labeling/placement.go:468-484 — 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. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (17 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:89— d2layouts/d2talalayout/internal/labeling/placement.go:89-105 | d2layouts/d2talalayout/internal/labeling/placement.go:555-571 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:89` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) d2layouts/d2talalayout/internal/nodeshape/shape_package.go:115— d2layouts/d2talalayout/internal/nodeshape/shape_package.go:115-131 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:82-98 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_package.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_square.go` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 134 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/nodeshape/shape_package.go:115` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1017— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1017-1033 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1066-1082 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1017` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1084` calls `isPortOf` and `d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1036` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17 lines × 2) d2layouts/d2talalayout/internal/routing/slingshot.go:110— d2layouts/d2talalayout/internal/routing/slingshot.go:110-126 | d2layouts/d2talalayout/internal/routing/slingshot.go:158-174 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/slingshot.go:110` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) d2renderers/d2isometric/d2isometricimg/svg_order.go:234— d2renderers/d2isometric/d2isometricimg/svg_order.go:234-250 | d2renderers/d2isometric/d2isometricimg/svg_visibility_tree.go:67-83 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2isometric/d2isometricimg/svg_order.go:234` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) d2renderers/d2raster/gradient.go:1166— d2renderers/d2raster/gradient.go:1166-1182 | d2renderers/d2raster/gradient.go:1210-1226 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:1166` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) d2renderers/d2raster/image.go:628— d2renderers/d2raster/image.go:628-644 | d2renderers/d2raster/image.go:907-923 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:628` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) d2renderers/d2raster/raster.go:1034— d2renderers/d2raster/raster.go:1034-1050 | d2renderers/d2raster/vector_validation.go:260-276 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/raster.go:1034` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) d2ast/d2ast.go:814— d2ast/d2ast.go:814-831 | d2ast/d2ast.go:896-913 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 2) d2js/d2wasm/functions.go:291— d2js/d2wasm/functions.go:291-308 | d2js/d2wasm/functions.go:427-444 — 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) d2layouts/d2talalayout/internal/hierarchy/discovery.go:418— d2layouts/d2talalayout/internal/hierarchy/discovery.go:418-435 | d2layouts/d2talalayout/internal/hierarchy/discovery.go:437-454 — 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) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:180— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:180-197 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:558-575 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:180` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:200— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:200-217 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:578-595 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:200` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (18 lines × 2) d2layouts/d2talalayout/internal/placement/transpose.go:154— d2layouts/d2talalayout/internal/placement/transpose.go:154-171 | d2layouts/d2talalayout/internal/placement/transpose.go:173-190 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/transpose.go:173` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (18 lines × 2) d2renderers/d2raster/gradient.go:831— d2renderers/d2raster/gradient.go:831-848 | d2renderers/d2raster/gradient.go:875-892 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:831` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) d2renderers/d2sketch/sketch.go:201— d2renderers/d2sketch/sketch.go:201-218 | d2renderers/d2sketch/sketch.go:273-290 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2sketch/sketch.go:201` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 2) d2renderers/d2sketch/sketch.go:848— d2renderers/d2sketch/sketch.go:848-865 | d2renderers/d2sketch/sketch.go:881-898 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2sketch/sketch.go:848` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) d2graph/layout.go:186— d2graph/layout.go:186-204 | d2graph/layout.go:240-258 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2graph/layout.go:186` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) d2layouts/d2talalayout/internal/placement/equidistance.go:338— d2layouts/d2talalayout/internal/placement/equidistance.go:338-356 | d2layouts/d2talalayout/internal/placement/equidistance.go:367-385 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/equidistance.go:338` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (19 lines × 2) d2layouts/d2talalayout/internal/placement/swap.go:145— d2layouts/d2talalayout/internal/placement/swap.go:145-163 | d2layouts/d2talalayout/internal/placement/swap.go:176-194 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/placement/swap.go:144` calls `Commit` and `d2layouts/d2talalayout/internal/placement/swap.go:175` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (19 lines × 2) d2layouts/d2talalayout/internal/routing/coordinator.go:474— d2layouts/d2talalayout/internal/routing/coordinator.go:474-492 | d2layouts/d2talalayout/internal/routing/coordinator.go:614-632 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/coordinator.go:474` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (19 lines × 2) d2oracle/edit.go:2879— d2oracle/edit.go:2879-2897 | d2oracle/edit.go:3197-3215 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:2879` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19 lines × 2) d2renderers/d2raster/effects.go:1496— d2renderers/d2raster/effects.go:1496-1514 | d2renderers/d2raster/effects.go:1608-1626 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1496` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (19 lines × 2) d2renderers/d2scenebuild/labels.go:136— d2renderers/d2scenebuild/labels.go:136-154 | d2renderers/d2scenebuild/markdown.go:79-97 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (7 lines × 3) d2layouts/d2dagrelayout/layout.go:594— d2layouts/d2dagrelayout/layout.go:594-600 | d2layouts/d2elklayout/layout.go:1170-1176 | d2layouts/d2grid/layout.go:208-214 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2dagrelayout/layout.go:594` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) d2layouts/d2talalayout/internal/graphbounds/bounds.go:59— d2layouts/d2talalayout/internal/graphbounds/bounds.go:59-65 | d2layouts/d2talalayout/internal/labeling/guard.go:335-341 | d2layouts/d2talalayout/internal/layoutgraph/node.go:101-107 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/graphbounds/bounds.go:59` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:83— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:83-89 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:117-123 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:84-90 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_package.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 66 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:83` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 3) d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:107— d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:107-113 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:121-127 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:88-94 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_callout.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_package.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 3) d2renderers/d2raster/image.go:189— d2renderers/d2raster/image.go:189-195 | d2renderers/d2svgimport/image.go:332-338 | lib/imageasset/probe.go:386-392 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:189` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 3) d2layouts/d2talalayout/internal/layoutgraph/node.go:1471— d2layouts/d2talalayout/internal/layoutgraph/node.go:1471-1477 | d2layouts/d2talalayout/internal/quality/crossings.go:77-83 | d2layouts/d2talalayout/internal/routing/geometry.go:48-54 — before extracting anything, compare `d2layouts/d2talalayout/internal/layoutgraph/node.go` and `d2layouts/d2talalayout/internal/routing/geometry.go` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 3) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:35— d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:35-41 | d2layouts/d2talalayout/internal/packing/combine.go:30-36 | d2layouts/d2talalayout/internal/routing/snapshot.go:33-39 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (8 lines × 3) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:93— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:93-100 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:127-134 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:94-101 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_package.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 66 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:93` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) d2layouts/d2talalayout/internal/nodeshape/shape_package.go:114— d2layouts/d2talalayout/internal/nodeshape/shape_package.go:114-121 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:81-88 | d2layouts/d2talalayout/internal/nodeshape/shape_step.go:86-93 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_package.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_square.go` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 134 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/nodeshape/shape_package.go:114` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 3) d2oracle/edit.go:2064— d2oracle/edit.go:2064-2071 | d2oracle/edit.go:2078-2085 | d2oracle/edit.go:2090-2097 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 3) d2renderers/d2raster/effects.go:1419— d2renderers/d2raster/effects.go:1419-1426 | d2renderers/d2raster/effects.go:1477-1484 | d2renderers/d2raster/effects.go:1590-1597 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 3) REDACTED:543— REDACTED:543-550 | REDACTED:645-652 | REDACTED:755-762 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 3) d2renderers/d2sketch/sketch.go:84— d2renderers/d2sketch/sketch.go:84-91 | d2renderers/d2sketch/sketch.go:151-158 | d2renderers/d2sketch/sketch.go:606-613 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×5
Members sharing a duplicated core (4 members, 50+ identical tokens) d2layouts/d2talalayout/internal/hierarchy/discovery.go:38— d2layouts/d2talalayout/internal/hierarchy/discovery.go:38-97 | REDACTED:105-139 | REDACTED:192-256 | d2layouts/d2talalayout/internal/trees/layout.go:646-693 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) d2layouts/d2talalayout/internal/labeling/guard.go:486— d2layouts/d2talalayout/internal/labeling/guard.go:486-555 | d2layouts/d2talalayout/internal/labeling/guard.go:557-620 | d2layouts/d2talalayout/internal/quality/labels.go:512-569 | d2layouts/d2talalayout/internal/routing/route_stage_guard.go:554-605 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) d2layouts/d2talalayout/internal/proximity/nears.go:203— d2layouts/d2talalayout/internal/proximity/nears.go:203-225 | d2layouts/d2talalayout/internal/routing/ovg_resource.go:460-482 | d2layouts/d2talalayout/internal/routing/route_search_guard.go:265-287 | d2layouts/d2talalayout/internal/routing/tunnel.go:69-91 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) d2renderers/d2ascii/asciishapes/helpers.go:21— d2renderers/d2ascii/asciishapes/helpers.go:21-41 | d2renderers/d2ascii/asciishapes/package.go:5-34 | d2renderers/d2ascii/asciishapes/page.go:7-47 | d2renderers/d2ascii/asciishapes/rectangle.go:11-58 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) d2renderers/d2raster/gradient.go:789— d2renderers/d2raster/gradient.go:789-848 | d2renderers/d2raster/gradient.go:850-892 | d2renderers/d2raster/gradient.go:1123-1182 | d2renderers/d2raster/gradient.go:1184-1226 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Duplicated block (22 lines × 2) d2graph/layout.go:434— d2graph/layout.go:434-455 | d2graph/layout.go:465-486 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2graph/layout.go:434` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) d2graph/layout.go:516— d2graph/layout.go:516-537 | d2graph/layout.go:548-569 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2graph/layout.go:516` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) REDACTED:107— REDACTED:107-128 | REDACTED:130-151 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) d2layouts/d2talalayout/result_validate.go:311— d2layouts/d2talalayout/result_validate.go:311-332 | d2layouts/d2talalayout/result_validate.go:333-354 — 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 (22 lines × 2) d2renderers/d2sketch/sketch.go:438— d2renderers/d2sketch/sketch.go:438-459 | d2renderers/d2sketch/sketch.go:571-592 — 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) d2layouts/d2talalayout/internal/grouping/lifecycle.go:130— d2layouts/d2talalayout/internal/grouping/lifecycle.go:130-149 | d2layouts/d2talalayout/internal/grouping/lifecycle.go:165-184 — 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) d2layouts/d2talalayout/internal/packing/binpack.go:370— d2layouts/d2talalayout/internal/packing/binpack.go:370-389 | d2layouts/d2talalayout/internal/packing/binpack.go:812-831 — 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) d2renderers/d2fonts/bundled_fallback.go:98— d2renderers/d2fonts/bundled_fallback.go:98-117 | d2renderers/d2fonts/fallback.go:125-144 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (20 lines × 2) d2renderers/d2fonts/bundled_fallback.go:262— d2renderers/d2fonts/bundled_fallback.go:262-281 | d2renderers/d2fonts/fallback.go:630-649 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2fonts/bundled_fallback.go:262` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) d2renderers/d2svg/d2svg.go:372— d2renderers/d2svg/d2svg.go:372-391 | d2renderers/d2svg/d2svg.go:419-438 — 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 (12 lines × 3) d2ast/d2ast.go:1363— d2ast/d2ast.go:1363-1374 | d2ast/d2ast.go:1405-1416 | d2ast/d2ast.go:1498-1509 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2ast/d2ast.go:1363` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 3) d2cli/raster_png_encoder.go:589— d2cli/raster_png_encoder.go:589-600 | d2renderers/d2raster/raster.go:598-609 | lib/xgif/xgif.go:1528-1539 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (12 lines × 3) REDACTED:1602— REDACTED:1602-1613 | REDACTED:1729-1740 | REDACTED:1861-1872 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1602` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) d2layouts/d2talalayout/internal/labeling/placement.go:163— d2layouts/d2talalayout/internal/labeling/placement.go:163-174 | d2layouts/d2talalayout/internal/labeling/placement.go:596-607 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:626-637 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:163` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) d2renderers/d2raster/effects.go:1735— d2renderers/d2raster/effects.go:1735-1746 | d2renderers/d2raster/effects.go:1835-1846 | d2renderers/d2raster/effects.go:1874-1885 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1735` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) d2layouts/d2talalayout/internal/hierarchy/discovery.go:120— d2layouts/d2talalayout/internal/hierarchy/discovery.go:120-140 | REDACTED:143-163 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/hierarchy/discovery.go:120` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (21 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/node.go:864— d2layouts/d2talalayout/internal/layoutgraph/node.go:864-884 | d2layouts/d2talalayout/internal/layoutgraph/node.go:886-906 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/node.go:864` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21 lines × 2) d2layouts/d2talalayout/internal/nodeshape/shape_cloud.go:80— d2layouts/d2talalayout/internal/nodeshape/shape_cloud.go:80-100 | d2layouts/d2talalayout/internal/nodeshape/shape_person.go:80-100 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_cloud.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_person.go` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 72 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (21 lines × 2) d2layouts/d2talalayout/internal/packing/binpack.go:305— d2layouts/d2talalayout/internal/packing/binpack.go:305-325 | d2layouts/d2talalayout/internal/packing/binpack.go:742-762 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/binpack.go:305` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) d2layouts/d2talalayout/internal/hierarchy/discovery.go:46— d2layouts/d2talalayout/internal/hierarchy/discovery.go:46-58 | REDACTED:116-128 | d2layouts/d2talalayout/internal/trees/layout.go:656-668 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/hierarchy/discovery.go:46` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/trees/layout.go:654` calls `SetLimit` and `d2layouts/d2talalayout/internal/hierarchy/discovery.go:45` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13 lines × 3) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:748— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:748-760 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:770-782 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:786-798 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:748` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) d2layouts/d2talalayout/internal/trees/geometry.go:254— d2layouts/d2talalayout/internal/trees/geometry.go:254-266 | d2layouts/d2talalayout/internal/trees/geometry.go:723-735 | d2layouts/d2talalayout/internal/trees/geometry.go:777-789 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/trees/geometry.go:254` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) d2renderers/d2ascii/d2ascii.go:157— d2renderers/d2ascii/d2ascii.go:157-169 | d2renderers/d2ascii/d2ascii.go:177-189 | d2renderers/d2ascii/d2ascii.go:197-209 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2ascii/d2ascii.go:157` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) d2layouts/d2talalayout/internal/labeling/placement.go:199— d2layouts/d2talalayout/internal/labeling/placement.go:199-208 | d2layouts/d2talalayout/internal/labeling/placement.go:224-233 | d2layouts/d2talalayout/internal/labeling/placement.go:579-588 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 3) d2renderers/d2raster/filter.go:944— d2renderers/d2raster/filter.go:944-953 | d2renderers/d2raster/filter.go:984-993 | d2renderers/d2raster/filter.go:1110-1119 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:944` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (10 lines × 3) REDACTED:509— REDACTED:509-518 | REDACTED:615-624 | REDACTED:739-748 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:509` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) REDACTED:578— REDACTED:578-587 | REDACTED:681-690 | REDACTED:783-792 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:578` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) d2layouts/d2talalayout/internal/layoutgraph/node.go:1480— d2layouts/d2talalayout/internal/layoutgraph/node.go:1480-1485 | d2layouts/d2talalayout/internal/quality/labels.go:380-384 | d2layouts/d2talalayout/internal/routing/geometry.go:57-61 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/node.go:1480` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) d2layouts/d2talalayout/internal/layoutgraph/node.go:1486— d2layouts/d2talalayout/internal/layoutgraph/node.go:1486-1491 | d2layouts/d2talalayout/internal/quality/labels.go:385-389 | d2layouts/d2talalayout/internal/routing/geometry.go:62-66 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/node.go:1486` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 3) d2layouts/d2talalayout/internal/layoutgraph/node.go:1497— d2layouts/d2talalayout/internal/layoutgraph/node.go:1497-1501 | d2layouts/d2talalayout/internal/quality/labels.go:395-399 | d2layouts/d2talalayout/internal/routing/geometry.go:72-76 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (5 lines × 3) d2renderers/d2isometric/d2isometricimg/geometry_routes.go:114— d2renderers/d2isometric/d2isometricimg/geometry_routes.go:114-118 | d2renderers/d2isometric/d2isometricimg/route_style.go:34-38 | d2renderers/d2isometric/d2isometricimg/route_style.go:58-62 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2isometric/d2isometricimg/geometry_routes.go:114` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2renderers/d2isometric/d2isometricimg/route_style.go:55` calls `nativeMaterial` and `d2renderers/d2isometric/d2isometricimg/route_style.go:32` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 3) d2renderers/d2scenebuild/build.go:1309— d2renderers/d2scenebuild/build.go:1309-1314 | d2renderers/d2svg/d2svg.go:108-113 | d2target/render_validation.go:417-422 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (6 lines × 3) d2renderers/d2scenebuild/build.go:1316— d2renderers/d2scenebuild/build.go:1316-1321 | d2renderers/d2svg/d2svg.go:115-120 | d2target/render_validation.go:424-429 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (6 lines × 3) REDACTED:359— REDACTED:359-364 | REDACTED:380-385 | REDACTED:475-480 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 3) d2target/d2target.go:427— d2target/d2target.go:427-432 | d2target/d2target.go:434-439 | d2target/d2target.go:441-446 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2target/d2target.go:427` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Low cohesion: Node (LCOM4 13) d2layouts/d2talalayout/internal/layoutgraph/node.go:610— Node's methods fall into 13 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 13 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Edge (LCOM4 5) d2graph/d2graph.go:1208— Edge's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Edge (LCOM4 4) d2layouts/d2talalayout/internal/layoutgraph/edge.go:15— Edge's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: OVGNode (LCOM4 4) d2layouts/d2talalayout/internal/routing/ovg_node.go:8— OVGNode's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
TooManyFields: ThemableElement d2themes/element.go:16— TooManyFields — 36 stored fields beside 9 methods. The bar is 30 stored fields; this is 6 over it, 1.20× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: builder d2renderers/d2scenebuild/build.go:122— TooManyFields — 35 stored fields beside 104 methods. The bar is 30 stored fields; this is 5 over it, 1.17× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: Shape d2target/d2target.go:769— TooManyFields — 33 stored fields beside 5 methods. The bar is 30 stored fields; this is 3 over it, 1.10× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
D4 · Code Duplication· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×3
Members sharing a duplicated core (6 members, 50+ identical tokens) d2renderers/d2raster/effects.go:1391— d2renderers/d2raster/effects.go:1391-1455 | d2renderers/d2raster/effects.go:1461-1514 | d2renderers/d2raster/effects.go:1516-1626 | d2renderers/d2raster/effects.go:1689-1748 | d2renderers/d2raster/effects.go:1760-1887 | lib/xgif/xgif.go:1341-1447 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) d2renderers/d2raster/gradient.go:692— d2renderers/d2raster/gradient.go:692-721 | d2renderers/d2raster/gradient.go:723-787 | d2renderers/d2raster/gradient.go:789-848 | d2renderers/d2raster/gradient.go:850-892 | d2renderers/d2raster/gradient.go:894-932 | d2renderers/d2raster/gradient.go:934-986 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) d2renderers/d2raster/gradient.go:1022— d2renderers/d2raster/gradient.go:1022-1090 | d2renderers/d2raster/gradient.go:1092-1121 | d2renderers/d2raster/gradient.go:1123-1182 | d2renderers/d2raster/gradient.go:1184-1226 | d2renderers/d2raster/gradient.go:1228-1266 | d2renderers/d2raster/gradient.go:1268-1320 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Duplicated block (30 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:53— d2layouts/d2talalayout/internal/labeling/placement.go:53-82 | d2layouts/d2talalayout/internal/labeling/placement.go:495-524 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:53` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (30 lines × 2) d2oracle/edit.go:2371— d2oracle/edit.go:2371-2400 | d2oracle/edit.go:2416-2445 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:2371` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (30 lines × 2) lib/xgif/xgif.go:765— lib/xgif/xgif.go:765-794 | lib/xgif/xgif.go:830-859 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/xgif/xgif.go:765` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lib/xgif/xgif.go:829` calls `squaredColorDifference` and `lib/xgif/xgif.go:764` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (26 lines × 2) d2layouts/d2talalayout/internal/routing/coordinator.go:493— d2layouts/d2talalayout/internal/routing/coordinator.go:493-518 | d2layouts/d2talalayout/internal/routing/coordinator.go:634-659 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/coordinator.go:493` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (26 lines × 2) d2renderers/d2sketch/sketch.go:80— d2renderers/d2sketch/sketch.go:80-105 | d2renderers/d2sketch/sketch.go:147-172 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2sketch/sketch.go:80` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (26 lines × 2) d2renderers/d2scenebuild/build.go:1323— d2renderers/d2scenebuild/build.go:1323-1348 | d2renderers/d2svg/d2svg.go:151-176 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (24 lines × 2) REDACTED:1768— REDACTED:1768-1791 | REDACTED:1842-1865 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1768` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24 lines × 2) d2layouts/d2elklayout/layout.go:278— d2layouts/d2elklayout/layout.go:278-301 | d2layouts/d2elklayout/wasm.go:38-61 — before extracting anything, compare `d2layouts/d2elklayout/layout.go` and `d2layouts/d2elklayout/wasm.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (24 lines × 2) d2renderers/d2svg/d2svg.go:1940— d2renderers/d2svg/d2svg.go:1940-1963 | d2renderers/d2svg/d2svg.go:1972-1995 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/d2svg.go:1940` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2renderers/d2svg/d2svg.go:1997` calls `FromString`, `IsBorder`, `SetMaskID` and `d2renderers/d2svg/d2svg.go:1964` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 4) d2layouts/d2talalayout/internal/hierarchy/discovery.go:48— d2layouts/d2talalayout/internal/hierarchy/discovery.go:48-59 | REDACTED:118-129 | REDACTED:211-222 | d2layouts/d2talalayout/internal/trees/layout.go:658-669 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/hierarchy/discovery.go:48` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/trees/layout.go:654` calls `SetLimit` and `d2layouts/d2talalayout/internal/hierarchy/discovery.go:45` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 4) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:185— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:185-196 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:205-216 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:563-574 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:583-594 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 4) d2renderers/d2raster/gradient.go:700— d2renderers/d2raster/gradient.go:700-711 | d2renderers/d2raster/gradient.go:815-826 | d2renderers/d2raster/gradient.go:859-870 | d2renderers/d2raster/gradient.go:943-954 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:700` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) d2layouts/d2dagrelayout/layout.go:1226— d2layouts/d2dagrelayout/layout.go:1226-1235 | d2layouts/d2dagrelayout/layout.go:1237-1247 — 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 (10–11 lines × 2) d2layouts/d2talalayout/internal/graphbounds/bounds.go:148— d2layouts/d2talalayout/internal/graphbounds/bounds.go:148-157 | d2layouts/d2talalayout/internal/layoutgraph/node.go:528-538 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/graphbounds/bounds.go:148` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/layoutgraph/node.go:527` calls `boundingBoxValues` and `d2layouts/d2talalayout/internal/graphbounds/bounds.go:147` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10–11 lines × 2) d2layouts/d2talalayout/internal/packing/combine.go:39— d2layouts/d2talalayout/internal/packing/combine.go:39-48 | d2layouts/d2talalayout/internal/routing/snapshot.go:42-52 — before extracting anything, compare `d2layouts/d2talalayout/internal/packing/combine.go` and `d2layouts/d2talalayout/internal/routing/snapshot.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9–10 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:1057— d2layouts/d2talalayout/internal/labeling/placement.go:1057-1066 | d2layouts/d2talalayout/internal/quality/labels.go:439-447 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:1057` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/node.go:1007— d2layouts/d2talalayout/internal/layoutgraph/node.go:1007-1016 | d2layouts/d2talalayout/internal/quality/labels.go:329-337 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9–10 lines × 2) d2renderers/d2scenebuild/assets.go:162— d2renderers/d2scenebuild/assets.go:162-171 | d2renderers/d2scenebuild/latex.go:75-83 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (9 lines × 3) d2renderers/d2raster/effects.go:1024— d2renderers/d2raster/effects.go:1024-1032 | d2renderers/d2raster/effects.go:1118-1126 | d2renderers/d2raster/effects.go:1238-1246 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1024` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) d2renderers/d2svgimport/path.go:343— d2renderers/d2svgimport/path.go:343-351 | d2renderers/d2svgimport/path.go:354-362 | d2renderers/d2svgimport/path.go:374-382 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 3) d2renderers/d2svgimport/transform.go:148— d2renderers/d2svgimport/transform.go:148-156 | d2renderers/d2svgimport/transform.go:159-167 | d2renderers/d2svgimport/transform.go:179-187 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 4) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:739— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:739-746 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:747-754 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:769-776 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:785-792 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 4) d2renderers/d2raster/filter.go:601— d2renderers/d2raster/filter.go:601-608 | d2renderers/d2raster/filter.go:644-651 | d2renderers/d2raster/filter.go:701-708 | d2renderers/d2raster/filter.go:754-761 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:601` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (8 lines × 4) d2layouts/d2talalayout/internal/layoutgraph/hub_spoke.go:4— d2layouts/d2talalayout/internal/layoutgraph/hub_spoke.go:4-11 | d2layouts/d2talalayout/internal/layoutgraph/layout.go:32-39 | d2layouts/d2talalayout/internal/layoutgraph/layout.go:42-49 | d2layouts/d2talalayout/internal/layoutgraph/layout.go:52-59 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
Near-duplicate member pair (22 shared lines) d2layouts/d2talalayout/internal/graphbounds/bounds.go:49— d2layouts/d2talalayout/internal/graphbounds/bounds.go:49-134 | d2layouts/d2talalayout/internal/labeling/guard.go:325-402 — These two members are variants of one another: 22 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (22 shared lines) d2renderers/d2raster/filter.go:653— d2renderers/d2raster/filter.go:653-761 | d2renderers/d2raster/filter.go:838-916 — These two members are variants of one another: 22 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Edited copy of a member (22 corresponding lines) · ×2
Edited copy of a member (22 corresponding lines) d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:99— d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:99-120 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:113-134 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (22 corresponding lines) d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:99— d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:99-120 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:80-101 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (19 corresponding lines) · ×2
Edited copy of a member (19 corresponding lines) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:79— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:79-100 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:113-134 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (19 corresponding lines) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:79— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:79-100 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:80-101 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (45 lines × 2) d2layouts/d2elklayout/layout.go:302— d2layouts/d2elklayout/layout.go:302-346 | d2layouts/d2elklayout/wasm.go:62-106 — before extracting anything, compare `d2layouts/d2elklayout/layout.go` and `d2layouts/d2elklayout/wasm.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2elklayout/layout.go:302` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (45 lines × 2) d2layouts/d2talalayout/internal/packing/combine_snapshot.go:52— d2layouts/d2talalayout/internal/packing/combine_snapshot.go:52-96 | d2layouts/d2talalayout/internal/placement/types.go:74-118 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/combine_snapshot.go:52` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (44 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:379— d2layouts/d2talalayout/internal/labeling/placement.go:379-422 | d2layouts/d2talalayout/internal/labeling/placement.go:611-654 — 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 (44 lines × 2) d2parser/parse.go:530— d2parser/parse.go:530-573 | d2parser/parse.go:1666-1709 — 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 (28–30 lines × 2) d2layouts/d2talalayout/internal/routing/balance_route_guard.go:102— d2layouts/d2talalayout/internal/routing/balance_route_guard.go:102-129 | lib/geo/segment.go:90-119 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/balance_route_guard.go:102` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Check import visibility before settling on that home: `d2layouts/d2talalayout/internal/routing/balance_route_guard.go` sits under a restricted `internal` directory, which only code inside its own subtree is permitted to import from — so it is reachable from some of these sites and not from others, and being able to see the copies is not the same as being allowed to share them. The home has to be somewhere every one of these sites is permitted to import from; if there is no such place, that restriction may be exactly why the copies are separate. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/routing/balance_route_guard.go:99` calls `step` and `lib/geo/segment.go:89` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (28–30 lines × 2) d2oracle/edit.go:2940— d2oracle/edit.go:2940-2967 | d2oracle/edit.go:3128-3157 — 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 (28–29 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:426— d2layouts/d2talalayout/internal/labeling/placement.go:426-454 | d2layouts/d2talalayout/internal/labeling/placement.go:658-685 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:426` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (28–29 lines × 2) d2layouts/d2talalayout/internal/packing/binpack.go:424— d2layouts/d2talalayout/internal/packing/binpack.go:424-451 | d2layouts/d2talalayout/internal/packing/binpack.go:833-861 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/binpack.go:424` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (23 lines × 2) d2layouts/d2talalayout/internal/quality/crossings.go:51— d2layouts/d2talalayout/internal/quality/crossings.go:51-73 | d2layouts/d2talalayout/internal/routing/cost.go:42-64 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (23 lines × 2) d2renderers/d2raster/gradient.go:958— d2renderers/d2raster/gradient.go:958-980 | d2renderers/d2raster/gradient.go:1293-1315 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:958` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20 lines × 3) d2renderers/d2raster/gradient.go:808— d2renderers/d2raster/gradient.go:808-827 | d2renderers/d2raster/gradient.go:852-871 | d2renderers/d2raster/gradient.go:936-955 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:808` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 3) d2renderers/d2raster/gradient.go:1143— d2renderers/d2raster/gradient.go:1143-1162 | d2renderers/d2raster/gradient.go:1187-1206 | d2renderers/d2raster/gradient.go:1271-1290 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:1143` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–16 lines × 2) d2renderers/d2ascii/asciiroute/labels.go:137— d2renderers/d2ascii/asciiroute/labels.go:137-151 | d2renderers/d2ascii/asciiroute/labels.go:169-184 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2ascii/asciiroute/labels.go:137` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15–16 lines × 2) lib/textmeasure/textmeasure.go:198— lib/textmeasure/textmeasure.go:198-213 | lib/textmeasure/textmeasure.go:225-239 — 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–15 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:913— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:913-927 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:952-965 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:913` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–15 lines × 2) d2renderers/d2scenebuild/appendix.go:55— d2renderers/d2scenebuild/appendix.go:55-68 | d2renderers/d2scenebuild/appendix.go:89-103 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/appendix.go:55` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 4) d2layouts/d2talalayout/internal/labeling/placement.go:90— d2layouts/d2talalayout/internal/labeling/placement.go:90-102 | d2layouts/d2talalayout/internal/labeling/placement.go:534-546 | d2layouts/d2talalayout/internal/labeling/placement.go:556-568 | d2layouts/d2talalayout/internal/labeling/placement.go:813-825 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13 lines × 4) d2renderers/d2raster/gradient.go:830— d2renderers/d2raster/gradient.go:830-842 | d2renderers/d2raster/gradient.go:874-886 | d2renderers/d2raster/gradient.go:1165-1177 | d2renderers/d2raster/gradient.go:1209-1221 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–12 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/node.go:1524— d2layouts/d2talalayout/internal/layoutgraph/node.go:1524-1535 | d2layouts/d2talalayout/internal/quality/labels.go:362-372 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/node.go:1524` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 2) lib/geo/bezier.go:185— lib/geo/bezier.go:185-195 | lib/geo/bezier.go:261-272 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/geo/bezier.go:185` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11 lines × 3) d2oracle/edit.go:2958— d2oracle/edit.go:2958-2968 | d2oracle/edit.go:3147-3158 | d2oracle/edit.go:3257-3267 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11 lines × 3) d2renderers/d2raster/effects.go:388— d2renderers/d2raster/effects.go:388-398 | d2renderers/d2raster/effects.go:409-419 | d2renderers/d2raster/effects.go:469-479 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 6) d2renderers/d2raster/gradient.go:1040— d2renderers/d2raster/gradient.go:1040-1048 | d2renderers/d2raster/gradient.go:1093-1101 | d2renderers/d2raster/gradient.go:1141-1149 | d2renderers/d2raster/gradient.go:1185-1193 | d2renderers/d2raster/gradient.go:1229-1237 | d2renderers/d2raster/gradient.go:1269-1277 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:1040` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2renderers/d2raster/gradient.go:1049` calls `wrapped` and `d2renderers/d2raster/gradient.go:1102` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 6) REDACTED:508— REDACTED:508-516 | REDACTED:577-585 | REDACTED:614-622 | REDACTED:680-688 | REDACTED:738-746 | REDACTED:782-790 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:508` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:611` calls `RGBA`, `max` and `REDACTED:678` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–9 lines × 2) d2layouts/d2talalayout/internal/placement/gapreduction.go:608— d2layouts/d2talalayout/internal/placement/gapreduction.go:608-616 | d2layouts/d2talalayout/internal/placement/gapreduction.go:701-708 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/gapreduction.go:608` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–9 lines × 2) lib/geo/bezier.go:183— lib/geo/bezier.go:183-190 | lib/geo/bezier.go:203-211 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/geo/bezier.go:183` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 7) d2layouts/d2talalayout/internal/trees/geometry.go:253— d2layouts/d2talalayout/internal/trees/geometry.go:253-259 | d2layouts/d2talalayout/internal/trees/geometry.go:294-300 | d2layouts/d2talalayout/internal/trees/geometry.go:681-687 | d2layouts/d2talalayout/internal/trees/geometry.go:722-728 | d2layouts/d2talalayout/internal/trees/geometry.go:776-782 | d2layouts/d2talalayout/internal/trees/geometry.go:810-816 | d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:583-589 — there are 7 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/trees/geometry.go:253` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 7) d2renderers/d2raster/image.go:593— d2renderers/d2raster/image.go:593-599 | d2renderers/d2raster/image.go:614-620 | d2renderers/d2raster/image.go:755-761 | d2renderers/d2raster/image.go:789-795 | d2renderers/d2raster/image.go:824-830 | d2renderers/d2raster/image.go:852-858 | d2renderers/d2raster/image.go:884-890 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:593` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 6) d2renderers/d2raster/gradient.go:693— d2renderers/d2raster/gradient.go:693-698 | d2renderers/d2raster/gradient.go:738-743 | d2renderers/d2raster/gradient.go:807-812 | d2renderers/d2raster/gradient.go:851-856 | d2renderers/d2raster/gradient.go:895-900 | d2renderers/d2raster/gradient.go:935-940 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:693` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2renderers/d2raster/gradient.go:744` calls `wrapped` and `d2renderers/d2raster/gradient.go:699` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 6) d2renderers/d2sketch/sketch.go:73— d2renderers/d2sketch/sketch.go:73-78 | d2renderers/d2sketch/sketch.go:123-128 | d2renderers/d2sketch/sketch.go:183-188 | d2renderers/d2sketch/sketch.go:239-244 | d2renderers/d2sketch/sketch.go:444-449 | d2renderers/d2sketch/sketch.go:577-582 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2renderers/d2sketch/sketch.go:80` calls `FromString`, `IsBorder`, `SetMaskID` and `d2renderers/d2sketch/sketch.go:450` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) d2renderers/d2ascii/asciishapes/helpers.go:29— d2renderers/d2ascii/asciishapes/helpers.go:29-33 | d2renderers/d2ascii/asciishapes/package.go:20-24 | d2renderers/d2ascii/asciishapes/page.go:27-31 | d2renderers/d2ascii/asciishapes/rectangle.go:38-42 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2ascii/asciishapes/helpers.go:29` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2renderers/d2ascii/asciishapes/rectangle.go:43` calls `TrimSpace`, `Set` and `d2renderers/d2ascii/asciishapes/helpers.go:34` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) d2renderers/d2raster/raster.go:1244— d2renderers/d2raster/raster.go:1244-1248 | d2renderers/d2raster/raster.go:1267-1271 | d2renderers/d2raster/raster.go:1291-1295 | d2renderers/d2raster/text.go:414-418 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/raster.go:1244` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 4) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:71— d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:71-76 | d2layouts/d2talalayout/internal/packing/snapshot.go:8-13 | d2layouts/d2talalayout/internal/placement/types.go:21-26 | d2layouts/d2talalayout/internal/routing/snapshot.go:13-18 — before extracting anything, compare `d2layouts/d2talalayout/internal/packing/snapshot.go` and `d2layouts/d2talalayout/internal/placement/types.go` as WHOLE FILES: 92% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 4) lib/shape/shape_c4_person.go:136— lib/shape/shape_c4_person.go:136-141 | lib/shape/shape_cylinder.go:78-83 | lib/shape/shape_page.go:85-90 | lib/shape/shape_queue.go:74-79 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
AC6 · Visual & motion safety· Focus outline removed in CSS without a · ×1
Focus outline removed in CSS without a :focus replacement d2renderers/d2svg/github-markdown.css:358— `.md .anchor: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.
AC7 · A11y enforcement· Accessibility enforcement below the top rung · ×1
Accessibility enforcement below the top rung — No accessibility enforcement found — no automated accessibility check runs over the HTML your app renders. Assert the accessibility invariants over that HTML in the test suite you already have (parse the output and assert, or drive a browser), and gate that test in CI so a regression blocks the merge. What was searched, so you can tell an absence from a miss: the 1 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.
placementcost.evaluateNodeEdgeLength (cyclomatic 268) d2layouts/d2talalayout/internal/placementcost/edge_length.go:345— placementcost.evaluateNodeEdgeLength has cyclomatic complexity 268 (threshold 15). Of this number, 189 points are the body's own statements and 79 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.
packing.packGuarded (cyclomatic 250) d2layouts/d2talalayout/internal/packing/binpack.go:65— packing.packGuarded has cyclomatic complexity 250 (threshold 15). Of this number, 237 points are the body's own statements and 13 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.
ovgEdgeRouter.search (cyclomatic 230) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:558— ovgEdgeRouter.search has cyclomatic complexity 230 (threshold 15). Of this number, 216 points are the body's own statements and 14 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.
layoutgraph.validateEngineGraph (cyclomatic 220) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:510— layoutgraph.validateEngineGraph has cyclomatic complexity 220 (threshold 15). Of this number, 176 points are the body's own statements and 44 belong to 11 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.
d2oracle._set (cyclomatic 182) d2oracle/edit.go:327— d2oracle._set has cyclomatic complexity 182 (threshold 15). Of this number, 176 points are the body's own statements and 6 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.
placement.Dejitter (cyclomatic 137) d2layouts/d2talalayout/internal/placement/dejitter.go:16— placement.Dejitter has cyclomatic complexity 137 (threshold 15). Of this number, 124 points are the body's own statements and 13 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.
d2oracle.move (cyclomatic 121) d2oracle/edit.go:1765— d2oracle.move has cyclomatic complexity 121 (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.
Ruler.measureMarkdownNode (cyclomatic 121) lib/textmeasure/markdown.go:330— Ruler.measureMarkdownNode has cyclomatic complexity 121 (threshold 15). Of this number, 117 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.
graphjson.deserializeGraphContext (cyclomatic 114) REDACTED:1035— graphjson.deserializeGraphContext has cyclomatic complexity 114 (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.
d2talalayout.translateGraph (cyclomatic 112) d2layouts/d2talalayout/adapter.go:116— d2talalayout.translateGraph has cyclomatic complexity 112 (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.
routing.balanceRegularEdgesGuarded (cyclomatic 106) d2layouts/d2talalayout/internal/routing/postprocess.go:70— routing.balanceRegularEdgesGuarded has cyclomatic complexity 106 (threshold 15). Of this number, 90 points are the body's own statements and 16 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.
d2dagrelayout.fitPadding (cyclomatic 103) d2layouts/d2dagrelayout/layout.go:1385— d2dagrelayout.fitPadding 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.
layoutgraph.validateCombineNodeTopology (cyclomatic 103) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:129— layoutgraph.validateCombineNodeTopology has cyclomatic complexity 103 (threshold 15). Of this number, 70 points are the body's own statements and 33 belong to 9 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.
d2cli.Run (cyclomatic 102) d2cli/main.go:62— d2cli.Run has cyclomatic complexity 102 (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.
d2dagrelayout.shiftReachableDownIndexed (cyclomatic 102) d2layouts/d2dagrelayout/layout.go:810— d2dagrelayout.shiftReachableDownIndexed has cyclomatic complexity 102 (threshold 15). Of this number, 26 points are the body's own statements and 76 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.
d2svg.drawShape (cyclomatic 102) d2renderers/d2svg/d2svg.go:1688— d2svg.drawShape has cyclomatic complexity 102 (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.
placement.reduceGapToNeighbors (cyclomatic 101) d2layouts/d2talalayout/internal/placement/gapreduction.go:273— placement.reduceGapToNeighbors has cyclomatic complexity 101 (threshold 15). Of this number, 84 points are the body's own statements and 17 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.
d2isometricimg.classicInkSegments (cyclomatic 101) d2renderers/d2isometric/d2isometricimg/native_edges.go:102— d2isometricimg.classicInkSegments has cyclomatic complexity 101 (threshold 15). Of this number, 74 points are the body's own statements and 27 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.
grouping.AddClusters (cyclomatic 100) REDACTED:167— grouping.AddClusters has cyclomatic complexity 100 (threshold 15). Of this number, 67 points are the body's own statements and 33 belong to 5 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.
d2elklayout.Layout (cyclomatic 93) d2layouts/d2elklayout/layout.go:257— d2elklayout.Layout has cyclomatic complexity 93 (threshold 15). Of this number, 70 points are the body's own statements and 23 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.
grouping.JoinDistancedClusters (cyclomatic 92) d2layouts/d2talalayout/internal/grouping/join.go:142— grouping.JoinDistancedClusters has cyclomatic complexity 92 (threshold 15). Of this number, 36 points are the body's own statements and 56 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.
d2svg.renderValidated (cyclomatic 89) d2renderers/d2svg/d2svg.go:2896— d2svg.renderValidated has cyclomatic complexity 89 (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.
Map.ensureField (cyclomatic 87) REDACTED:1216— Map.ensureField has cyclomatic complexity 87 (threshold 15). Of this number, 68 points are the body's own statements and 19 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.
routing.routeLineChecked (cyclomatic 87) d2layouts/d2talalayout/internal/routing/coordinator.go:844— routing.routeLineChecked has cyclomatic complexity 87 (threshold 15). Of this number, 84 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.
d2cli.compile (cyclomatic 86) d2cli/main.go:452— d2cli.compile 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.
labeling.place (cyclomatic 86) d2layouts/d2talalayout/internal/labeling/placement.go:28— labeling.place has cyclomatic complexity 86 (threshold 15). Of this number, 84 points are the body's own statements and 2 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.
layoutgraph.collectRuntimeObjectsContext (cyclomatic 85) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:362— layoutgraph.collectRuntimeObjectsContext has cyclomatic complexity 85 (threshold 15). Of this number, 45 points are the body's own statements and 40 belong to 9 function literals inside it that branch. 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.
builder.resolveFontFallbacks (cyclomatic 85) d2renderers/d2scenebuild/font_fallback.go:131— builder.resolveFontFallbacks has cyclomatic complexity 85 (threshold 15). Of this number, 83 points are the body's own statements and 2 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.
placement.equidistanceNodeGuarded (cyclomatic 81) d2layouts/d2talalayout/internal/placement/equidistance.go:103— placement.equidistanceNodeGuarded has cyclomatic complexity 81 (threshold 15). Of this number, 73 points are the body's own statements and 8 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.
compiler.compileReserved (cyclomatic 78) d2compiler/compile.go:863— compiler.compileReserved has cyclomatic complexity 78 (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.
placement.swapOptimize (cyclomatic 76) d2layouts/d2talalayout/internal/placement/swap.go:60— placement.swapOptimize has cyclomatic complexity 76 (threshold 15). Of this number, 72 points are the body's own statements and 4 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.
placementcost.nodeSymmetry (cyclomatic 76) d2layouts/d2talalayout/internal/placementcost/symmetry.go:94— placementcost.nodeSymmetry 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.
ovgEdgeRouter.findSShapedRoute (cyclomatic 76) d2layouts/d2talalayout/internal/routing/slingshot.go:891— ovgEdgeRouter.findSShapedRoute has cyclomatic complexity 76 (threshold 15). Of this number, 73 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.
d2isometricimg.svgVisibleFacesWithLimits (cyclomatic 75) REDACTED:343— d2isometricimg.svgVisibleFacesWithLimits has cyclomatic complexity 75 (threshold 15). Of this number, 60 points are the body's own statements and 15 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.
ShapingWorkspace.ShapeTextTransient (cyclomatic 75) d2renderers/internal/fontface/shaping.go:111— ShapingWorkspace.ShapeTextTransient has cyclomatic complexity 75 (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.
packing.CombineSubgraphs (cyclomatic 74) d2layouts/d2talalayout/internal/packing/combine.go:92— packing.CombineSubgraphs has cyclomatic complexity 74 (threshold 15). Of this number, 55 points are the body's own statements and 19 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.
graphjson.validateSerializedGraphForDeserialization (cyclomatic 73) d2layouts/d2talalayout/internal/graphjson/preflight.go:25— graphjson.validateSerializedGraphForDeserialization has cyclomatic complexity 73 (threshold 15). Of this number, 55 points are the body's own statements and 18 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.
routing.buildChannelProblem (cyclomatic 73) d2layouts/d2talalayout/internal/routing/nudge_channels.go:200— routing.buildChannelProblem has cyclomatic complexity 73 (threshold 15). Of this number, 71 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.
d2isometricimg.nativeResolveLaneRoutes (cyclomatic 73) d2renderers/d2isometric/d2isometricimg/route_lanes.go:63— d2isometricimg.nativeResolveLaneRoutes has cyclomatic complexity 73 (threshold 15). Of this number, 67 points are the body's own statements and 6 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.
d2isometric.BuildScene (cyclomatic 73) d2renderers/d2isometric/scene.go:129— d2isometric.BuildScene has cyclomatic complexity 73 (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.
Style.Apply (cyclomatic 72) d2graph/d2graph.go:313— Style.Apply has cyclomatic complexity 72 (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.
preflight.text (cyclomatic 70) d2renderers/d2raster/text.go:183— preflight.text has cyclomatic complexity 70 (threshold 15). Of this number, 67 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.
rasterimage.inspectPNG (cyclomatic 70) internal/rasterimage/firstframe.go:339— rasterimage.inspectPNG has cyclomatic complexity 70 (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.
compiler.resolveSubstitutions (cyclomatic 69) REDACTED:415— compiler.resolveSubstitutions has cyclomatic complexity 69 (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.
textPainter.texture (cyclomatic 69) d2renderers/d2isometric/d2isometricimg/text.go:145— textPainter.texture has cyclomatic complexity 69 (threshold 15). Of this number, 59 points are the body's own statements and 10 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.
svgImporter.computeStyle (cyclomatic 69) d2renderers/d2svgimport/style.go:266— svgImporter.computeStyle has cyclomatic complexity 69 (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.
d2wasm.Render (cyclomatic 68) d2js/d2wasm/functions.go:351— d2wasm.Render has cyclomatic complexity 68 (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.
graphjson.Serialize (cyclomatic 67) REDACTED:262— graphjson.Serialize has cyclomatic complexity 67 (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.
d2dagrelayout.Layout (cyclomatic 66) d2layouts/d2dagrelayout/layout.go:53— d2dagrelayout.Layout has cyclomatic complexity 66 (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.
packing.binPackCanUseRoutedContainerBox (cyclomatic 66) d2layouts/d2talalayout/internal/packing/routed_container.go:45— packing.binPackCanUseRoutedContainerBox has cyclomatic complexity 66 (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.
ovgEdgeRouter.findLShapedRoute (cyclomatic 66) d2layouts/d2talalayout/internal/routing/slingshot.go:666— ovgEdgeRouter.findLShapedRoute has cyclomatic complexity 66 (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.
labeling.findBestEdgeLabelPosition (cyclomatic 65) d2layouts/d2talalayout/internal/labeling/placement.go:687— labeling.findBestEdgeLabelPosition has cyclomatic complexity 65 (threshold 15). Of this number, 45 points are the body's own statements and 20 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.
Transaction.buildPostStateOverlapCandidates (cyclomatic 65) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:824— Transaction.buildPostStateOverlapCandidates has cyclomatic complexity 65 (threshold 15). Of this number, 60 points are the body's own statements and 5 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.
Graph.SetDimensions (cyclomatic 64) d2graph/d2graph.go:1515— Graph.SetDimensions has cyclomatic complexity 64 (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.
compiler._compileField (cyclomatic 63) REDACTED:1704— compiler._compileField has cyclomatic complexity 63 (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.
placement.transpose (cyclomatic 63) d2layouts/d2talalayout/internal/placement/transpose.go:35— placement.transpose has cyclomatic complexity 63 (threshold 15). Of this number, 53 points are the body's own statements and 10 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.
builder.buildDocument (cyclomatic 63) d2renderers/d2scenebuild/build.go:542— builder.buildDocument has cyclomatic complexity 63 (threshold 15). Of this number, 58 points are the body's own statements and 5 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.
routing.tunnelRangesBetweenChecked (cyclomatic 62) d2layouts/d2talalayout/internal/routing/tunnel.go:93— routing.tunnelRangesBetweenChecked has cyclomatic complexity 62 (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.
placement.optimizeClusterWithRollback (cyclomatic 61) d2layouts/d2talalayout/internal/placement/cluster_optimization.go:148— placement.optimizeClusterWithRollback has cyclomatic complexity 61 (threshold 15). Of this number, 46 points are the body's own statements and 15 belong to 5 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.
routing.fixClusterEdgeBranchingGuarded (cyclomatic 61) d2layouts/d2talalayout/internal/routing/postprocess.go:472— routing.fixClusterEdgeBranchingGuarded 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.
d2svg.collectFontCorporaAndClasses (cyclomatic 61) d2renderers/d2svg/font_corpus.go:79— d2svg.collectFontCorporaAndClasses has cyclomatic complexity 61 (threshold 15). Of this number, 55 points are the body's own statements and 6 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.
svgImporter.parse (cyclomatic 61) d2renderers/d2svgimport/import.go:393— svgImporter.parse 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.
placement.optimizerAdjacents (cyclomatic 60) d2layouts/d2talalayout/internal/placement/optimization_guard.go:176— placement.optimizerAdjacents has cyclomatic complexity 60 (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.
quality.scoreExistingLabelPlacements (cyclomatic 60) d2layouts/d2talalayout/internal/quality/labels.go:16— quality.scoreExistingLabelPlacements has cyclomatic complexity 60 (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.
d2isometricimg.hierarchyBoardHeaderPlacement (cyclomatic 60) d2renderers/d2isometric/d2isometricimg/hierarchy_headers.go:25— d2isometricimg.hierarchyBoardHeaderPlacement has cyclomatic complexity 60 (threshold 15). Of this number, 50 points are the body's own statements and 10 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.
graphjson.newEdgeSerializationIDs (cyclomatic 59) REDACTED:50— graphjson.newEdgeSerializationIDs has cyclomatic complexity 59 (threshold 15). Of this number, 51 points are the body's own statements and 8 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.
meshBuilder.edges (cyclomatic 59) d2renderers/d2isometric/d2isometricimg/geometry_routes.go:332— meshBuilder.edges has cyclomatic complexity 59 (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.
builder.preflightConnection (cyclomatic 59) d2renderers/d2scenebuild/build.go:404— builder.preflightConnection has cyclomatic complexity 59 (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.
compiler._compileEdges (cyclomatic 58) REDACTED:2088— compiler._compileEdges has cyclomatic complexity 58 (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.
Route.isOpposingColinear (cyclomatic 58) d2layouts/d2talalayout/internal/routing/route.go:87— Route.isOpposingColinear has cyclomatic complexity 58 (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.
compiler.ampersandFilter (cyclomatic 57) REDACTED:1364— compiler.ampersandFilter 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.
d2talalayout.validateLayoutResultMetadata (cyclomatic 57) d2layouts/d2talalayout/result_validate.go:129— d2talalayout.validateLayoutResultMetadata 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.
hierarchy.newRankProblem (cyclomatic 57) d2layouts/d2talalayout/internal/hierarchy/rank_graph.go:13— hierarchy.newRankProblem has cyclomatic complexity 57 (threshold 15). Of this number, 52 points are the body's own statements and 5 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.
placement.orientSourceInterior (cyclomatic 57) d2layouts/d2talalayout/internal/placement/container_orientation.go:37— placement.orientSourceInterior has cyclomatic complexity 57 (threshold 15). Of this number, 41 points are the body's own statements and 16 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.
routing.RouteGraphWithWorkLimit (cyclomatic 57) d2layouts/d2talalayout/internal/routing/graph_stage.go:44— routing.RouteGraphWithWorkLimit has cyclomatic complexity 57 (threshold 15). Most of this is not in the body itself: 15 of the 57 points are its own statements and the rest belongs to one function literal inside it that branches (line 101). 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.
trees.extractTreesInContainer (cyclomatic 57) d2layouts/d2talalayout/internal/trees/layout.go:14— trees.extractTreesInContainer 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.
d2isometricimg.nativeResolveBridgeRoutes (cyclomatic 57) d2renderers/d2isometric/d2isometricimg/route_bridges.go:60— d2isometricimg.nativeResolveBridgeRoutes has cyclomatic complexity 57 (threshold 15). Of this number, 53 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.
d2svg.drawConnection (cyclomatic 57) d2renderers/d2svg/d2svg.go:1079— d2svg.drawConnection 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.
builder.shapeTextRuns (cyclomatic 56) d2renderers/d2scenebuild/font_fallback.go:432— builder.shapeTextRuns 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.
Transaction.Commit (cyclomatic 54) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1166— Transaction.Commit has cyclomatic complexity 54 (threshold 15). Of this number, 52 points are the body's own statements and 2 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.
d2isometricimg.newNativeSceneWithOptions (cyclomatic 54) d2renderers/d2isometric/d2isometricimg/geometry.go:431— d2isometricimg.newNativeSceneWithOptions 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.
d2isometricimg.nativeSceneSVG (cyclomatic 54) d2renderers/d2isometric/d2isometricimg/svg.go:237— d2isometricimg.nativeSceneSVG has cyclomatic complexity 54 (threshold 15). Of this number, 52 points are the body's own statements and 2 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.
d2layouts.LayoutNested (cyclomatic 53) d2layouts/d2layouts.go:78— d2layouts.LayoutNested has cyclomatic complexity 53 (threshold 15). Of this number, 52 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.
preflight.node (cyclomatic 53) d2renderers/d2raster/raster.go:977— preflight.node has cyclomatic complexity 53 (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.
d2dagrelayout.adjustRankSpacing (cyclomatic 52) d2layouts/d2dagrelayout/layout.go:1123— d2dagrelayout.adjustRankSpacing 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.
OVG.halfwayPoints (cyclomatic 52) REDACTED:561— OVG.halfwayPoints 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.
Rasterizer.DrawRGBA (cyclomatic 52) REDACTED:491— Rasterizer.DrawRGBA has cyclomatic complexity 52 (threshold 15). Most of this is not in the body itself: 12 of the 52 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 507, 613, 576, …). 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.
d2raster.planNodeResources (cyclomatic 51) d2renderers/d2raster/effects.go:322— d2raster.planNodeResources 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.
pathParser.parseGroup (cyclomatic 51) d2renderers/d2svgimport/path.go:131— pathParser.parseGroup has cyclomatic complexity 51 (threshold 15). Of this number, 50 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.
ThemableElement.Render (cyclomatic 51) d2themes/element.go:138— ThemableElement.Render has cyclomatic complexity 51 (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.
Node.deltaToGuarded (cyclomatic 50) d2layouts/d2talalayout/internal/layoutgraph/node.go:788— Node.deltaToGuarded 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.
quality.measureLabels (cyclomatic 50) d2layouts/d2talalayout/internal/quality/inspection_labels.go:19— quality.measureLabels has cyclomatic complexity 50 (threshold 15). Of this number, 48 points are the body's own statements and 2 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.
grouping.AddSequences (cyclomatic 49) REDACTED:206— grouping.AddSequences has cyclomatic complexity 49 (threshold 15). Of this number, 48 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.
placementcost.prepareNodeEdgeLength (cyclomatic 49) d2layouts/d2talalayout/internal/placementcost/edge_length.go:142— placementcost.prepareNodeEdgeLength has cyclomatic complexity 49 (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.
proximity.assignNearsWithWorkLimit (cyclomatic 49) d2layouts/d2talalayout/internal/proximity/nears.go:18— proximity.assignNearsWithWorkLimit has cyclomatic complexity 49 (threshold 15). Of this number, 37 points are the body's own statements and 12 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.
hierarchy.PlaceCompound (cyclomatic 48) REDACTED:39— hierarchy.PlaceCompound has cyclomatic complexity 48 (threshold 15). Of this number, 47 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.
Nodes.clustersWithWorkGuard (cyclomatic 48) d2layouts/d2talalayout/internal/layoutgraph/node.go:300— Nodes.clustersWithWorkGuard has cyclomatic complexity 48 (threshold 15). Of this number, 32 points are the body's own statements and 16 belong 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.
ovgEdgeSet.intersectsWithChecked (cyclomatic 48) d2layouts/d2talalayout/internal/routing/ovg_edge_set.go:128— ovgEdgeSet.intersectsWithChecked has cyclomatic complexity 48 (threshold 15). Of this number, 47 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.
trees.placeAtOrientationGuarded (cyclomatic 48) d2layouts/d2talalayout/internal/trees/layout.go:399— trees.placeAtOrientationGuarded has cyclomatic complexity 48 (threshold 15). Of this number, 36 points are the body's own statements and 12 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.
d2isometricimg.nativeLaneJoinCorners (cyclomatic 48) d2renderers/d2isometric/d2isometricimg/route_lanes.go:435— d2isometricimg.nativeLaneJoinCorners has cyclomatic complexity 48 (threshold 15). Of this number, 43 points are the body's own statements and 5 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.
svgImporter.declarationsFor (cyclomatic 48) d2renderers/d2svgimport/style.go:63— svgImporter.declarationsFor has cyclomatic complexity 48 (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.
d2wasm.Compile (cyclomatic 48) d2js/d2wasm/functions.go:196— d2wasm.Compile has cyclomatic complexity 48 (threshold 15). Of this number, 44 points are the body's own statements and 4 belong to 2 function literals 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.
d2graph.compareSerializedObject (cyclomatic 47) REDACTED:231— d2graph.compareSerializedObject has cyclomatic complexity 47 (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.
placement.placeNodes (cyclomatic 47) REDACTED:21— placement.placeNodes has cyclomatic complexity 47 (threshold 15). Of this number, 44 points are the body's own statements and 3 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.
placement.newSizedOptimizer (cyclomatic 47) REDACTED:106— placement.newSizedOptimizer 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.
GraphState.updateContext (cyclomatic 46) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:167— GraphState.updateContext has cyclomatic complexity 46 (threshold 15). Of this number, 36 points are the body's own statements and 10 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.
routing.reorderDuplicatesInEdgesGuarded (cyclomatic 46) d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:323— routing.reorderDuplicatesInEdgesGuarded has cyclomatic complexity 46 (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.
d2isometricimg.svgOrderPaintUnitsWithLimits (cyclomatic 46) d2renderers/d2isometric/d2isometricimg/svg_order.go:29— d2isometricimg.svgOrderPaintUnitsWithLimits has cyclomatic complexity 46 (threshold 15). Of this number, 36 points are the body's own statements and 10 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.
d2raster.prepareWithSessionBands (cyclomatic 46) d2renderers/d2raster/raster.go:615— d2raster.prepareWithSessionBands has cyclomatic complexity 46 (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.
prepare.main (cyclomatic 46) ci/release/prepare.py:27— prepare.main has cyclomatic complexity 46 (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.
main.verifyArchive (cyclomatic 45) ci/release/releasetool/main.go:669— main.verifyArchive has cyclomatic complexity 45 (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.
Edge.TraceToShape (cyclomatic 45) d2graph/layout.go:414— Edge.TraceToShape has cyclomatic complexity 45 (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.
Map.createEdge (cyclomatic 45) REDACTED:1717— Map.createEdge has cyclomatic complexity 45 (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.
sizedOptimizer.optimizeGuarded (cyclomatic 45) REDACTED:279— sizedOptimizer.optimizeGuarded has cyclomatic complexity 45 (threshold 15). Of this number, 41 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.
routing.balanceReversalRemovesCrossings (cyclomatic 45) REDACTED:17— routing.balanceReversalRemovesCrossings has cyclomatic complexity 45 (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.
routing.reorderDuplicatesInEdges (cyclomatic 45) d2layouts/d2talalayout/internal/routing/coordinator.go:1633— routing.reorderDuplicatesInEdges has cyclomatic complexity 45 (threshold 15). Of this number, 42 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.
routing.simplifyPoints (cyclomatic 45) d2layouts/d2talalayout/internal/routing/edge_simplify.go:37— routing.simplifyPoints has cyclomatic complexity 45 (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.
routing.routeEdgesWithBudgets (cyclomatic 45) d2layouts/d2talalayout/internal/routing/standalone_router.go:27— routing.routeEdgesWithBudgets has cyclomatic complexity 45 (threshold 15). Of this number, 26 points are the body's own statements and 19 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.
d2raster.maskRenderBounds (cyclomatic 45) d2renderers/d2raster/mask_regions.go:21— d2raster.maskRenderBounds has cyclomatic complexity 45 (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.
routing.channelProposalSafe (cyclomatic 44) d2layouts/d2talalayout/internal/routing/nudge_channels.go:602— routing.channelProposalSafe 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.
d2oracle.ReconnectEdge (cyclomatic 44) d2oracle/edit.go:124— d2oracle.ReconnectEdge 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.
parser.parseUnquotedString (cyclomatic 44) d2parser/parse.go:1129— parser.parseUnquotedString has cyclomatic complexity 44 (threshold 15). Of this number, 39 points are the body's own statements and 5 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.
main.writeArchive (cyclomatic 43) ci/release/releasetool/main.go:158— main.writeArchive has cyclomatic complexity 43 (threshold 15). Of this number, 34 points are the body's own statements and 9 belong to 2 function literals 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.
placement.initializeByGraphDistance (cyclomatic 43) d2layouts/d2talalayout/internal/placement/stress_initialize.go:16— placement.initializeByGraphDistance has cyclomatic complexity 43 (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.
sizedOptimizer.fillPlacementPointsGuarded (cyclomatic 43) REDACTED:715— sizedOptimizer.fillPlacementPointsGuarded has cyclomatic complexity 43 (threshold 15). Of this number, 36 points are the body's own statements and 7 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.
proximity.AssignHerds (cyclomatic 43) d2layouts/d2talalayout/internal/proximity/herding.go:16— proximity.AssignHerds has cyclomatic complexity 43 (threshold 15). Of this number, 41 points are the body's own statements and 2 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.
routing.shortcutRoutesGuarded (cyclomatic 43) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:69— routing.shortcutRoutesGuarded has cyclomatic complexity 43 (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.
SystemFallbackResolver.ResolveFallbacks (cyclomatic 43) d2renderers/d2fonts/fallback.go:121— SystemFallbackResolver.ResolveFallbacks has cyclomatic complexity 43 (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.
svgImporter.compileGeometry (cyclomatic 43) d2renderers/d2svgimport/geometry.go:33— svgImporter.compileGeometry has cyclomatic complexity 43 (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.
grouping.ResetClusters (cyclomatic 42) d2layouts/d2talalayout/internal/grouping/lifecycle.go:7— grouping.ResetClusters 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.
hierarchy.findCycleEdges (cyclomatic 42) d2layouts/d2talalayout/internal/hierarchy/discovery.go:579— hierarchy.findCycleEdges has cyclomatic complexity 42 (threshold 15). Of this number, 33 points are the body's own statements and 9 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.
labeling.placeNewEdges (cyclomatic 42) d2layouts/d2talalayout/internal/labeling/placement.go:462— labeling.placeNewEdges has cyclomatic complexity 42 (threshold 15). Of this number, 40 points are the body's own statements and 2 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.
packing.allEdgesHaveCompleteRoutesGuarded (cyclomatic 42) d2layouts/d2talalayout/internal/packing/guard.go:471— packing.allEdgesHaveCompleteRoutesGuarded 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.
d2oracle.DeleteIDDeltas (cyclomatic 42) d2oracle/edit.go:2972— d2oracle.DeleteIDDeltas has cyclomatic complexity 42 (threshold 15). Of this number, 34 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.
ASCIIartist.Render (cyclomatic 42) d2renderers/d2ascii/d2ascii.go:215— ASCIIartist.Render has cyclomatic complexity 42 (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.
svgImporter.instantiate (cyclomatic 42) d2renderers/d2svgimport/compile.go:386— svgImporter.instantiate 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.
Key.Equals (cyclomatic 41) d2ast/d2ast.go:895— Key.Equals has cyclomatic complexity 41 (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.
d2cli.renderIsometricImages (cyclomatic 41) d2cli/isometric_image.go:120— d2cli.renderIsometricImages has cyclomatic complexity 41 (threshold 15). Of this number, 31 points are the body's own statements and 10 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.
compiler.compileField (cyclomatic 41) d2compiler/compile.go:651— compiler.compileField has cyclomatic complexity 41 (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.
d2exporter.toConnection (cyclomatic 41) d2exporter/export.go:338— d2exporter.toConnection has cyclomatic complexity 41 (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.
compiler.compileMap (cyclomatic 41) REDACTED:971— compiler.compileMap has cyclomatic complexity 41 (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.
d2elklayout.deleteBends (cyclomatic 41) d2layouts/d2elklayout/layout.go:770— d2elklayout.deleteBends has cyclomatic complexity 41 (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.
d2grid.Layout (cyclomatic 41) d2layouts/d2grid/layout.go:23— d2grid.Layout has cyclomatic complexity 41 (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.
Node.reachableNodesGuarded (cyclomatic 41) d2layouts/d2talalayout/internal/layoutgraph/node.go:1670— Node.reachableNodesGuarded has cyclomatic complexity 41 (threshold 15). Of this number, 38 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.
placement.shiftSubgraphs (cyclomatic 41) d2layouts/d2talalayout/internal/placement/compaction.go:145— placement.shiftSubgraphs has cyclomatic complexity 41 (threshold 15). Of this number, 38 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.
sizedOptimizer.bestSwapCandidateGuarded (cyclomatic 41) REDACTED:1027— sizedOptimizer.bestSwapCandidateGuarded has cyclomatic complexity 41 (threshold 15). Of this number, 28 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.
routing.edgeCanOverlapEdges (cyclomatic 41) d2layouts/d2talalayout/internal/routing/coordinator.go:1208— routing.edgeCanOverlapEdges has cyclomatic complexity 41 (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.
routing.overshot (cyclomatic 41) d2layouts/d2talalayout/internal/routing/slingshot.go:219— routing.overshot has cyclomatic complexity 41 (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.
OVG.connectNodesOnSameLine (cyclomatic 41) REDACTED:1223— OVG.connectNodesOnSameLine has cyclomatic complexity 41 (threshold 15). Of this number, 37 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.
d2isometricimg.rasterValidate (cyclomatic 41) d2renderers/d2isometric/d2isometricimg/raster.go:475— d2isometricimg.rasterValidate has cyclomatic complexity 41 (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.
builder.buildShape (cyclomatic 41) d2renderers/d2scenebuild/build.go:828— builder.buildShape has cyclomatic complexity 41 (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.
svgImporter.validateXMLDeclaration (cyclomatic 41) d2renderers/d2svgimport/import.go:604— svgImporter.validateXMLDeclaration has cyclomatic complexity 41 (threshold 15). Of this number, 37 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.
imageasset.validateSVGWithLimits (cyclomatic 41) lib/imageasset/probe.go:457— imageasset.validateSVGWithLimits has cyclomatic complexity 41 (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.
d2elklayout.ConvertGraph (cyclomatic 40) d2layouts/d2elklayout/wasm.go:23— d2elklayout.ConvertGraph has cyclomatic complexity 40 (threshold 15). Of this number, 19 points are the body's own statements and 21 belong to 2 function literals inside it that branch. 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.
Graph.abductEdges (cyclomatic 40) d2layouts/d2talalayout/internal/layoutgraph/layout.go:163— Graph.abductEdges has cyclomatic complexity 40 (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.
placement.captureOptimizerMutationStateInto (cyclomatic 40) d2layouts/d2talalayout/internal/placement/optimization_guard.go:814— placement.captureOptimizerMutationStateInto 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, 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.
d2lsp.getKeywordContext (cyclomatic 40) d2lsp/completion.go:120— d2lsp.getKeywordContext has cyclomatic complexity 40 (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.
d2oracle.Delete (cyclomatic 40) d2oracle/edit.go:937— d2oracle.Delete has cyclomatic complexity 40 (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.
d2oracle.MoveIDDeltas (cyclomatic 40) d2oracle/edit.go:2778— d2oracle.MoveIDDeltas has cyclomatic complexity 40 (threshold 15). Of this number, 28 points are the body's own statements and 12 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.
d2isometricimg.richLabelDocumentWithResources (cyclomatic 40) d2renderers/d2isometric/d2isometricimg/rich_labels.go:222— d2isometricimg.richLabelDocumentWithResources has cyclomatic complexity 40 (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.
Raster.drawPrepared (cyclomatic 40) d2renderers/d2isometric/d2isometricimg/raster.go:928— Raster.drawPrepared has cyclomatic complexity 40 (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.
d2raster.compositeLayerOver (cyclomatic 40) d2renderers/d2raster/effects.go:1760— d2raster.compositeLayerOver has cyclomatic complexity 40 (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.
d2raster.makeStrokeRuns (cyclomatic 40) d2renderers/d2raster/geometry.go:529— d2raster.makeStrokeRuns has cyclomatic complexity 40 (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.
svgImporter.compileElement (cyclomatic 40) d2renderers/d2svgimport/compile.go:242— svgImporter.compileElement has cyclomatic complexity 40 (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.
d2talalayout.validateD2Edges (cyclomatic 39) d2layouts/d2talalayout/adapter_validate.go:383— d2talalayout.validateD2Edges 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.
placement.placeNodesOrthogonally (cyclomatic 39) REDACTED:246— placement.placeNodesOrthogonally 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.
d2isometricimg.rasterBuildShadow (cyclomatic 39) d2renderers/d2isometric/d2isometricimg/raster.go:691— d2isometricimg.rasterBuildShadow 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.
meshBuilder.sequenceEdge (cyclomatic 39) d2renderers/d2isometric/d2isometricimg/sequence_routes.go:175— meshBuilder.sequenceEdge 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.
Object.GetFill (cyclomatic 38) d2graph/d2graph.go:510— Object.GetFill has cyclomatic complexity 38 (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.
ovgEdgeRouter.addRoute (cyclomatic 38) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1659— ovgEdgeRouter.addRoute has cyclomatic complexity 38 (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.
BundledFallbackResolver.resolve (cyclomatic 38) d2renderers/d2fonts/bundled_fallback.go:94— BundledFallbackResolver.resolve has cyclomatic complexity 38 (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.
d2isometric.classifySequence (cyclomatic 38) d2renderers/d2isometric/sequence.go:15— d2isometric.classifySequence has cyclomatic complexity 38 (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.
preflight.positionGlyphs (cyclomatic 38) d2renderers/d2raster/text.go:456— preflight.positionGlyphs has cyclomatic complexity 38 (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.
d2exporter.applyTheme (cyclomatic 37) d2exporter/export.go:80— d2exporter.applyTheme 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.
layoutgraph.ValidatePositionedGraphSelection (cyclomatic 37) d2layouts/d2talalayout/internal/layoutgraph/positioned_validation.go:16— layoutgraph.ValidatePositionedGraphSelection has cyclomatic complexity 37 (threshold 15). Of this number, 21 points are the body's own statements and 16 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.
sizedOptimizer.moveNodeToBestGuarded (cyclomatic 37) REDACTED:887— sizedOptimizer.moveNodeToBestGuarded has cyclomatic complexity 37 (threshold 15). Of this number, 36 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.
routing.shortcutContactsPreserved (cyclomatic 37) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:300— routing.shortcutContactsPreserved 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.
d2oracle.updateNear (cyclomatic 37) d2oracle/edit.go:2328— d2oracle.updateNear 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.
d2raster.flattenScenePath (cyclomatic 37) d2renderers/d2raster/geometry.go:60— d2raster.flattenScenePath has cyclomatic complexity 37 (threshold 15). Of this number, 29 points are the body's own statements and 8 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.
builder.measureLegend (cyclomatic 37) d2renderers/d2scenebuild/legend.go:147— builder.measureLegend has cyclomatic complexity 37 (threshold 15). Of this number, 32 points are the body's own statements and 5 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.
d2svgimport.inspectEmbeddedJPEG (cyclomatic 37) d2renderers/d2svgimport/image.go:377— d2svgimport.inspectEmbeddedJPEG 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.
Graph.splitSubgraphsWithOwnership (cyclomatic 36) d2layouts/d2talalayout/internal/layoutgraph/graph.go:674— Graph.splitSubgraphsWithOwnership has cyclomatic complexity 36 (threshold 15). Of this number, 26 points are the body's own statements and 10 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.
Node.ConnectedNodeSet (cyclomatic 36) d2layouts/d2talalayout/internal/layoutgraph/connected_set.go:25— Node.ConnectedNodeSet has cyclomatic complexity 36 (threshold 15). Of this number, 35 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
placement.alignAxes (cyclomatic 36) d2layouts/d2talalayout/internal/placement/alignment.go:26— placement.alignAxes has cyclomatic complexity 36 (threshold 15). Of this number, 35 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.
routing.validateRouteStageGeometry (cyclomatic 36) d2layouts/d2talalayout/internal/routing/route_stage_guard.go:278— routing.validateRouteStageGeometry has cyclomatic complexity 36 (threshold 15). Most of this is not in the body itself: 11 of the 36 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 312, 287, 282). 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.
Canvas.ToByteArray (cyclomatic 36) d2renderers/d2ascii/asciicanvas/asciicanvas.go:76— Canvas.ToByteArray 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.
d2isometricimg.RenderTimeline (cyclomatic 36) d2renderers/d2isometric/d2isometricimg/timeline.go:26— d2isometricimg.RenderTimeline 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.
d2raster.boxBlurAlphaPixelsGeneral (cyclomatic 36) d2renderers/d2raster/filter.go:838— d2raster.boxBlurAlphaPixelsGeneral 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.
d2raster.rgbaToNRGBAInPlaceBounds (cyclomatic 36) d2renderers/d2raster/raster.go:462— d2raster.rgbaToNRGBAInPlaceBounds 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.
builder.preflightShape (cyclomatic 36) d2renderers/d2scenebuild/build.go:324— builder.preflightShape 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.
svgImporter.validateFrozenMathJaxTextElement (cyclomatic 36) d2renderers/d2svgimport/mathjax_text.go:57— svgImporter.validateFrozenMathJaxTextElement has cyclomatic complexity 36 (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.
d2cli.loadFonts (cyclomatic 35) d2cli/main.go:1103— d2cli.loadFonts 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.
d2talalayout.validateD2Objects (cyclomatic 35) d2layouts/d2talalayout/adapter_validate.go:100— d2talalayout.validateD2Objects 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.
graphCloneState.copy (cyclomatic 35) REDACTED:86— graphCloneState.copy 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.
d2oracle.deleteReserved (cyclomatic 35) d2oracle/edit.go:1313— d2oracle.deleteReserved 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.
retainedVectorValidator.node (cyclomatic 35) d2renderers/d2raster/vector_validation.go:127— retainedVectorValidator.node 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.
pathParser.number (cyclomatic 35) d2renderers/d2svgimport/path.go:324— pathParser.number 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.
rasterimage.buildFramePNG (cyclomatic 35) internal/rasterimage/firstframe.go:524— rasterimage.buildFramePNG 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.
Key.D2OracleEquals (cyclomatic 34) d2ast/d2ast.go:813— Key.D2OracleEquals has cyclomatic complexity 34 (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.
rankSimplex.feasibleTree (cyclomatic 34) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:136— rankSimplex.feasibleTree has cyclomatic complexity 34 (threshold 15). Of this number, 26 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.
labeling.findSharedSegmentsChecked (cyclomatic 34) d2layouts/d2talalayout/internal/labeling/placement.go:1024— labeling.findSharedSegmentsChecked has cyclomatic complexity 34 (threshold 15). Of this number, 17 points are the body's own statements and 17 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.
routing.captureRouteMutations (cyclomatic 34) d2layouts/d2talalayout/internal/routing/route_stage_guard.go:147— routing.captureRouteMutations has cyclomatic complexity 34 (threshold 15). Of this number, 25 points are the body's own statements and 9 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.
trees.layoutTree (cyclomatic 34) d2layouts/d2talalayout/internal/trees/geometry.go:113— trees.layoutTree has cyclomatic complexity 34 (threshold 15). Of this number, 31 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.
d2oracle.renameConflictsToParent (cyclomatic 34) d2oracle/edit.go:1162— d2oracle.renameConflictsToParent has cyclomatic complexity 34 (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.
d2isometricimg.surfaceIconLayout (cyclomatic 34) d2renderers/d2isometric/d2isometricimg/surface_icons.go:306— d2isometricimg.surfaceIconLayout has cyclomatic complexity 34 (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.
nativeSurfaceSVGWriter.text (cyclomatic 34) d2renderers/d2isometric/d2isometricimg/vector_surface_text.go:49— nativeSurfaceSVGWriter.text has cyclomatic complexity 34 (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.
builder.arrowhead (cyclomatic 34) d2renderers/d2scenebuild/connection.go:430— builder.arrowhead has cyclomatic complexity 34 (threshold 15). Of this number, 32 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.
builder.compileLinkRegions (cyclomatic 34) d2renderers/d2scenebuild/metadata.go:16— builder.compileLinkRegions has cyclomatic complexity 34 (threshold 15). Of this number, 33 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.
markdownPainter.wrapInlineTokens (cyclomatic 34) lib/textmeasure/markdown_svg.go:983— markdownPainter.wrapInlineTokens has cyclomatic complexity 34 (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.
xgif.validatePalettedImage (cyclomatic 34) lib/xgif/xgif.go:1341— xgif.validatePalettedImage has cyclomatic complexity 34 (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.
d2cli.mapPagedLinks (cyclomatic 33) d2cli/paged.go:273— d2cli.mapPagedLinks has cyclomatic complexity 33 (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.
compiler.compileMap (cyclomatic 33) d2compiler/compile.go:453— compiler.compileMap 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.
grouping.buildClusterDiscoveryIndex (cyclomatic 33) d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:265— grouping.buildClusterDiscoveryIndex has cyclomatic complexity 33 (threshold 15). Of this number, 29 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.
Node.connectedNodes (cyclomatic 33) d2layouts/d2talalayout/internal/layoutgraph/node.go:1847— Node.connectedNodes has cyclomatic complexity 33 (threshold 15). Of this number, 32 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.
placement.moveNodeToBest (cyclomatic 33) d2layouts/d2talalayout/internal/placement/moves.go:16— placement.moveNodeToBest 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.
routing.applyChannelProblem (cyclomatic 33) d2layouts/d2talalayout/internal/routing/nudge_channels.go:441— routing.applyChannelProblem has cyclomatic complexity 33 (threshold 15). Of this number, 32 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.
ovgEdgeRouter.bestRoute (cyclomatic 33) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1490— ovgEdgeRouter.bestRoute 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.
d2oracle.deleteObject (cyclomatic 33) d2oracle/edit.go:1523— d2oracle.deleteObject has cyclomatic complexity 33 (threshold 15). Of this number, 32 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.
d2oracle.ReconnectEdgeIDDeltas (cyclomatic 33) d2oracle/edit.go:2500— d2oracle.ReconnectEdgeIDDeltas 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.
d2svg.arrowheadMarker (cyclomatic 33) d2renderers/d2svg/d2svg.go:531— d2svg.arrowheadMarker 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.
main.discoverTests (cyclomatic 33) e2etests/report/main.go:46— main.discoverTests has cyclomatic complexity 33 (threshold 15). Of this number, 17 points are the body's own statements and 16 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.
markdownSubstitutionMatcher.replaceBounded (cyclomatic 33) lib/textmeasure/substitutions.go:214— markdownSubstitutionMatcher.replaceBounded 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.
gridDiagram.layoutDynamic (cyclomatic 32) d2layouts/d2grid/layout.go:337— gridDiagram.layoutDynamic has cyclomatic complexity 32 (threshold 15). 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.
placement.adjacents (cyclomatic 32) d2layouts/d2talalayout/internal/placement/metrics.go:105— placement.adjacents 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.
placementcost.flowContinuityCost (cyclomatic 32) d2layouts/d2talalayout/internal/placementcost/flow_continuity.go:19— placementcost.flowContinuityCost 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.
d2isometricimg.newRaster (cyclomatic 32) d2renderers/d2isometric/d2isometricimg/raster.go:165— d2isometricimg.newRaster 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.
d2raster.boxBlurRGBAGeneral (cyclomatic 32) d2renderers/d2raster/filter.go:653— d2raster.boxBlurRGBAGeneral 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.
svgImporter.parseEmbeddedRasterDataURI (cyclomatic 32) d2renderers/d2svgimport/image.go:199— svgImporter.parseEmbeddedRasterDataURI 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.
d2cli.renderGIFWithSession (cyclomatic 31) d2cli/raster.go:555— d2cli.renderGIFWithSession has cyclomatic complexity 31 (threshold 15). Of this number, 26 points are the body's own statements and 5 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.
compiler.validateKey (cyclomatic 31) d2compiler/compile.go:1510— compiler.validateKey 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.
compiler.compileSubstitutionsWalk (cyclomatic 31) REDACTED:270— compiler.compileSubstitutionsWalk 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.
hierarchy.is1N1 (cyclomatic 31) d2layouts/d2talalayout/internal/hierarchy/discovery.go:367— hierarchy.is1N1 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.
placement.candidateMoves (cyclomatic 31) d2layouts/d2talalayout/internal/placement/compaction.go:577— placement.candidateMoves 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.
placement.PlaceChildrenOrder (cyclomatic 31) REDACTED:461— placement.PlaceChildrenOrder 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.
optimizerSpatialIndex.doesOverlap (cyclomatic 31) d2layouts/d2talalayout/internal/placement/optimizer_spatial_index.go:281— optimizerSpatialIndex.doesOverlap 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.
routing.finalizeSelectedRoutes (cyclomatic 31) d2layouts/d2talalayout/internal/routing/coordinator.go:205— routing.finalizeSelectedRoutes has cyclomatic complexity 31 (threshold 15). Of this number, 30 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.
routing.routeInSShape (cyclomatic 31) d2layouts/d2talalayout/internal/routing/coordinator.go:725— routing.routeInSShape has cyclomatic complexity 31 (threshold 15). Most of this is not in the body itself: 11 of the 31 points are its own statements and the rest belongs to one function literal inside it that branches (line 741). 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.
meshBuilder.arrowWithOpacity (cyclomatic 31) d2renderers/d2isometric/d2isometricimg/geometry_routes.go:171— meshBuilder.arrowWithOpacity has cyclomatic complexity 31 (threshold 15). Of this number, 24 points are the body's own statements and 7 belong to 4 function literals inside it that branch. 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.
meshBuilder.classicInkEdges (cyclomatic 31) d2renderers/d2isometric/d2isometricimg/native_edges.go:429— meshBuilder.classicInkEdges has cyclomatic complexity 31 (threshold 15). Of this number, 28 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.
meshBuilder.rootDecorations (cyclomatic 31) d2renderers/d2isometric/d2isometricimg/source_panels.go:128— meshBuilder.rootDecorations 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.
d2raster.compositeBlendLayerOpaquePrefix (cyclomatic 31) d2renderers/d2raster/effects.go:1516— d2raster.compositeBlendLayerOpaquePrefix 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.
Graph.Texts (cyclomatic 30) d2graph/d2graph.go:1710— Graph.Texts 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.
Map.getEdges (cyclomatic 30) REDACTED:1593— Map.getEdges 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.
d2layouts.extractSubgraphs (cyclomatic 30) d2layouts/d2layouts.go:456— d2layouts.extractSubgraphs has cyclomatic complexity 30 (threshold 15). Of this number, 25 points are the body's own statements and 5 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.
d2talalayout.validateTopology (cyclomatic 30) d2layouts/d2talalayout/result_validate.go:37— d2talalayout.validateTopology 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.
routing.reorderSelectedRoutes (cyclomatic 30) d2layouts/d2talalayout/internal/routing/coordinator.go:305— routing.reorderSelectedRoutes has cyclomatic complexity 30 (threshold 15). Of this number, 25 points are the body's own statements and 5 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.
routing.buildOVGFromGraphWithGuard (cyclomatic 30) REDACTED:130— routing.buildOVGFromGraphWithGuard 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.
routing.newOVGPortIndex (cyclomatic 30) d2layouts/d2talalayout/internal/routing/ovg_resource.go:690— routing.newOVGPortIndex 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.
routing.shortcutCandidateSafe (cyclomatic 30) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:227— routing.shortcutCandidateSafe 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.
meshBuilder.hierarchyBoard (cyclomatic 30) d2renderers/d2isometric/d2isometricimg/hierarchy_boards.go:296— meshBuilder.hierarchyBoard 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.
richLabelPainter.texture (cyclomatic 30) d2renderers/d2isometric/d2isometricimg/rich_labels.go:78— richLabelPainter.texture has cyclomatic complexity 30 (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.
d2sketch.ConnectionDrawable (cyclomatic 30) d2renderers/d2sketch/scene_connection.go:25— d2sketch.ConnectionDrawable 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.
svgImporter.validateNonRenderingTree (cyclomatic 30) d2renderers/d2svgimport/boilerplate.go:63— svgImporter.validateNonRenderingTree 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.
transformParser.number (cyclomatic 30) d2renderers/d2svgimport/transform.go:142— transformParser.number 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.
colrv1Builder.paint (cyclomatic 30) d2renderers/internal/fontface/colrv1.go:223— colrv1Builder.paint 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.
rasterimage.inspectWebP (cyclomatic 30) internal/rasterimage/firstframe.go:752— rasterimage.inspectWebP 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.
layoutgraph.segmentIntersectsBox (cyclomatic 29) d2layouts/d2talalayout/internal/layoutgraph/node.go:1408— layoutgraph.segmentIntersectsBox has cyclomatic complexity 29 (threshold 15). Of this number, 23 points are the body's own statements and 6 belong to 2 function literals inside it that branch. 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.
layoutgraph.buildTransactionOverlapsWithReferenceLimit (cyclomatic 29) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:509— layoutgraph.buildTransactionOverlapsWithReferenceLimit has cyclomatic complexity 29 (threshold 15). Of this number, 21 points are the body's own statements and 8 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.
placement.mirrorAxes (cyclomatic 29) d2layouts/d2talalayout/internal/placement/direct.go:167— placement.mirrorAxes has cyclomatic complexity 29 (threshold 15). Of this number, 15 points are the body's own statements and 14 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.
placement.optimizerMedian (cyclomatic 29) d2layouts/d2talalayout/internal/placement/optimization_guard.go:332— placement.optimizerMedian has cyclomatic complexity 29 (threshold 15). Of this number, 25 points are the body's own statements and 4 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.
placementcost.AxisScore (cyclomatic 29) d2layouts/d2talalayout/internal/placementcost/axis.go:11— placementcost.AxisScore 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.
proximity.GroupSheep (cyclomatic 29) d2layouts/d2talalayout/internal/proximity/herding.go:237— proximity.GroupSheep 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.
routing.sortEdges (cyclomatic 29) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:190— routing.sortEdges has cyclomatic complexity 29 (threshold 15). Most of this is not in the body itself: 4 of the 29 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 219, 277, 193, …). 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.
routing.isOnFlightPlan (cyclomatic 29) d2layouts/d2talalayout/internal/routing/slingshot.go:289— routing.isOnFlightPlan has cyclomatic complexity 29 (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.
routing.traceToShapeBorder (cyclomatic 29) d2layouts/d2talalayout/internal/routing/trace.go:27— routing.traceToShapeBorder has cyclomatic complexity 29 (threshold 15). Of this number, 27 points are the body's own statements and 2 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.
Route.canSwapEdgesGuarded (cyclomatic 29) d2layouts/d2talalayout/internal/routing/route.go:202— Route.canSwapEdgesGuarded 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.
d2lib.compileBoard (cyclomatic 29) d2lib/d2.go:184— d2lib.compileBoard 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.
routeCaptionPlacer.Place (cyclomatic 29) d2renderers/d2isometric/d2isometricimg/route_labels.go:58— routeCaptionPlacer.Place has cyclomatic complexity 29 (threshold 15). Of this number, 28 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.
d2raster.flattenGlyph (cyclomatic 29) d2renderers/d2raster/text.go:626— d2raster.flattenGlyph has cyclomatic complexity 29 (threshold 15). Of this number, 22 points are the body's own statements and 7 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.
builder.preflightLegend (cyclomatic 29) d2renderers/d2scenebuild/legend.go:47— builder.preflightLegend 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.
d2svg.wrapIsometricSVG (cyclomatic 29) d2renderers/d2svg/isometric.go:104— d2svg.wrapIsometricSVG has cyclomatic complexity 29 (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.
Diagram.BoundingBox (cyclomatic 29) d2target/d2target.go:450— Diagram.BoundingBox 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.
MarkdownLayout.SVG (cyclomatic 29) lib/textmeasure/markdown_svg.go:219— MarkdownLayout.SVG 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.
markdownPainter.markdownInlineLineHeight (cyclomatic 29) lib/textmeasure/markdown_svg.go:875— markdownPainter.markdownInlineLineHeight 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.
printer._map (cyclomatic 28) d2format/format.go:287— printer._map 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.
placement.initializeNodes (cyclomatic 28) d2layouts/d2talalayout/internal/placement/initialize.go:14— placement.initializeNodes has cyclomatic complexity 28 (threshold 15). Of this number, 19 points are the body's own statements and 9 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.
placement.BalanceSymmetry (cyclomatic 28) d2layouts/d2talalayout/internal/placement/symmetry.go:12— placement.BalanceSymmetry has cyclomatic complexity 28 (threshold 15). Of this number, 25 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.
d2fonts.probeFontFileCoverage (cyclomatic 28) d2renderers/d2fonts/fallback.go:483— d2fonts.probeFontFileCoverage 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.
d2isometricimg.nativeDocumentGlyphCoverage (cyclomatic 28) d2renderers/d2isometric/d2isometricimg/surface_fonts.go:83— d2isometricimg.nativeDocumentGlyphCoverage has cyclomatic complexity 28 (threshold 15). Most of this is not in the body itself: 5 of the 28 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 131, 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.
d2raster.multiplyLayerByRGBALuminance (cyclomatic 28) d2renderers/d2raster/effects.go:1117— d2raster.multiplyLayerByRGBALuminance 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.
d2raster.multiplyLayerByRGBAAlpha (cyclomatic 28) d2renderers/d2raster/effects.go:1237— d2raster.multiplyLayerByRGBAAlpha 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.
preflight.finishPrimitive (cyclomatic 28) d2renderers/d2raster/raster.go:1327— preflight.finishPrimitive 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.
d2svgimport.parseSVGNumber (cyclomatic 28) d2renderers/d2svgimport/style.go:648— d2svgimport.parseSVGNumber has cyclomatic complexity 28 (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.
d2target.validateRenderConnection (cyclomatic 28) d2target/render_validation.go:166— d2target.validateRenderConnection 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.
main.verifyStripped (cyclomatic 27) ci/release/releasetool/main.go:612— main.verifyStripped 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.
engine.compoundEnclosedRoute (cyclomatic 27) d2layouts/d2talalayout/internal/engine/compound_routes.go:108— engine.compoundEnclosedRoute has cyclomatic complexity 27 (threshold 15). Of this number, 17 points are the body's own statements and 10 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.
grouping.isValidRememberedSequence (cyclomatic 27) REDACTED:128— grouping.isValidRememberedSequence 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.
Transaction.hasBadPostStateOverlap (cyclomatic 27) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1103— Transaction.hasBadPostStateOverlap 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.
quality.measureGeometry (cyclomatic 27) d2layouts/d2talalayout/internal/quality/inspection_geometry.go:15— quality.measureGeometry 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.
routing.routeAdditionalEdgesWithResourceLimits (cyclomatic 27) d2layouts/d2talalayout/internal/routing/coordinator.go:531— routing.routeAdditionalEdgesWithResourceLimits has cyclomatic complexity 27 (threshold 15). Of this number, 20 points are the body's own statements and 7 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.
routing.newOVGForHierarchy (cyclomatic 27) d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:15— routing.newOVGForHierarchy has cyclomatic complexity 27 (threshold 15). Of this number, 25 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.
OVG.addPortConnectionNodesAtBoundaries (cyclomatic 27) REDACTED:874— OVG.addPortConnectionNodesAtBoundaries has cyclomatic complexity 27 (threshold 15). Most of this is not in the body itself: 12 of the 27 points are its own statements and the rest belongs to one function literal inside it that branches (line 900). 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.
OVGNode.hasUnobstructedLineToPorts (cyclomatic 27) d2layouts/d2talalayout/internal/routing/ovg_node.go:184— OVGNode.hasUnobstructedLineToPorts 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.
trees.placeTree (cyclomatic 27) d2layouts/d2talalayout/internal/trees/layout.go:750— trees.placeTree 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.
trees.buildPlacementTrees (cyclomatic 27) d2layouts/d2talalayout/internal/trees/layout.go:1021— trees.buildPlacementTrees 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.
asciishapes.DrawPerson (cyclomatic 27) d2renderers/d2ascii/asciishapes/person.go:5— asciishapes.DrawPerson 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.
meshBuilder.extrudedProfile (cyclomatic 27) d2renderers/d2isometric/d2isometricimg/native_shapes.go:651— meshBuilder.extrudedProfile has cyclomatic complexity 27 (threshold 15). Of this number, 26 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.
Raster.renderStrips (cyclomatic 27) d2renderers/d2isometric/d2isometricimg/raster.go:396— Raster.renderStrips 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.
Rasterizer.WriteAlpha (cyclomatic 27) REDACTED:724— Rasterizer.WriteAlpha has cyclomatic complexity 27 (threshold 15). Most of this is not in the body itself: 9 of the 27 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 737, 781). 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.
retainedVectorValidator.path (cyclomatic 27) d2renderers/d2raster/vector_validation.go:519— retainedVectorValidator.path 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.
builder.preflightAssets (cyclomatic 27) d2renderers/d2scenebuild/assets.go:27— builder.preflightAssets 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.
builder.buildConnection (cyclomatic 27) d2renderers/d2scenebuild/connection.go:28— builder.buildConnection 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.
svgImporter.validateDegenerateStrokeCaps (cyclomatic 27) d2renderers/d2svgimport/compile.go:193— svgImporter.validateDegenerateStrokeCaps has cyclomatic complexity 27 (threshold 15). Of this number, 24 points are the body's own statements and 3 belong to one function literal inside it that branches. 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.
rasterimage.DecodeFirst (cyclomatic 27) internal/rasterimage/firstframe.go:87— rasterimage.DecodeFirst 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.
xgif.NormalizePalettedImage (cyclomatic 27) lib/xgif/xgif.go:1069— xgif.NormalizePalettedImage 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.
d2cli.bundleRasterPreview (cyclomatic 26) d2cli/raster.go:756— d2cli.bundleRasterPreview 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.
d2ir.walkVariableExpansion (cyclomatic 26) d2ir/expansion.go:193— d2ir.walkVariableExpansion 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.
d2grid.newGridDiagram (cyclomatic 26) d2layouts/d2grid/grid_diagram.go:28— d2grid.newGridDiagram 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.
gridDiagram.getBestLayout (cyclomatic 26) d2layouts/d2grid/layout.go:563— gridDiagram.getBestLayout has cyclomatic complexity 26 (threshold 15). Of this number, 14 points are the body's own statements and 12 belong to 3 function literals 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.
Graph.isStructurallyBadStateWithFixedOriginContext (cyclomatic 26) d2layouts/d2talalayout/internal/layoutgraph/graph.go:128— Graph.isStructurallyBadStateWithFixedOriginContext 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.
placement.optimizerDescendants (cyclomatic 26) d2layouts/d2talalayout/internal/placement/optimization_guard.go:602— placement.optimizerDescendants has cyclomatic complexity 26 (threshold 15). Most of this is not in the body itself: 7 of the 26 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 629, 612). 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.
placement.captureOptimizerNodePositions (cyclomatic 26) d2layouts/d2talalayout/internal/placement/optimization_guard.go:962— placement.captureOptimizerNodePositions 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.
sizelessOptimizer.placementPointsGuarded (cyclomatic 26) REDACTED:350— sizelessOptimizer.placementPointsGuarded has cyclomatic complexity 26 (threshold 15). Of this number, 24 points are the body's own statements and 2 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.
placementcost.EdgeLength (cyclomatic 26) d2layouts/d2talalayout/internal/placementcost/graph.go:111— placementcost.EdgeLength has cyclomatic complexity 26 (threshold 15). Of this number, 19 points are the body's own statements and 7 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.
routing.buildTunnelsBetween (cyclomatic 26) d2layouts/d2talalayout/internal/routing/tunnel.go:263— routing.buildTunnelsBetween 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.
OVG.addIntersections (cyclomatic 26) REDACTED:330— OVG.addIntersections 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.
asciishapes.DrawCylinder (cyclomatic 26) d2renderers/d2ascii/asciishapes/cylinder.go:3— asciishapes.DrawCylinder 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.
d2isometricimg.nativeShapeProfile (cyclomatic 26) d2renderers/d2isometric/d2isometricimg/native_shapes.go:510— d2isometricimg.nativeShapeProfile has cyclomatic complexity 26 (threshold 15). Of this number, 23 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.
d2isometricimg.writeSVGGroundShadow (cyclomatic 26) d2renderers/d2isometric/d2isometricimg/svg_lighting.go:274— d2isometricimg.writeSVGGroundShadow has cyclomatic complexity 26 (threshold 15). Of this number, 25 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.
d2scene.EndpointArcToCenter (cyclomatic 26) d2renderers/d2scene/path.go:356— d2scene.EndpointArcToCenter has cyclomatic complexity 26 (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.
d2scenebuild.parsePaperPatternSource (cyclomatic 26) d2renderers/d2scenebuild/pattern_sources.go:139— d2scenebuild.parsePaperPatternSource 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.
svgImporter.parseStylesheet (cyclomatic 26) d2renderers/d2svgimport/stylesheet.go:66— svgImporter.parseStylesheet 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.
svgImporter.stylesheetDeclarations (cyclomatic 26) d2renderers/d2svgimport/stylesheet.go:185— svgImporter.stylesheetDeclarations 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.
imagediff.CompareImages (cyclomatic 26) REDACTED:118— imagediff.CompareImages 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.
imageasset.probeResource (cyclomatic 26) lib/imageasset/probe.go:40— imageasset.probeResource 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.
Resolver.validateCached (cyclomatic 26) lib/imageasset/resolve.go:633— Resolver.validateCached 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.
d2cli.renderWithPNGEncoderToPaths (cyclomatic 25) d2cli/main.go:894— d2cli.renderWithPNGEncoderToPaths 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.
d2compiler.compileThemeOverrides (cyclomatic 25) d2compiler/compile.go:1914— d2compiler.compileThemeOverrides has cyclomatic complexity 25 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
d2dagrelayout.adjustDeltaForEdges (cyclomatic 25) d2layouts/d2dagrelayout/layout.go:1712— d2dagrelayout.adjustDeltaForEdges has cyclomatic complexity 25 (threshold 15). Most of this is not in the body itself: 12 of the 25 points are its own statements and the rest belongs to one function literal inside it that branches (line 1713). 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.
graphbounds.NodeBoundingBox (cyclomatic 25) d2layouts/d2talalayout/internal/graphbounds/bounds.go:45— graphbounds.NodeBoundingBox 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.
rankSimplex.computeCutValues (cyclomatic 25) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:354— rankSimplex.computeCutValues 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.
labeling.isClusterPathSharedChecked (cyclomatic 25) d2layouts/d2talalayout/internal/labeling/placement.go:1189— labeling.isClusterPathSharedChecked 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.
Graph.doesOverlapWithDimensionsContext (cyclomatic 25) d2layouts/d2talalayout/internal/layoutgraph/graph.go:338— Graph.doesOverlapWithDimensionsContext 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.
Transaction.markDescendantOverlapExceptions (cyclomatic 25) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1021— Transaction.markDescendantOverlapExceptions has cyclomatic complexity 25 (threshold 15). Of this number, 13 points are the body's own statements and 12 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.
placement.Equidistance (cyclomatic 25) d2layouts/d2talalayout/internal/placement/equidistance.go:18— placement.Equidistance has cyclomatic complexity 25 (threshold 15). Of this number, 24 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.
placement.chargeOptimizerTranspose (cyclomatic 25) d2layouts/d2talalayout/internal/placement/optimization_guard.go:549— placement.chargeOptimizerTranspose 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.
sizedOptimizer.findClosestUnoccupiedDistanceGuarded (cyclomatic 25) REDACTED:528— sizedOptimizer.findClosestUnoccupiedDistanceGuarded 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.
placementcost.computeSymmetryScoreInto (cyclomatic 25) d2layouts/d2talalayout/internal/placementcost/symmetry.go:397— placementcost.computeSymmetryScoreInto 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.
quality.findSharedSegments (cyclomatic 25) d2layouts/d2talalayout/internal/quality/labels.go:418— quality.findSharedSegments has cyclomatic complexity 25 (threshold 15). Most of this is not in the body itself: 12 of the 25 points are its own statements and the rest belongs to one function literal inside it that branches (line 448). 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.
ovgEdgeRouter.usedPorts (cyclomatic 25) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:465— ovgEdgeRouter.usedPorts 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.
asciishapes.DrawDocument (cyclomatic 25) d2renderers/d2ascii/asciishapes/document.go:5— asciishapes.DrawDocument 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.
d2isometricimg.nativeLaneClear (cyclomatic 25) d2renderers/d2isometric/d2isometricimg/route_lanes.go:373— d2isometricimg.nativeLaneClear has cyclomatic complexity 25 (threshold 15). Of this number, 22 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.
meshBuilder.arrowRetreat (cyclomatic 25) d2renderers/d2isometric/d2isometricimg/arrow_visibility.go:328— meshBuilder.arrowRetreat 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.
d2raster.applyNonZeroClip (cyclomatic 25) d2renderers/d2raster/effects.go:791— d2raster.applyNonZeroClip has cyclomatic complexity 25 (threshold 15). Most of this is not in the body itself: 10 of the 25 points are its own statements and the rest belongs to one function literal inside it that branches (line 815). 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.
d2raster.paintDropShadowInteger (cyclomatic 25) d2renderers/d2raster/filter.go:955— d2raster.paintDropShadowInteger 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.
d2raster.addStrokeRun (cyclomatic 25) d2renderers/d2raster/geometry.go:677— d2raster.addStrokeRun 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.
d2raster.render (cyclomatic 25) d2renderers/d2raster/raster.go:341— d2raster.render has cyclomatic complexity 25 (threshold 15). Of this number, 24 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.
preflight.animationValueAt (cyclomatic 25) d2renderers/d2raster/animation_value.go:15— preflight.animationValueAt 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.
d2scenebuild.flattenSketchPath (cyclomatic 25) d2renderers/d2scenebuild/sketch_shapes.go:318— d2scenebuild.flattenSketchPath has cyclomatic complexity 25 (threshold 15). Of this number, 19 points are the body's own statements and 6 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.
builder.splitAnimatedConnectionPath (cyclomatic 25) d2renderers/d2scenebuild/connection.go:218— builder.splitAnimatedConnectionPath 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.
builder.buildMarkdownLabel (cyclomatic 25) d2renderers/d2scenebuild/markdown.go:101— builder.buildMarkdownLabel 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.
builder.buildSketchStructuredShape (cyclomatic 25) d2renderers/d2scenebuild/sketch_shapes.go:592— builder.buildSketchStructuredShape 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.
svgImporter.compileLinearGradient (cyclomatic 25) d2renderers/d2svgimport/gradient.go:90— svgImporter.compileLinearGradient has cyclomatic complexity 25 (threshold 15). Of this number, 24 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.
svgImporter.resolveEmbeddedRaster (cyclomatic 25) d2renderers/d2svgimport/image.go:72— svgImporter.resolveEmbeddedRaster has cyclomatic complexity 25 (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.
d2layoutfeatures.Check (cyclomatic 25) internal/d2layoutfeatures/features.go:21— d2layoutfeatures.Check 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.
markdownPainter.paintInlineNodes (cyclomatic 25) lib/textmeasure/markdown_svg.go:753— markdownPainter.paintInlineNodes 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.
isometricPagedRenderer.admitPage (cyclomatic 24) d2cli/isometric_paged.go:135— isometricPagedRenderer.admitPage 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.
compiler.validateNear (cyclomatic 24) d2compiler/compile.go:1585— compiler.validateNear 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.
Object.GetDefaultSize (cyclomatic 24) d2graph/d2graph.go:996— Object.GetDefaultSize 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.
Object.SpacingOpt (cyclomatic 24) d2graph/d2graph.go:1898— Object.SpacingOpt has cyclomatic complexity 24 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
compiler.extendLinks (cyclomatic 24) REDACTED:1928— compiler.extendLinks 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.
compiler.compileArray (cyclomatic 24) REDACTED:2285— compiler.compileArray 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.
d2dagrelayout.shiftDown (cyclomatic 24) d2layouts/d2dagrelayout/layout.go:664— d2dagrelayout.shiftDown 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. This shape REPEATS in the file: one other method here (d2dagrelayout.shiftUp) 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.
d2dagrelayout.shiftUp (cyclomatic 24) d2layouts/d2dagrelayout/layout.go:728— d2dagrelayout.shiftUp 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. This shape REPEATS in the file: one other method here (d2dagrelayout.shiftDown) 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.
placement.optimizerDoesOverlap (cyclomatic 24) d2layouts/d2talalayout/internal/placement/optimization_guard.go:439— placement.optimizerDoesOverlap 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.
placement.scaleBasedOnEdges (cyclomatic 24) d2layouts/d2talalayout/internal/placement/stages.go:26— placement.scaleBasedOnEdges 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.
OVG.addPorts (cyclomatic 24) REDACTED:233— OVG.addPorts 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.
trees.candidateTreeRoots (cyclomatic 24) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:220— trees.candidateTreeRoots has cyclomatic complexity 24 (threshold 15). Of this number, 22 points are the body's own statements and 2 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.
asciishapes.DrawQueue (cyclomatic 24) d2renderers/d2ascii/asciishapes/queue.go:3— asciishapes.DrawQueue has cyclomatic complexity 24 (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.
d2isometricimg.nativeGIFLoopScene (cyclomatic 24) d2renderers/d2isometric/d2isometricimg/gif_loop.go:16— d2isometricimg.nativeGIFLoopScene has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 9 of the 24 points are its own statements and the rest belongs to one function literal inside it that branches (line 26). 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.
d2isometricimg.hierarchyTerraces (cyclomatic 24) d2renderers/d2isometric/d2isometricimg/hierarchy_boards.go:164— d2isometricimg.hierarchyTerraces has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 10 of the 24 points are its own statements and the rest belongs to one function literal inside it that branches (line 192). 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.
d2isometricimg.hierarchyStrongTerraces (cyclomatic 24) d2renderers/d2isometric/d2isometricimg/hierarchy_support.go:20— d2isometricimg.hierarchyStrongTerraces has cyclomatic complexity 24 (threshold 15). Of this number, 14 points are the body's own statements and 10 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.
d2isometricimg.preflightPageMetadata (cyclomatic 24) d2renderers/d2isometric/d2isometricimg/page.go:66— d2isometricimg.preflightPageMetadata has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 10 of the 24 points are its own statements and the rest belongs to one function literal inside it that branches (line 71). 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.
d2isometricimg.normalize (cyclomatic 24) d2renderers/d2isometric/d2isometricimg/render.go:56— d2isometricimg.normalize has cyclomatic complexity 24 (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.
meshBuilder.canonicalNode (cyclomatic 24) d2renderers/d2isometric/d2isometricimg/native_shapes.go:313— meshBuilder.canonicalNode 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.
surfaceIconPainter.texture (cyclomatic 24) d2renderers/d2isometric/d2isometricimg/surface_icons.go:130— surfaceIconPainter.texture 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.
nativeSurfaceSVGWriter.primitive (cyclomatic 24) d2renderers/d2isometric/d2isometricimg/vector_surface_svg.go:371— nativeSurfaceSVGWriter.primitive 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.
d2raster.renderBands (cyclomatic 24) d2renderers/d2raster/bands.go:38— d2raster.renderBands 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.
Rasterizer.accumulateEdgeRow (cyclomatic 24) REDACTED:1169— Rasterizer.accumulateEdgeRow 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.
d2svg.RenderLegend (cyclomatic 24) d2renderers/d2svg/d2svg.go:259— d2svg.RenderLegend 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.
svgGeometry.primitive (cyclomatic 24) d2renderers/d2svgimport/compile.go:597— svgGeometry.primitive 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.
testutil.parsePDFLiteralString (cyclomatic 24) internal/testutil/pdf.go:545— testutil.parsePDFLiteralString has cyclomatic complexity 24 (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.
d2cli.validateBoardOutputManifest (cyclomatic 23) d2cli/board_output_publish.go:272— d2cli.validateBoardOutputManifest has cyclomatic complexity 23 (threshold 15). Of this number, 13 points are the body's own statements and 10 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.
compiler.__import (cyclomatic 23) d2ir/import.go:86— compiler.__import 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.
hierarchy.isValid (cyclomatic 23) d2layouts/d2talalayout/internal/hierarchy/discovery.go:249— hierarchy.isValid has cyclomatic complexity 23 (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.
rankSimplex.optimize (cyclomatic 23) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:281— rankSimplex.optimize 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.
labeling.clusterNodeBoundingBoxPlacement (cyclomatic 23) d2layouts/d2talalayout/internal/labeling/guard.go:325— labeling.clusterNodeBoundingBoxPlacement 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.
layoutgraph.transactionSweepPadding (cyclomatic 23) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:407— layoutgraph.transactionSweepPadding 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.
Node.boundingBoxValues (cyclomatic 23) d2layouts/d2talalayout/internal/layoutgraph/node.go:93— Node.boundingBoxValues 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.
Node.UpdateSpacing (cyclomatic 23) d2layouts/d2talalayout/internal/layoutgraph/node.go:927— Node.UpdateSpacing has cyclomatic complexity 23 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
Node.IsBlocked (cyclomatic 23) d2layouts/d2talalayout/internal/layoutgraph/node.go:1172— Node.IsBlocked 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.
optimizerSpatialIndex.rebuild (cyclomatic 23) d2layouts/d2talalayout/internal/placement/optimizer_spatial_index.go:103— optimizerSpatialIndex.rebuild has cyclomatic complexity 23 (threshold 15). Of this number, 20 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.
routing.routeStageGraphBoundingBox (cyclomatic 23) d2layouts/d2talalayout/internal/routing/route_stage_guard.go:400— routing.routeStageGraphBoundingBox has cyclomatic complexity 23 (threshold 15). Of this number, 21 points are the body's own statements and 2 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.
routing.swapEdgesOnAdjacentSides (cyclomatic 23) d2layouts/d2talalayout/internal/routing/swap_ports.go:541— routing.swapEdgesOnAdjacentSides 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.
trees.putBackNonBranchingTrees (cyclomatic 23) d2layouts/d2talalayout/internal/trees/layout.go:573— trees.putBackNonBranchingTrees 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.
ASCIIartist.calculateExtendedBounds (cyclomatic 23) d2renderers/d2ascii/d2ascii.go:133— ASCIIartist.calculateExtendedBounds 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.
d2isometricimg.nativeConnectionCaptionSurface (cyclomatic 23) d2renderers/d2isometric/d2isometricimg/route_caption_style.go:57— d2isometricimg.nativeConnectionCaptionSurface has cyclomatic complexity 23 (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.
d2isometricimg.nativeFallbackTextTexture (cyclomatic 23) d2renderers/d2isometric/d2isometricimg/surface_fonts.go:206— d2isometricimg.nativeFallbackTextTexture has cyclomatic complexity 23 (threshold 15). Of this number, 15 points are the body's own statements and 8 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.
d2isometricimg.nativeSurfaceSVG (cyclomatic 23) d2renderers/d2isometric/d2isometricimg/vector_surface_svg.go:36— d2isometricimg.nativeSurfaceSVG has cyclomatic complexity 23 (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.
preflight.assets (cyclomatic 23) d2renderers/d2raster/raster.go:837— preflight.assets 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.
d2svgimport.validatePrimitiveBounds (cyclomatic 23) d2renderers/d2svgimport/import.go:242— d2svgimport.validatePrimitiveBounds has cyclomatic complexity 23 (threshold 15). Of this number, 20 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.
svgImporter.attributes (cyclomatic 23) d2renderers/d2svgimport/import.go:770— svgImporter.attributes 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.
d2target.stabilizeHashURLs (cyclomatic 23) d2target/d2target.go:250— d2target.stabilizeHashURLs has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 2 of the 23 points are its own statements and the rest belongs to one function literal inside it that branches (line 256). 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.
d2target.ToArrowhead (cyclomatic 23) d2target/d2target.go:1133— d2target.ToArrowhead has cyclomatic complexity 23 (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.
rasterimage.extractWebPFrame (cyclomatic 23) internal/rasterimage/firstframe.go:840— rasterimage.extractWebPFrame 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.
run.run (cyclomatic 23) ci/nonlayout-perf/run.py:41— run.run 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.
main.main (cyclomatic 22) ci/tala-performance/main.go:197— main.main 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, 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.
d2cli.publishBoardOutputWorkspace (cyclomatic 22) d2cli/board_output_publish.go:38— d2cli.publishBoardOutputWorkspace 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, 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.
d2compiler.compileConfig (cyclomatic 22) d2compiler/compile.go:1823— d2compiler.compileConfig has cyclomatic complexity 22 (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.
compiler.compileBoard (cyclomatic 22) d2compiler/compile.go:145— compiler.compileBoard has cyclomatic complexity 22 (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.
printer.mapKey (cyclomatic 22) d2format/format.go:367— printer.mapKey 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.
engine.CompoundCandidate (cyclomatic 22) REDACTED:16— engine.CompoundCandidate has cyclomatic complexity 22 (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.
grouping.Cleanup (cyclomatic 22) d2layouts/d2talalayout/internal/grouping/lifecycle.go:126— grouping.Cleanup has cyclomatic complexity 22 (threshold 15). 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.
layoutgraph.countSegmentCrossingsWithCheck (cyclomatic 22) d2layouts/d2talalayout/internal/layoutgraph/segment_crossing.go:54— layoutgraph.countSegmentCrossingsWithCheck 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.
graphCloneState.copyTrees (cyclomatic 22) REDACTED:546— graphCloneState.copyTrees has cyclomatic complexity 22 (threshold 15). Most of this is not in the body itself: 6 of the 22 points are its own statements and the rest belongs to one function literal inside it that branches (line 552). 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.
Graph.allDescendantNodesGuarded (cyclomatic 22) d2layouts/d2talalayout/internal/layoutgraph/graph.go:955— Graph.allDescendantNodesGuarded 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 one function literal inside it that branches (line 971). 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.
packing.snapshotCombineNodePositions (cyclomatic 22) d2layouts/d2talalayout/internal/packing/combine_snapshot.go:25— packing.snapshotCombineNodePositions has cyclomatic complexity 22 (threshold 15). Of this number, 18 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.
placement.snapshotNodePositionsContext (cyclomatic 22) d2layouts/d2talalayout/internal/placement/types.go:47— placement.snapshotNodePositionsContext has cyclomatic complexity 22 (threshold 15). Of this number, 18 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.
routing.balancePortInteriorsGuarded (cyclomatic 22) d2layouts/d2talalayout/internal/routing/port_interior_balance.go:18— routing.balancePortInteriorsGuarded 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.
routing.positionedArrowheadLabelCostGuarded (cyclomatic 22) d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:207— routing.positionedArrowheadLabelCostGuarded 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.
OVG.connectNodes (cyclomatic 22) REDACTED:1115— OVG.connectNodes has cyclomatic complexity 22 (threshold 15). Of this number, 19 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.
OVG.fixedOverlapsForBuild (cyclomatic 22) d2layouts/d2talalayout/internal/routing/ovg_resource.go:607— OVG.fixedOverlapsForBuild 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.
trees.positionEdgeLabels (cyclomatic 22) d2layouts/d2talalayout/internal/trees/geometry.go:285— trees.positionEdgeLabels 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.
trees.handleTreeSubgraph (cyclomatic 22) d2layouts/d2talalayout/internal/trees/layout.go:251— trees.handleTreeSubgraph 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.
d2oracle.generateUniqueKey (cyclomatic 22) d2oracle/edit.go:2650— d2oracle.generateUniqueKey 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.
parser.parseMap (cyclomatic 22) d2parser/parse.go:443— parser.parseMap 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.
asciishapes.DrawStoredData (cyclomatic 22) d2renderers/d2ascii/asciishapes/stored_data.go:7— asciishapes.DrawStoredData 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.
meshBuilder.classicInkJunctions (cyclomatic 22) d2renderers/d2isometric/d2isometricimg/native_ink_joins.go:12— meshBuilder.classicInkJunctions 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, 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.
meshBuilder.solidContentSupport (cyclomatic 22) d2renderers/d2isometric/d2isometricimg/native_solids.go:203— meshBuilder.solidContentSupport has cyclomatic complexity 22 (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.
routeCaptionPlacer.score (cyclomatic 22) d2renderers/d2isometric/d2isometricimg/route_labels.go:265— routeCaptionPlacer.score has cyclomatic complexity 22 (threshold 15). Of this number, 11 points are the body's own statements and 11 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.
nativeSurfaceSVGWriter.node (cyclomatic 22) d2renderers/d2isometric/d2isometricimg/vector_surface_svg.go:154— nativeSurfaceSVGWriter.node 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.
d2isometric.composeHierarchy (cyclomatic 22) REDACTED:13— d2isometric.composeHierarchy 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.
d2raster.planPrimitiveResources (cyclomatic 22) d2renderers/d2raster/effects.go:502— d2raster.planPrimitiveResources 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.
d2raster.strokeRegionBounds (cyclomatic 22) d2renderers/d2raster/stroke_regions.go:54— d2raster.strokeRegionBounds 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.
retainedVectorValidator.stroke (cyclomatic 22) d2renderers/d2raster/vector_validation.go:756— retainedVectorValidator.stroke 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.
d2scenebuild.Build (cyclomatic 22) d2renderers/d2scenebuild/build.go:165— d2scenebuild.Build has cyclomatic complexity 22 (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.
d2sketch.CompileScenePaths (cyclomatic 22) d2renderers/d2sketch/scene.go:34— d2sketch.CompileScenePaths 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.
d2svgimport.splitSVGNumberList (cyclomatic 22) d2renderers/d2svgimport/style.go:744— d2svgimport.splitSVGNumberList has cyclomatic complexity 22 (threshold 15). Of this number, 19 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.
svgImporter.compileClipPathResource (cyclomatic 22) d2renderers/d2svgimport/clip.go:113— svgImporter.compileClipPathResource 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.
Diagram.GetBoard (cyclomatic 22) d2target/d2target.go:109— Diagram.GetBoard 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.
rasterimage.jpegEXIFOrientation (cyclomatic 22) internal/rasterimage/jpeg_orientation.go:23— rasterimage.jpegEXIFOrientation 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.
testutil.InspectD2PDF (cyclomatic 22) internal/testutil/pdf.go:66— testutil.InspectD2PDF 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.
testutil.inspectPDFImage (cyclomatic 22) internal/testutil/pdf.go:343— testutil.inspectPDFImage has cyclomatic complexity 22 (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.
Resolver.classifySource (cyclomatic 22) lib/imageasset/resolve.go:183— Resolver.classifySource 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.
svg.parseSupportedExternalDoctype (cyclomatic 22) lib/svg/doctype.go:67— svg.parseSupportedExternalDoctype has cyclomatic complexity 22 (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.
xgif.buildFewOpaquePaletted (cyclomatic 22) lib/xgif/xgif.go:392— xgif.buildFewOpaquePaletted 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.
d2cli._renderWithPNGEncoder (cyclomatic 21) d2cli/main.go:965— d2cli._renderWithPNGEncoder 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.
boardOutputWorkspace.discard (cyclomatic 21) d2cli/board_output.go:348— boardOutputWorkspace.discard 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.
watcher.watchLoop (cyclomatic 21) REDACTED:244— watcher.watchLoop 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.
d2graph.compareSerializedEdge (cyclomatic 21) REDACTED:387— d2graph.compareSerializedEdge 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.
Object.GetMargin (cyclomatic 21) d2graph/layout.go:289— Object.GetMargin has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
compiler.compileLink (cyclomatic 21) REDACTED:1995— compiler.compileLink 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.
d2dagrelayout.adjustCrossRankSpacing (cyclomatic 21) d2layouts/d2dagrelayout/layout.go:1306— d2dagrelayout.adjustCrossRankSpacing 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.
d2talalayout.buildLayoutPatch (cyclomatic 21) d2layouts/d2talalayout/patch.go:158— d2talalayout.buildLayoutPatch 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.
Graph.containerPadding (cyclomatic 21) d2layouts/d2talalayout/internal/layoutgraph/graph.go:1168— Graph.containerPadding 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.
GraphState.captureRuntimeStateContext (cyclomatic 21) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:707— GraphState.captureRuntimeStateContext 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.
packing.estimateEdgeSegments (cyclomatic 21) d2layouts/d2talalayout/internal/packing/binpack.go:1283— packing.estimateEdgeSegments has cyclomatic complexity 21 (threshold 15). Of this number, 19 points are the body's own statements and 2 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.
placement.compaction (cyclomatic 21) d2layouts/d2talalayout/internal/placement/compaction.go:32— placement.compaction has cyclomatic complexity 21 (threshold 15). Of this number, 20 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.
sizelessOptimizer.findClosestUnoccupiedDistanceGuarded (cyclomatic 21) REDACTED:280— sizelessOptimizer.findClosestUnoccupiedDistanceGuarded has cyclomatic complexity 21 (threshold 15). Of this number, 19 points are the body's own statements and 2 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.
quality.inspectWithLimit (cyclomatic 21) d2layouts/d2talalayout/internal/quality/inspection.go:27— quality.inspectWithLimit 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.
routing.nudgeChannelsGuarded (cyclomatic 21) d2layouts/d2talalayout/internal/routing/nudge_channels.go:50— routing.nudgeChannelsGuarded 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.
routing.undershot (cyclomatic 21) d2layouts/d2talalayout/internal/routing/slingshot.go:176— routing.undershot 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.
OVG.flagNodesNearPorts (cyclomatic 21) REDACTED:1540— OVG.flagNodesNearPorts 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.
d2oracle.RenameIDDeltas (cyclomatic 21) d2oracle/edit.go:3163— d2oracle.RenameIDDeltas has cyclomatic complexity 21 (threshold 15). Of this number, 15 points are the body's own statements and 6 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.
parser.parseBlockString (cyclomatic 21) d2parser/parse.go:1490— parser.parseBlockString 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.
SystemFallbackResolver.fontPaths (cyclomatic 21) d2renderers/d2fonts/fallback.go:338— SystemFallbackResolver.fontPaths 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.
d2isometricimg.rasterSnapshot (cyclomatic 21) d2renderers/d2isometric/d2isometricimg/raster.go:307— d2isometricimg.rasterSnapshot 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.
meshBuilder.arrowOwnerCaps (cyclomatic 21) d2renderers/d2isometric/d2isometricimg/arrow_visibility.go:94— meshBuilder.arrowOwnerCaps has cyclomatic complexity 21 (threshold 15). Of this number, 14 points are the body's own statements and 7 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.
meshBuilder.nativeFaceLayer (cyclomatic 21) d2renderers/d2isometric/d2isometricimg/native_shapes.go:191— meshBuilder.nativeFaceLayer 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.
meshBuilder.routeCaptionKnockout (cyclomatic 21) d2renderers/d2isometric/d2isometricimg/route_caption_mask.go:10— meshBuilder.routeCaptionKnockout has cyclomatic complexity 21 (threshold 15). Of this number, 18 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.
budget.check (cyclomatic 21) d2renderers/d2isometric/scene.go:343— budget.check 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.
d2raster.normalizeNodeFilters (cyclomatic 21) d2renderers/d2raster/filter.go:53— d2raster.normalizeNodeFilters 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.
d2raster.prepareAnimatedPaintWithPattern (cyclomatic 21) d2renderers/d2raster/gradient.go:62— d2raster.prepareAnimatedPaintWithPattern 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.
d2raster.prepareAnimatedStrokeWithPaint (cyclomatic 21) d2renderers/d2raster/raster.go:1475— d2raster.prepareAnimatedStrokeWithPaint 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: d2raster.validateOptions (cyclomatic 23) 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 function is counted neither in this dimension's figures nor in its score.
preflight.preparePatternPaint (cyclomatic 21) d2renderers/d2raster/pattern.go:50— preflight.preparePatternPaint 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.
builder.sceneTextReferences (cyclomatic 21) d2renderers/d2scenebuild/font_fallback.go:802— builder.sceneTextReferences 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.
builder.buildConnectionLabels (cyclomatic 21) d2renderers/d2scenebuild/labels.go:159— builder.buildConnectionLabels 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.
builder.buildLegend (cyclomatic 21) d2renderers/d2scenebuild/legend.go:351— builder.buildLegend 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.
builder.buildMarkdownPrimitive (cyclomatic 21) d2renderers/d2scenebuild/markdown.go:239— builder.buildMarkdownPrimitive 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.
d2svg.singleThemeRulesets (cyclomatic 21) d2renderers/d2svg/d2svg.go:3322— d2svg.singleThemeRulesets 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.
d2svg.themeRuleSelector (cyclomatic 21) d2renderers/d2svg/theme.go:120— d2svg.themeRuleSelector 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.
svgImporter.viewport (cyclomatic 21) d2renderers/d2svgimport/viewport.go:18— svgImporter.viewport 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.
Theme.ApplyOverrides (cyclomatic 21) d2themes/d2themes.go:33— Theme.ApplyOverrides 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.
color.Darken (cyclomatic 21) lib/color/color.go:22— color.Darken has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
d2cli.renderPPTXWithRenderer (cyclomatic 20) d2cli/paged.go:509— d2cli.renderPPTXWithRenderer has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 7 of the 20 points are its own statements and the rest belongs to one function literal inside it that branches (line 523). 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.
boardOutputTransaction.removeStaleDirectories (cyclomatic 20) d2cli/board_output_publish.go:815— boardOutputTransaction.removeStaleDirectories 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.
compiler.compilePosition (cyclomatic 20) d2compiler/compile.go:798— compiler.compilePosition 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. This is NOT this file's highest cyclomatic complexity: d2compiler.compileStyleFieldInit (cyclomatic 21) 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 function is counted neither in this dimension's figures nor in its score.
compiler.IsContainer (cyclomatic 20) REDACTED:1032— compiler.IsContainer 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.
d2dagrelayout.adjustEdges (cyclomatic 20) d2layouts/d2dagrelayout/layout.go:1802— d2dagrelayout.adjustEdges has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 4 of the 20 points are its own statements and the rest belongs to one function literal inside it that branches (line 1803). 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.
d2sequence.newSequenceDiagram (cyclomatic 20) d2layouts/d2sequence/sequence_diagram.go:78— d2sequence.newSequenceDiagram 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.
grouping.identifySequences (cyclomatic 20) REDACTED:18— grouping.identifySequences 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.
hierarchy.alignHierarchy (cyclomatic 20) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:42— hierarchy.alignHierarchy 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.
labeling.sortLabelPlacementEdges (cyclomatic 20) d2layouts/d2talalayout/internal/labeling/guard.go:486— labeling.sortLabelPlacementEdges has cyclomatic complexity 20 (threshold 15). Of this number, 16 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.
placementcost.obstructed (cyclomatic 20) d2layouts/d2talalayout/internal/placementcost/symmetry.go:514— placementcost.obstructed has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 3 of the 20 points are its own statements and the rest belongs to one function literal inside it that branches (line 516). 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.
placementcost.isMirrored (cyclomatic 20) d2layouts/d2talalayout/internal/placementcost/symmetry.go:625— placementcost.isMirrored 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.
routing.routeEdgesWithResourceGuards (cyclomatic 20) d2layouts/d2talalayout/internal/routing/coordinator.go:419— routing.routeEdgesWithResourceGuards 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.
routing.newOVGEdgeRouterWithWorkLimit (cyclomatic 20) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:102— routing.newOVGEdgeRouterWithWorkLimit has cyclomatic complexity 20 (threshold 15). 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, 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.
routing.treeEdgePathForBuild (cyclomatic 20) d2layouts/d2talalayout/internal/routing/tree_routes.go:28— routing.treeEdgePathForBuild has cyclomatic complexity 20 (threshold 15). 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, 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.
routing.buildTunnels (cyclomatic 20) d2layouts/d2talalayout/internal/routing/tunnel.go:366— routing.buildTunnels 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.
OVG.addEdgesNodes (cyclomatic 20) REDACTED:433— OVG.addEdgesNodes 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.
OVG.createPortsConnectionsToBoundaries (cyclomatic 20) REDACTED:1455— OVG.createPortsConnectionsToBoundaries has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 6 of the 20 points are its own statements and the rest belongs to one function literal inside it that branches (line 1470). 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.
ovgEdgeRouter.slingshot (cyclomatic 20) d2layouts/d2talalayout/internal/routing/slingshot.go:566— ovgEdgeRouter.slingshot has cyclomatic complexity 20 (threshold 15). Of this number, 13 points are the body's own statements and 7 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.
trees.treePlacementDescendants (cyclomatic 20) d2layouts/d2talalayout/internal/trees/geometry.go:571— trees.treePlacementDescendants has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 9 of the 20 points are its own statements and the rest belongs to one function literal inside it that branches (line 578). 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.
d2isometricimg.nativeLaneObstacles (cyclomatic 20) d2renderers/d2isometric/d2isometricimg/route_lanes.go:350— d2isometricimg.nativeLaneObstacles 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.
d2isometricimg.nativeSequenceCaptionData (cyclomatic 20) d2renderers/d2isometric/d2isometricimg/sequence_routes.go:100— d2isometricimg.nativeSequenceCaptionData has cyclomatic complexity 20 (threshold 15). Of this number, 18 points are the body's own statements and 2 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.
projectedExtent.preparedGroundShadows (cyclomatic 20) d2renderers/d2isometric/d2isometricimg/framing.go:75— projectedExtent.preparedGroundShadows has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 7 of the 20 points are its own statements and the rest belongs to one function literal inside it that branches (line 90). 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.
d2raster.multiplyLayerByAlpha (cyclomatic 20) d2renderers/d2raster/effects.go:1023— d2raster.multiplyLayerByAlpha 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.
preflight.prepareFilters (cyclomatic 20) d2renderers/d2raster/filter.go:132— preflight.prepareFilters 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. This is NOT this file's highest cyclomatic complexity: d2raster.exactIntegerTranslatedBounds (cyclomatic 21) 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 function is counted neither in this dimension's figures nor in its score.
builder.buildConnectionMask (cyclomatic 20) d2renderers/d2scenebuild/labels.go:17— builder.buildConnectionMask 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.
d2svg.pruneThemeCSSWithClasses (cyclomatic 20) d2renderers/d2svg/theme.go:19— d2svg.pruneThemeCSSWithClasses 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.
d2svgimport.inspectEmbeddedGIF (cyclomatic 20) d2renderers/d2svgimport/image.go:492— d2svgimport.inspectEmbeddedGIF 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.
svgImporter.validateClipTree (cyclomatic 20) d2renderers/d2svgimport/clip.go:38— svgImporter.validateClipTree 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.
imageasset.expandDeclaredSVG (cyclomatic 20) lib/imageasset/probe.go:148— imageasset.expandDeclaredSVG 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.
Resolver.loadData (cyclomatic 20) lib/imageasset/resolve.go:507— Resolver.loadData 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.
compare.main (cyclomatic 20) ci/tala-performance/compare.py:48— compare.main 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.
d2cli.isPortableBoardOutputComponent (cyclomatic 19) d2cli/board_output.go:50— d2cli.isPortableBoardOutputComponent has cyclomatic complexity 19 (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.
d2cli.renderPDFWithRenderer (cyclomatic 19) d2cli/paged.go:428— d2cli.renderPDFWithRenderer has cyclomatic complexity 19 (threshold 15). Most of this is not in the body itself: 7 of the 19 points are its own statements and the rest belongs to one function literal inside it that branches (line 440). 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.
d2exporter.applyStyles (cyclomatic 19) d2exporter/export.go:152— d2exporter.applyStyles 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.
compiler.validateConfigs (cyclomatic 19) REDACTED:359— compiler.validateConfigs has cyclomatic complexity 19 (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.
d2near.place (cyclomatic 19) d2layouts/d2near/layout.go:95— d2near.place has cyclomatic complexity 19 (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.
d2near.boundingBox (cyclomatic 19) d2layouts/d2near/layout.go:151— d2near.boundingBox has cyclomatic complexity 19 (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.
hierarchy.markConflicts (cyclomatic 19) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:467— hierarchy.markConflicts 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, 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.
hierarchy.assign (cyclomatic 19) d2layouts/d2talalayout/internal/hierarchy/discovery.go:111— hierarchy.assign 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, 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.
labeling.sortSharedSegmentGroup (cyclomatic 19) d2layouts/d2talalayout/internal/labeling/guard.go:557— labeling.sortSharedSegmentGroup 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, 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.
packing.placementCandidatesGuarded (cyclomatic 19) d2layouts/d2talalayout/internal/packing/binpack.go:1032— packing.placementCandidatesGuarded has cyclomatic complexity 19 (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.
placement.direct (cyclomatic 19) d2layouts/d2talalayout/internal/placement/direct.go:270— placement.direct 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.
sizedOptimizer.findUnoccupiedGuarded (cyclomatic 19) REDACTED:619— sizedOptimizer.findUnoccupiedGuarded has cyclomatic complexity 19 (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.
obstructionBounds.excludes (cyclomatic 19) d2layouts/d2talalayout/internal/placementcost/obstruction_bounds.go:40— obstructionBounds.excludes has cyclomatic complexity 19 (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.
routing.checkBalanceOrder (cyclomatic 19) d2layouts/d2talalayout/internal/routing/balance_route_guard.go:167— routing.checkBalanceOrder has cyclomatic complexity 19 (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.
routing.segmentIntersectsBox (cyclomatic 19) d2layouts/d2talalayout/internal/routing/geometry.go:9— routing.segmentIntersectsBox has cyclomatic complexity 19 (threshold 15). Of this number, 13 points are the body's own statements and 6 belong to 2 function literals inside it that branch. 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.
trees.placeTrees (cyclomatic 19) d2layouts/d2talalayout/internal/trees/layout.go:906— trees.placeTrees 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, 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.
asciishapes.DrawPackage (cyclomatic 19) d2renderers/d2ascii/asciishapes/package.go:5— asciishapes.DrawPackage has cyclomatic complexity 19 (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.
asciishapes.DrawStep (cyclomatic 19) d2renderers/d2ascii/asciishapes/step.go:3— asciishapes.DrawStep has cyclomatic complexity 19 (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.
d2isometricimg.nativeShapeProfiles (cyclomatic 19) d2renderers/d2isometric/d2isometricimg/native_shapes.go:593— d2isometricimg.nativeShapeProfiles has cyclomatic complexity 19 (threshold 15). Of this number, 11 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.
d2isometricimg.nativeVectorInitialPaint (cyclomatic 19) d2renderers/d2isometric/d2isometricimg/vector_surface_animation.go:43— d2isometricimg.nativeVectorInitialPaint has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
meshBuilder.arrowObstacles (cyclomatic 19) d2renderers/d2isometric/d2isometricimg/arrow_visibility.go:223— meshBuilder.arrowObstacles has cyclomatic complexity 19 (threshold 15). Most of this is not in the body itself: 8 of the 19 points are its own statements and the rest belongs to one function literal inside it that branches (line 234). 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.
meshBuilder.structuredNode (cyclomatic 19) d2renderers/d2isometric/d2isometricimg/native_structured.go:142— meshBuilder.structuredNode 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, 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.
nativeSurfaceSVGWriter.paint (cyclomatic 19) d2renderers/d2isometric/d2isometricimg/vector_surface_svg.go:280— nativeSurfaceSVGWriter.paint has cyclomatic complexity 19 (threshold 15). Of this number, 15 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.
d2raster.setBandReferenceBounds (cyclomatic 19) d2renderers/d2raster/bands.go:180— d2raster.setBandReferenceBounds has cyclomatic complexity 19 (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.
d2raster.drawSampledPreparedImage (cyclomatic 19) d2renderers/d2raster/image.go:1022— d2raster.drawSampledPreparedImage has cyclomatic complexity 19 (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.
Rasterizer.rasterize (cyclomatic 19) REDACTED:1026— Rasterizer.rasterize has cyclomatic complexity 19 (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.
retainedVectorValidator.paint (cyclomatic 19) d2renderers/d2raster/vector_validation.go:580— retainedVectorValidator.paint has cyclomatic complexity 19 (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.
builder.measureAppendix (cyclomatic 19) d2renderers/d2scenebuild/appendix.go:139— builder.measureAppendix has cyclomatic complexity 19 (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.
builder.preflight (cyclomatic 19) d2renderers/d2scenebuild/build.go:282— builder.preflight 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.
d2svg.dimensions (cyclomatic 19) d2renderers/d2svg/d2svg.go:178— d2svg.dimensions has cyclomatic complexity 19 (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.
d2svgimport.ImportNodeWithOptions (cyclomatic 19) d2renderers/d2svgimport/import.go:117— d2svgimport.ImportNodeWithOptions 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.
d2svgimport.transformFunction (cyclomatic 19) d2renderers/d2svgimport/transform.go:247— d2svgimport.transformFunction has cyclomatic complexity 19 (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.
svgImporter.validateIgnoredUnnamespacedAttribute (cyclomatic 19) d2renderers/d2svgimport/boilerplate.go:243— svgImporter.validateIgnoredUnnamespacedAttribute has cyclomatic complexity 19 (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.
ParsedFace.SupportsRenderableRune (cyclomatic 19) d2renderers/internal/fontface/face.go:404— ParsedFace.SupportsRenderableRune has cyclomatic complexity 19 (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.
testutil.ValidatePPTX (cyclomatic 19) internal/testutil/pptx.go:18— testutil.ValidatePPTX has cyclomatic complexity 19 (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.
png.exifChunkLocation (cyclomatic 19) lib/png/png.go:135— png.exifChunkLocation has cyclomatic complexity 19 (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.
textmeasure.fitMarkdownTableColumns (cyclomatic 19) lib/textmeasure/markdown_svg.go:1668— textmeasure.fitMarkdownTableColumns has cyclomatic complexity 19 (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.
markdownPainter.atomizeInlineTokens (cyclomatic 19) lib/textmeasure/markdown_svg.go:1191— markdownPainter.atomizeInlineTokens has cyclomatic complexity 19 (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.
run.fingerprints (cyclomatic 19) ci/nonlayout-perf/run.py:142— run.fingerprints has cyclomatic complexity 19 (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.
d2ast.RawString (cyclomatic 18) d2ast/d2ast.go:1563— d2ast.RawString 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.
pagedRenderer.render (cyclomatic 18) d2cli/paged.go:124— pagedRenderer.render has cyclomatic complexity 18 (threshold 15). Of this number, 12 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.
compiler.compileLegend (cyclomatic 18) d2compiler/compile.go:256— compiler.compileLegend 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 is NOT this file's highest cyclomatic complexity: d2compiler.compileStyleFieldInit (cyclomatic 21) 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 function is counted neither in this dimension's figures nor in its score.
compiler.compileEdgeMap (cyclomatic 18) d2compiler/compile.go:1247— compiler.compileEdgeMap 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 is NOT this file's highest cyclomatic complexity: d2compiler.compileStyleFieldInit (cyclomatic 21) 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 function is counted neither in this dimension's figures nor in its score.
compiler.compileClass (cyclomatic 18) d2compiler/compile.go:1385— compiler.compileClass 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 is NOT this file's highest cyclomatic complexity: d2compiler.compileStyleFieldInit (cyclomatic 21) 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 function is counted neither in this dimension's figures nor in its score.
d2exporter.toShape (cyclomatic 18) d2exporter/export.go:209— d2exporter.toShape 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.
Object.ShiftDescendants (cyclomatic 18) d2graph/layout.go:103— Object.ShiftDescendants has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 5 of the 18 points are its own statements and the rest belongs to one function literal inside it that branches (line 119). 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.
d2ir.Compile (cyclomatic 18) REDACTED:109— d2ir.Compile 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.
Map.createEdge2 (cyclomatic 18) REDACTED:1846— Map.createEdge2 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.
Map.FindBoardRoot (cyclomatic 18) REDACTED:2405— Map.FindBoardRoot 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.
astCloner.cloneArray (cyclomatic 18) d2ir/import_cache.go:91— astCloner.cloneArray 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.
gridDiagram.layoutEvenly (cyclomatic 18) d2layouts/d2grid/layout.go:233— gridDiagram.layoutEvenly has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 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.
sequenceDiagram.adjustGroupLabel (cyclomatic 18) d2layouts/d2sequence/sequence_diagram.go:313— sequenceDiagram.adjustGroupLabel 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.
Graph.restoreEdgeAbductions (cyclomatic 18) d2layouts/d2talalayout/internal/layoutgraph/layout.go:72— Graph.restoreEdgeAbductions 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.
packing.blocksRoutesWithDeltasGuarded (cyclomatic 18) d2layouts/d2talalayout/internal/packing/binpack.go:1129— packing.blocksRoutesWithDeltasGuarded 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.
packing.binPackHasExternalConnection (cyclomatic 18) d2layouts/d2talalayout/internal/packing/guard.go:86— packing.binPackHasExternalConnection 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.
packing.routedContainerRoundedCornersStayInsideShrink (cyclomatic 18) d2layouts/d2talalayout/internal/packing/routed_container.go:271— packing.routedContainerRoundedCornersStayInsideShrink 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.
packing.routedContainerEndpointKeepsSides (cyclomatic 18) d2layouts/d2talalayout/internal/packing/routed_container.go:435— packing.routedContainerEndpointKeepsSides has cyclomatic complexity 18 (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.
sizelessOptimizer.optimizeGuarded (cyclomatic 18) REDACTED:161— sizelessOptimizer.optimizeGuarded 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.
sizelessOptimizer.bestSwapCandidateGuarded (cyclomatic 18) REDACTED:479— sizelessOptimizer.bestSwapCandidateGuarded has cyclomatic complexity 18 (threshold 15). Of this number, 13 points are the body's own statements and 5 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.
routing.changedRouteIsClear (cyclomatic 18) d2layouts/d2talalayout/internal/routing/port_interior_balance.go:87— routing.changedRouteIsClear 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.
routing.fixedOverlapsForRoute (cyclomatic 18) d2layouts/d2talalayout/internal/routing/route_search_guard.go:304— routing.fixedOverlapsForRoute 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.
routing.refineEdgeGuarded (cyclomatic 18) d2layouts/d2talalayout/internal/routing/swap_ports.go:248— routing.refineEdgeGuarded 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.
ovgEdgeRouter.fillPathGuarded (cyclomatic 18) d2layouts/d2talalayout/internal/routing/slingshot.go:413— ovgEdgeRouter.fillPathGuarded 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.
trees.treeContainerRDFSOrder (cyclomatic 18) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:20— trees.treeContainerRDFSOrder 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.
layoutguard.CheckGraph (cyclomatic 18) d2layouts/internal/layoutguard/graph.go:31— layoutguard.CheckGraph 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.
d2oracle.deleteObjField (cyclomatic 18) d2oracle/edit.go:1476— d2oracle.deleteObjField 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.
d2oracle._updateImport (cyclomatic 18) d2oracle/edit.go:3354— d2oracle._updateImport 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.
d2isometricimg.nativeSolidContactRoutes (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/solid_contacts.go:79— d2isometricimg.nativeSolidContactRoutes has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 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.
d2isometricimg.nativeUprightContact (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/solid_contacts.go:151— d2isometricimg.nativeUprightContact 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.
d2isometricimg.nativeQueueContact (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/solid_contacts.go:218— d2isometricimg.nativeQueueContact has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 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.
nativeScene.Frame (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/geometry.go:687— nativeScene.Frame 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.
nativeScene.frameRaster (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/source_panels.go:281— nativeScene.frameRaster 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.
meshBuilder.classicInkFace (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/native_edges.go:594— meshBuilder.classicInkFace has cyclomatic complexity 18 (threshold 15). Of this number, 13 points are the body's own statements and 5 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.
meshBuilder.addDocumentLinks (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/page.go:246— meshBuilder.addDocumentLinks 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.
Raster.rasterPrepareOpacityGroups (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/opacity_groups.go:60— Raster.rasterPrepareOpacityGroups has cyclomatic complexity 18 (threshold 15). Of this number, 10 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.
Raster.drawOpacityGroup (cyclomatic 18) d2renderers/d2isometric/d2isometricimg/opacity_groups.go:146— Raster.drawOpacityGroup 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.
d2raster.renderFilteredEffectNode (cyclomatic 18) d2renderers/d2raster/effects.go:718— d2raster.renderFilteredEffectNode 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.
d2raster.compositeCOLRv1SoftLightLayer (cyclomatic 18) d2renderers/d2raster/effects.go:1391— d2raster.compositeCOLRv1SoftLightLayer 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.
d2raster.compositeLayerOverOpaquePartialPrefix (cyclomatic 18) d2renderers/d2raster/effects.go:1689— d2raster.compositeLayerOverOpaquePartialPrefix 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.
d2raster.prepareRadialGradient (cyclomatic 18) d2renderers/d2raster/gradient.go:200— d2raster.prepareRadialGradient has cyclomatic complexity 18 (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.
d2raster.drawDirectPatternMaskPixels (cyclomatic 18) d2renderers/d2raster/gradient.go:1022— d2raster.drawDirectPatternMaskPixels has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 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.
d2raster.validateRasterAsset (cyclomatic 18) d2renderers/d2raster/image.go:64— d2raster.validateRasterAsset 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. This is NOT this file's highest cyclomatic complexity: d2raster.nativeRasterImageOrigin (cyclomatic 19) 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 function is counted neither in this dimension's figures nor in its score.
retainedVectorValidator.pattern (cyclomatic 18) d2renderers/d2raster/vector_validation.go:633— retainedVectorValidator.pattern 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.
d2scene.PrimitiveBounds (cyclomatic 18) d2renderers/d2scene/primitive.go:128— d2scene.PrimitiveBounds 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.
legendLayout.expandViewBox (cyclomatic 18) d2renderers/d2scenebuild/legend.go:293— legendLayout.expandViewBox 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.
svgImporter.compileUse (cyclomatic 18) d2renderers/d2svgimport/compile.go:343— svgImporter.compileUse 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.
transformParser.parse (cyclomatic 18) d2renderers/d2svgimport/transform.go:49— transformParser.parse 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.
fontface.colrv1ClipBounds (cyclomatic 18) d2renderers/internal/fontface/face.go:603— fontface.colrv1ClipBounds has cyclomatic complexity 18 (threshold 15). Of this number, 15 points are the body's own statements and 3 belong to one function literal inside it that branches. 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.
rasterimage.inspectGIF (cyclomatic 18) internal/rasterimage/firstframe.go:232— rasterimage.inspectGIF 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.
testutil.orderPDFImagesByPage (cyclomatic 18) internal/testutil/pdf.go:149— testutil.orderPDFImagesByPage 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.
textmeasure.ReplaceSubstitutionsMarkdownBounded (cyclomatic 18) lib/textmeasure/substitutions.go:24— textmeasure.ReplaceSubstitutionsMarkdownBounded has cyclomatic complexity 18 (threshold 15). Of this number, 12 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.
textmeasure.newMarkdownSubstitutionMatcher (cyclomatic 18) lib/textmeasure/substitutions.go:139— textmeasure.newMarkdownSubstitutionMatcher 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.
fewOpaqueBucket.split (cyclomatic 18) lib/xgif/xgif.go:246— fewOpaqueBucket.split has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 belong to one function literal inside it that branches. 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.
main.verifyChecksums (cyclomatic 17) ci/release/releasetool/main.go:512— main.verifyChecksums 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.
d2cli.isometricImageOptions (cyclomatic 17) d2cli/isometric_image.go:19— d2cli.isometricImageOptions has cyclomatic complexity 17 (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.
d2cli.relink (cyclomatic 17) d2cli/main.go:817— d2cli.relink 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.
d2cli.renderGIFBoardFrames (cyclomatic 17) d2cli/raster.go:402— d2cli.renderGIFBoardFrames has cyclomatic complexity 17 (threshold 15). Of this number, 15 points are the body's own statements and 2 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.
compiler.validateBoardLinks (cyclomatic 17) d2compiler/compile.go:1726— compiler.validateBoardLinks 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. This is NOT this file's highest cyclomatic complexity: d2compiler.compileStyleFieldInit (cyclomatic 21) 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 function is counted neither in this dimension's figures nor in its score.
Graph.IDA (cyclomatic 17) d2graph/d2graph.go:92— Graph.IDA 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.
compiler.compileKey (cyclomatic 17) REDACTED:1161— compiler.compileKey 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.
compiler.applyLazyGlobs (cyclomatic 17) REDACTED:1254— compiler.applyLazyGlobs has cyclomatic complexity 17 (threshold 15). 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, 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.
d2ir.walkComposite (cyclomatic 17) REDACTED:753— d2ir.walkComposite 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.
d2elklayout.adjustPadding (cyclomatic 17) d2layouts/d2elklayout/layout.go:1061— d2elklayout.adjustPadding has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
d2layouts.ExtractSubgraph (cyclomatic 17) d2layouts/d2layouts.go:637— d2layouts.ExtractSubgraph has cyclomatic complexity 17 (threshold 15). 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, 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.
d2talalayout.coordinateLocalSeeds (cyclomatic 17) d2layouts/d2talalayout/layout.go:169— d2talalayout.coordinateLocalSeeds has cyclomatic complexity 17 (threshold 15). 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, 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.
engine.preserveCompoundInteriors (cyclomatic 17) d2layouts/d2talalayout/internal/engine/compound_routes.go:38— engine.preserveCompoundInteriors 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.
grouping.SequenceDefiningEdges (cyclomatic 17) REDACTED:80— grouping.SequenceDefiningEdges 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.
joinPositionJournal.moveWithChildren (cyclomatic 17) d2layouts/d2talalayout/internal/grouping/join.go:46— joinPositionJournal.moveWithChildren 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.
hierarchy.Assign (cyclomatic 17) d2layouts/d2talalayout/internal/hierarchy/discovery.go:38— hierarchy.Assign has cyclomatic complexity 17 (threshold 15). 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, 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.
GraphState.captureGeometryStateContext (cyclomatic 17) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:278— GraphState.captureGeometryStateContext 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.
packing.routedContainerRoutesStayInsideShrink (cyclomatic 17) d2layouts/d2talalayout/internal/packing/routed_container.go:216— packing.routedContainerRoutesStayInsideShrink 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.
placement.inflateAlongAxis (cyclomatic 17) d2layouts/d2talalayout/internal/placement/compaction.go:330— placement.inflateAlongAxis 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.
placement.nearestConnectedAhead (cyclomatic 17) d2layouts/d2talalayout/internal/placement/gapreduction.go:197— placement.nearestConnectedAhead 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.
placement.withHubSpokesSuppressed (cyclomatic 17) REDACTED:57— placement.withHubSpokesSuppressed 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.
placement.newSizelessOptimizer (cyclomatic 17) REDACTED:29— placement.newSizelessOptimizer 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.
sizelessOptimizer.moveNodeToBestGuarded (cyclomatic 17) REDACTED:403— sizelessOptimizer.moveNodeToBestGuarded has cyclomatic complexity 17 (threshold 15). 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, 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.
placementcost.clusterExactlyTwoExternalConnectedNodes (cyclomatic 17) d2layouts/d2talalayout/internal/placementcost/cluster.go:5— placementcost.clusterExactlyTwoExternalConnectedNodes 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.
routing.edgesIntersect (cyclomatic 17) d2layouts/d2talalayout/internal/routing/swap_ports.go:200— routing.edgesIntersect has cyclomatic complexity 17 (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.
OVG.isMisdirectedPortPair (cyclomatic 17) REDACTED:1355— OVG.isMisdirectedPortPair 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.
ovgEdgeRouter.generateRoutes (cyclomatic 17) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:349— ovgEdgeRouter.generateRoutes has cyclomatic complexity 17 (threshold 15). Of this number, 15 points are the body's own statements and 2 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.
Route.isEntireColinear (cyclomatic 17) d2layouts/d2talalayout/internal/routing/route.go:34— Route.isEntireColinear 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.
trees.normalizedAspectRatio (cyclomatic 17) d2layouts/d2talalayout/internal/trees/layout.go:701— trees.normalizedAspectRatio 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.
d2oracle.deleteMapField (cyclomatic 17) d2oracle/edit.go:1417— d2oracle.deleteMapField 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.
parser.parseKey (cyclomatic 17) d2parser/parse.go:1035— parser.parseKey has cyclomatic complexity 17 (threshold 15). Of this number, 13 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.
asciishapes.DrawCallout (cyclomatic 17) d2renderers/d2ascii/asciishapes/callout.go:5— asciishapes.DrawCallout has cyclomatic complexity 17 (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.
asciishapes.DrawHex (cyclomatic 17) d2renderers/d2ascii/asciishapes/hexagon.go:7— asciishapes.DrawHex has cyclomatic complexity 17 (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.
d2isometricimg.richSourceSize (cyclomatic 17) d2renderers/d2isometric/d2isometricimg/rich_labels.go:165— d2isometricimg.richSourceSize has cyclomatic complexity 17 (threshold 15). Of this number, 15 points are the body's own statements and 2 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.
meshBuilder.node (cyclomatic 17) d2renderers/d2isometric/d2isometricimg/geometry.go:630— meshBuilder.node 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.
surfaceIconPainter.resolve (cyclomatic 17) d2renderers/d2isometric/d2isometricimg/surface_icons.go:213— surfaceIconPainter.resolve 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.
nativeSurfaceSVGWriter.colorPaint (cyclomatic 17) d2renderers/d2isometric/d2isometricimg/vector_surface_color.go:26— nativeSurfaceSVGWriter.colorPaint has cyclomatic complexity 17 (threshold 15). 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, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
d2raster.sampleShadowAlphaRGBA (cyclomatic 17) d2renderers/d2raster/filter.go:1131— d2raster.sampleShadowAlphaRGBA has cyclomatic complexity 17 (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. This shape REPEATS in the file: one other method here (d2raster.sampleShadowAlphaImage) 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. This is NOT this file's highest cyclomatic complexity: d2raster.exactIntegerTranslatedBounds (cyclomatic 21) 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 function is counted neither in this dimension's figures nor in its score.
d2raster.sampleShadowAlphaImage (cyclomatic 17) d2renderers/d2raster/filter.go:1163— d2raster.sampleShadowAlphaImage has cyclomatic complexity 17 (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. This shape REPEATS in the file: one other method here (d2raster.sampleShadowAlphaRGBA) 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. This is NOT this file's highest cyclomatic complexity: d2raster.exactIntegerTranslatedBounds (cyclomatic 21) 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 function is counted neither in this dimension's figures nor in its score.
d2raster.roundedRectSubpaths (cyclomatic 17) d2renderers/d2raster/geometry.go:176— d2raster.roundedRectSubpaths has cyclomatic complexity 17 (threshold 15). Of this number, 14 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.
patternCollector.node (cyclomatic 17) d2renderers/d2raster/pattern.go:346— patternCollector.node 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.
preflight.primitive (cyclomatic 17) d2renderers/d2raster/raster.go:1186— preflight.primitive 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. This is NOT this file's highest cyclomatic complexity: d2raster.validateOptions (cyclomatic 23) 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 function is counted neither in this dimension's figures nor in its score.
retainedVectorValidator.animations (cyclomatic 17) d2renderers/d2raster/vector_validation.go:231— retainedVectorValidator.animations 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.
retainedVectorValidator.primitive (cyclomatic 17) d2renderers/d2raster/vector_validation.go:283— retainedVectorValidator.primitive has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function taking that case's concrete type, so the dispatch reads one line per case. These arms are selected by TYPE rather than by value, so there is no key a lookup table could be built on; where you own the matched types, giving them one shared interface method and calling that is the form a table would have taken, and where you do not, keep the cases — they stay explicit and reviewable.
retainedVectorValidator.text (cyclomatic 17) d2renderers/d2raster/vector_validation.go:392— retainedVectorValidator.text 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.
Path.transformedGeometryBounds (cyclomatic 17) d2renderers/d2scene/path.go:99— Path.transformedGeometryBounds 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.
d2scenebuild.validateShapeEffectIntegerBounds (cyclomatic 17) d2renderers/d2scenebuild/shape_effects.go:202— d2scenebuild.validateShapeEffectIntegerBounds has cyclomatic complexity 17 (threshold 15). Of this number, 15 points are the body's own statements and 2 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.
d2scenebuild.sketchStreakRoot (cyclomatic 17) d2renderers/d2scenebuild/sketch_shapes.go:866— d2scenebuild.sketchStreakRoot 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.
builder.resolveImageAsset (cyclomatic 17) d2renderers/d2scenebuild/assets.go:103— builder.resolveImageAsset 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.
d2svg.validateRenderPaints (cyclomatic 17) d2renderers/d2svg/paint_validation.go:16— d2svg.validateRenderPaints 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.
d2svgimport.inspectEmbeddedWebP (cyclomatic 17) d2renderers/d2svgimport/image.go:583— d2svgimport.inspectEmbeddedWebP 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.
svgImporter.ignoredNamespacedAttribute (cyclomatic 17) d2renderers/d2svgimport/boilerplate.go:203— svgImporter.ignoredNamespacedAttribute has cyclomatic complexity 17 (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.
svgImporter.pointCommands (cyclomatic 17) d2renderers/d2svgimport/geometry.go:195— svgImporter.pointCommands 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.
svgImporter.compileEmbeddedImage (cyclomatic 17) d2renderers/d2svgimport/image.go:21— svgImporter.compileEmbeddedImage 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.
transformParser.arguments (cyclomatic 17) d2renderers/d2svgimport/transform.go:103— transformParser.arguments 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.
BundledFaceSource.SupportsRenderableRune (cyclomatic 17) d2renderers/internal/fontface/face.go:191— BundledFaceSource.SupportsRenderableRune 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.
Diagram.appendCorpus (cyclomatic 17) d2target/d2target.go:702— Diagram.appendCorpus has cyclomatic complexity 17 (threshold 15). 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.
rasterimage.Config (cyclomatic 17) internal/rasterimage/firstframe.go:28— rasterimage.Config 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.
rasterimage.parseEXIFOrientation (cyclomatic 17) internal/rasterimage/jpeg_orientation.go:69— rasterimage.parseEXIFOrientation 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.
testutil.InspectGIF (cyclomatic 17) internal/testutil/gif.go:88— testutil.InspectGIF 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.
imageasset.uriScheme (cyclomatic 17) lib/imageasset/resolve.go:317— imageasset.uriScheme has cyclomatic complexity 17 (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.
textmeasure.normalizeMarkdownWhitespaceTree (cyclomatic 17) lib/textmeasure/markdown.go:241— textmeasure.normalizeMarkdownWhitespaceTree has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 2 of the 17 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 266, 300, 257, …). 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.
markdownPainter.collectInlineTokens (cyclomatic 17) lib/textmeasure/markdown_svg.go:1312— markdownPainter.collectInlineTokens 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.
Ruler.scaleUnicodeFallback (cyclomatic 17) lib/textmeasure/textmeasure.go:322— Ruler.scaleUnicodeFallback has cyclomatic complexity 17 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
xgif.AnimateCenteredOpaquePalettedImagesWithLimit (cyclomatic 17) lib/xgif/encode.go:38— xgif.AnimateCenteredOpaquePalettedImagesWithLimit 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.
paletteTree.nearest (cyclomatic 17) lib/xgif/xgif.go:722— paletteTree.nearest 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.
d2cli.planBoardOutput (cyclomatic 16) d2cli/board_output.go:160— d2cli.planBoardOutput 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.
d2cli.indexPagedBoards (cyclomatic 16) d2cli/paged.go:344— d2cli.indexPagedBoards has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 4 of the 16 points are its own statements and the rest belongs to one function literal inside it that branches (line 355). 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.
boardOutputWorkspace.preflightMerge (cyclomatic 16) d2cli/board_output.go:433— boardOutputWorkspace.preflightMerge 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 literal inside it that branches (line 435). 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.
rasterPNGBandEncoder.append (cyclomatic 16) d2cli/raster_png_encoder.go:321— rasterPNGBandEncoder.append has cyclomatic complexity 16 (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.
Object.Text (cyclomatic 16) d2graph/d2graph.go:659— Object.Text has cyclomatic complexity 16 (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.
Object.FindEdges (cyclomatic 16) d2graph/d2graph.go:816— Object.FindEdges has cyclomatic complexity 16 (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.
compiler._ampersandPropertyFilter (cyclomatic 16) REDACTED:1608— compiler._ampersandPropertyFilter 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.
d2ir.canSelectImportNode (cyclomatic 16) d2ir/import_cache.go:407— d2ir.canSelectImportNode 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.
Map.ensureFieldMode (cyclomatic 16) REDACTED:1179— Map.ensureFieldMode 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.
RefContext.Equal (cyclomatic 16) REDACTED:974— RefContext.Equal 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.
d2dagrelayout.positionLabelsIcons (cyclomatic 16) d2layouts/d2dagrelayout/layout.go:577— d2dagrelayout.positionLabelsIcons 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.
d2elklayout.positionLabelsIcons (cyclomatic 16) d2layouts/d2elklayout/layout.go:1153— d2elklayout.positionLabelsIcons 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.
d2talalayout.validateCompletedGraph (cyclomatic 16) d2layouts/d2talalayout/result_validate.go:421— d2talalayout.validateCompletedGraph 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.
d2talalayout.validateResultEdge (cyclomatic 16) d2layouts/d2talalayout/result_validate.go:510— d2talalayout.validateResultEdge 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.
grouping.hasNodeID (cyclomatic 16) REDACTED:464— grouping.hasNodeID has cyclomatic complexity 16 (threshold 15). Of this number, 13 points are the body's own statements and 3 belong to 2 function literals inside it that branch. 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.
hierarchy.orderCompoundInterfaces (cyclomatic 16) REDACTED:240— hierarchy.orderCompoundInterfaces has cyclomatic complexity 16 (threshold 15). Of this number, 13 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.
Edge.stylesMatchOneWay (cyclomatic 16) d2layouts/d2talalayout/internal/layoutgraph/edge.go:51— Edge.stylesMatchOneWay 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.
Graph.buildNodeToTreeGuarded (cyclomatic 16) d2layouts/d2talalayout/internal/layoutgraph/tree_access.go:48— Graph.buildNodeToTreeGuarded 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.
Node.isVisibilityGraphCandidate (cyclomatic 16) d2layouts/d2talalayout/internal/layoutgraph/node.go:1359— Node.isVisibilityGraphCandidate 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.
packing.binPackPositionContainerChildren (cyclomatic 16) d2layouts/d2talalayout/internal/packing/guard.go:274— packing.binPackPositionContainerChildren 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.
placement.optimizerMoveNodeAbs (cyclomatic 16) d2layouts/d2talalayout/internal/placement/optimization_guard.go:684— placement.optimizerMoveNodeAbs 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.
placementcost.GraphEdgeCrossings (cyclomatic 16) d2layouts/d2talalayout/internal/placementcost/graph.go:301— placementcost.GraphEdgeCrossings 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.
quality.sortSharedSegments (cyclomatic 16) d2layouts/d2talalayout/internal/quality/labels.go:512— quality.sortSharedSegments 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.
quality.evaluateWithAreaLimit (cyclomatic 16) d2layouts/d2talalayout/internal/quality/scoring.go:21— quality.evaluateWithAreaLimit 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.
routing.crosshatchWithWorkLimit (cyclomatic 16) d2layouts/d2talalayout/internal/routing/coordinator.go:1826— routing.crosshatchWithWorkLimit has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to one function literal inside it that branches (line 1827). 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.
routing.shortcutLabelBoxes (cyclomatic 16) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:518— routing.shortcutLabelBoxes 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.
routing.preferLaunchingVertically (cyclomatic 16) d2layouts/d2talalayout/internal/routing/slingshot.go:340— routing.preferLaunchingVertically 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.
trees.dominantTreeEdgeDirection (cyclomatic 16) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:158— trees.dominantTreeEdgeDirection 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.
trees.buildNodeToTreeGuarded (cyclomatic 16) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:651— trees.buildNodeToTreeGuarded 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.
d2lsp.GetRefRanges (cyclomatic 16) d2lsp/d2lsp.go:14— d2lsp.GetRefRanges 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.
parser.parseArray (cyclomatic 16) d2parser/parse.go:1603— parser.parseArray 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.
parser.parseValue (cyclomatic 16) d2parser/parse.go:1728— parser.parseValue has cyclomatic complexity 16 (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.
asciiroute.drawConnectionLabel (cyclomatic 16) d2renderers/d2ascii/asciiroute/labels.go:87— asciiroute.drawConnectionLabel 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.
asciishapes.DrawRect (cyclomatic 16) d2renderers/d2ascii/asciishapes/rectangle.go:11— asciishapes.DrawRect 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.
d2fonts.readBoundedFontFile (cyclomatic 16) d2renderers/d2fonts/fallback.go:549— d2fonts.readBoundedFontFile has cyclomatic complexity 16 (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.
d2fonts.fallbackPathPriority (cyclomatic 16) d2renderers/d2fonts/fallback.go:725— d2fonts.fallbackPathPriority has cyclomatic complexity 16 (threshold 15). Of this number, 14 points are the body's own statements and 2 belong to one function literal inside it that branches. 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.
d2isometricimg.sceneOutputDensity (cyclomatic 16) d2renderers/d2isometric/d2isometricimg/framing.go:208— d2isometricimg.sceneOutputDensity has cyclomatic complexity 16 (threshold 15). 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.
d2isometricimg.renderGIF (cyclomatic 16) d2renderers/d2isometric/d2isometricimg/gif.go:20— d2isometricimg.renderGIF 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.
d2isometricimg.CaptureFrames (cyclomatic 16) d2renderers/d2isometric/d2isometricimg/render.go:117— d2isometricimg.CaptureFrames 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.
d2isometricimg.rasterNativeSurfaceDocument (cyclomatic 16) d2renderers/d2isometric/d2isometricimg/surface_document.go:108— d2isometricimg.rasterNativeSurfaceDocument 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.
d2isometricimg.svgPolygonPath (cyclomatic 16) d2renderers/d2isometric/d2isometricimg/svg.go:119— d2isometricimg.svgPolygonPath 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.
d2isometricimg.svgOrderComponents (cyclomatic 16) d2renderers/d2isometric/d2isometricimg/svg_order.go:394— d2isometricimg.svgOrderComponents 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.
meshBuilder.prepareGradientMaterials (cyclomatic 16) d2renderers/d2isometric/d2isometricimg/gradient_paints.go:58— meshBuilder.prepareGradientMaterials 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.
d2raster.drawDirectPatternCoverage (cyclomatic 16) d2renderers/d2raster/gradient.go:723— d2raster.drawDirectPatternCoverage has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 3 of the 16 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 738, 728). 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.
d2raster.renderNode (cyclomatic 16) d2renderers/d2raster/raster.go:1536— d2raster.renderNode 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. This is NOT this file's highest cyclomatic complexity: d2raster.validateOptions (cyclomatic 23) 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 function is counted neither in this dimension's figures nor in its score.
d2raster.drawPrimitive (cyclomatic 16) d2renderers/d2raster/raster.go:1559— d2raster.drawPrimitive has cyclomatic complexity 16 (threshold 15). Of this number, 14 points are the body's own statements and 2 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. This is NOT this file's highest cyclomatic complexity: d2raster.validateOptions (cyclomatic 23) 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 function is counted neither in this dimension's figures nor in its score.
preflight.vectorImage (cyclomatic 16) d2renderers/d2raster/image.go:266— preflight.vectorImage has cyclomatic complexity 16 (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 is NOT this file's highest cyclomatic complexity: d2raster.nativeRasterImageOrigin (cyclomatic 19) 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 function is counted neither in this dimension's figures nor in its score.
RenderSession.memoizedCacheKeyWithDigest (cyclomatic 16) REDACTED:202— RenderSession.memoizedCacheKeyWithDigest 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.
retainedVectorValidator.image (cyclomatic 16) d2renderers/d2raster/vector_validation.go:479— retainedVectorValidator.image 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.
retainedVectorValidator.gradientCommon (cyclomatic 16) d2renderers/d2raster/vector_validation.go:716— retainedVectorValidator.gradientCommon 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.
d2scenebuild.validateConnectionNumbers (cyclomatic 16) d2renderers/d2scenebuild/build.go:1162— d2scenebuild.validateConnectionNumbers has cyclomatic complexity 16 (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.
builder.buildCodeTextRuns (cyclomatic 16) d2renderers/d2scenebuild/code_shape.go:115— builder.buildCodeTextRuns 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.
builder.addLinkRegion (cyclomatic 16) d2renderers/d2scenebuild/metadata.go:202— builder.addLinkRegion 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.
builder.buildClassContents (cyclomatic 16) d2renderers/d2scenebuild/special_shapes.go:69— builder.buildClassContents 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.
builder.buildSQLTableContents (cyclomatic 16) d2renderers/d2scenebuild/special_shapes.go:184— builder.buildSQLTableContents 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.
svgImporter.elementName (cyclomatic 16) d2renderers/d2svgimport/import.go:731— svgImporter.elementName 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.
svgImporter.simpleClassSelector (cyclomatic 16) d2renderers/d2svgimport/stylesheet.go:153— svgImporter.simpleClassSelector 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.
pathParser.parse (cyclomatic 16) d2renderers/d2svgimport/path.go:80— pathParser.parse 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. This is NOT this file's highest cyclomatic complexity: pathParser.append (cyclomatic 19) 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 function is counted neither in this dimension's figures nor in its score.
clusterFaceResolver.supports (cyclomatic 16) d2renderers/internal/fontface/shaping.go:445— clusterFaceResolver.supports 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.
d2target.validateRenderConnectionNumbers (cyclomatic 16) d2target/render_validation.go:308— d2target.validateRenderConnectionNumbers has cyclomatic complexity 16 (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.
Resolver.Resolve (cyclomatic 16) lib/imageasset/resolve.go:72— Resolver.Resolve 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.
GoFPDF.AddPDFPage (cyclomatic 16) lib/pdf/pdf.go:71— GoFPDF.AddPDFPage 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.
Presentation.writeTo (cyclomatic 16) lib/pptx/pptx.go:203— Presentation.writeTo 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.
svg.ParseAttributes (cyclomatic 16) lib/svg/markup.go:81— svg.ParseAttributes 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.
textmeasure.collectMarkdownTableRows (cyclomatic 16) lib/textmeasure/markdown_svg.go:1738— textmeasure.collectMarkdownTableRows has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 2 function literals inside it that branch (lines 1753, 1740). 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.
textmeasure.markdownListMarker (cyclomatic 16) lib/textmeasure/markdown_svg.go:1780— textmeasure.markdownListMarker 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.
paletteTree.nearestRGBA (cyclomatic 16) lib/xgif/xgif.go:796— paletteTree.nearestRGBA 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.
D12 · Dependency Hygiene· Dependency pinned to a stale untagged commit · ×1
Dependency pinned to a stale untagged commit: github.com/ericpauley/go-quantize — Direct dependency `github.com/ericpauley/go-quantize` is required at `v0.0.0-20200331213906-ae555eb2afa4` in REDACTED — a pseudo-version, which pins an UNTAGGED commit from 2020-03-31, 6.6 years ago. The pin itself is exact, so this is not a reproducibility defect, and it is not a claim that the module is unmaintained. What it says is that this repository tracks no RELEASE of `github.com/ericpauley/go-quantize` and has not moved this requirement in 6.6 years: every fix the module has published since that commit — including any security fix — is absent from this build, whether the module went quiet or moved on without you. Check whether `github.com/ericpauley/go-quantize` now publishes tagged releases and move the requirement to one; if it publishes none, re-pin to a current commit.
placementcost.evaluateNodeEdgeLength (cognitive 819) d2layouts/d2talalayout/internal/placementcost/edge_length.go:345— placementcost.evaluateNodeEdgeLength has cognitive complexity 819 (threshold 15). Drivers by points: if/else 152 (547 pts), match/switch 40 (205 pts), boolean chains 48, loops 7 (19 pts) (nesting depth added 572). Of this number, 547 points are the body's own statements and 272 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.
packing.packGuarded (cognitive 718) d2layouts/d2talalayout/internal/packing/binpack.go:65— packing.packGuarded has cognitive complexity 718 (threshold 15). Drivers by points: if/else 189 (563 pts), loops 56 (146 pts), boolean chains 6, match/switch 1 (3 pts) (nesting depth added 466). Of this number, 670 points are the body's own statements and 48 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.
ovgEdgeRouter.search (cognitive 683) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:558— ovgEdgeRouter.search has cognitive complexity 683 (threshold 15). Drivers by points: if/else 167 (576 pts), loops 18 (52 pts), boolean chains 37, match/switch 4 (18 pts) (nesting depth added 457). Of this number, 657 points are the body's own statements and 26 belong to 2 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.
layoutgraph.validateEngineGraph (cognitive 462) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:510— layoutgraph.validateEngineGraph has cognitive complexity 462 (threshold 15). Drivers by points: if/else 146 (349 pts), loops 47 (97 pts), boolean chains 8, match/switch 3 (8 pts) (nesting depth added 258). Of this number, 408 points are the body's own statements and 54 belong to 11 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.
d2oracle._set (cognitive 455) d2oracle/edit.go:327— d2oracle._set has cognitive complexity 455 (threshold 15). Drivers by points: if/else 110 (387 pts), loops 8 (26 pts), boolean chains 25, match/switch 4 (17 pts) (nesting depth added 308). Of this number, 445 points are the body's own statements and 10 belong to one function literal inside it that branches. 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.
placement.Dejitter (cognitive 421) d2layouts/d2talalayout/internal/placement/dejitter.go:16— placement.Dejitter has cognitive complexity 421 (threshold 15). Drivers by points: if/else 108 (352 pts), boolean chains 36, loops 11 (33 pts) (nesting depth added 266). Of this number, 389 points are the body's own statements and 32 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.
routing.balanceRegularEdgesGuarded (cognitive 384) d2layouts/d2talalayout/internal/routing/postprocess.go:70— routing.balanceRegularEdgesGuarded has cognitive complexity 384 (threshold 15). Drivers by points: if/else 80 (307 pts), loops 22 (64 pts), boolean chains 13 (nesting depth added 269). Of this number, 357 points are the body's own statements and 27 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.
placement.reduceGapToNeighbors (cognitive 369) d2layouts/d2talalayout/internal/placement/gapreduction.go:273— placement.reduceGapToNeighbors has cognitive complexity 369 (threshold 15). Drivers by points: if/else 108 (347 pts), loops 8 (16 pts), boolean chains 6 (nesting depth added 247). Of this number, 316 points are the body's own statements and 53 belong to 3 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.
d2oracle.move (cognitive 356) d2oracle/edit.go:1765— d2oracle.move has cognitive complexity 356 (threshold 15). Drivers by points: if/else 95 (297 pts), loops 14 (42 pts), boolean chains 17 (nesting depth added 230). 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.
d2dagrelayout.shiftReachableDownIndexed (cognitive 279) d2layouts/d2dagrelayout/layout.go:810— d2dagrelayout.shiftReachableDownIndexed has cognitive complexity 279 (threshold 15). Drivers by points: if/else 70 (214 pts), loops 17 (47 pts), boolean chains 18 (nesting depth added 174). Of this number, 61 points are the body's own statements and 218 belong to 3 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.
Ruler.measureMarkdownNode (cognitive 279) lib/textmeasure/markdown.go:330— Ruler.measureMarkdownNode has cognitive complexity 279 (threshold 15). Drivers by points: if/else 78 (220 pts), loops 9 (29 pts), boolean chains 22, match/switch 4 (8 pts) (nesting depth added 166). Of this number, 270 points are the body's own statements and 9 belong to one function literal inside it that branches. 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.
ovgEdgeRouter.findLShapedRoute (cognitive 277) d2layouts/d2talalayout/internal/routing/slingshot.go:666— ovgEdgeRouter.findLShapedRoute has cognitive complexity 277 (threshold 15). Drivers by points: if/else 47 (230 pts), loops 10 (40 pts), boolean chains 7 (nesting depth added 213). 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.
routing.fixClusterEdgeBranchingGuarded (cognitive 270) d2layouts/d2talalayout/internal/routing/postprocess.go:472— routing.fixClusterEdgeBranchingGuarded has cognitive complexity 270 (threshold 15). Drivers by points: if/else 61 (238 pts), loops 10 (29 pts), boolean chains 2, jumps 1 (nesting depth added 196). 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.
ovgEdgeRouter.findSShapedRoute (cognitive 264) d2layouts/d2talalayout/internal/routing/slingshot.go:891— ovgEdgeRouter.findSShapedRoute has cognitive complexity 264 (threshold 15). Drivers by points: if/else 56 (218 pts), loops 13 (39 pts), boolean chains 5, match/switch 1 (2 pts) (nesting depth added 189). Of this number, 259 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.
routing.routeLineChecked (cognitive 257) d2layouts/d2talalayout/internal/routing/coordinator.go:844— routing.routeLineChecked has cognitive complexity 257 (threshold 15). Drivers by points: if/else 86 (237 pts), loops 10 (16 pts), boolean chains 4 (nesting depth added 157). Of this number, 252 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.
d2talalayout.translateGraph (cognitive 251) d2layouts/d2talalayout/adapter.go:116— d2talalayout.translateGraph has cognitive complexity 251 (threshold 15). Drivers by points: if/else 87 (216 pts), boolean chains 19, loops 8 (16 pts) (nesting depth added 137). 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.
d2dagrelayout.fitPadding (cognitive 248) d2layouts/d2dagrelayout/layout.go:1385— d2dagrelayout.fitPadding has cognitive complexity 248 (threshold 15). Drivers by points: if/else 53 (172 pts), loops 12 (45 pts), match/switch 8 (22 pts), boolean chains 9 (nesting depth added 166). 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.
d2svg.drawShape (cognitive 248) d2renderers/d2svg/d2svg.go:1688— d2svg.drawShape has cognitive complexity 248 (threshold 15). Drivers by points: if/else 91 (208 pts), loops 7 (26 pts), boolean chains 11, match/switch 2 (3 pts) (nesting depth added 137). 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.
compiler.resolveSubstitutions (cognitive 243) REDACTED:415— compiler.resolveSubstitutions has cognitive complexity 243 (threshold 15). Drivers by points: if/else 44 (186 pts), loops 8 (33 pts), match/switch 4 (16 pts), boolean chains 8 (nesting depth added 179). 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.
builder.resolveFontFallbacks (cognitive 243) d2renderers/d2scenebuild/font_fallback.go:131— builder.resolveFontFallbacks has cognitive complexity 243 (threshold 15). Drivers by points: if/else 61 (189 pts), loops 18 (47 pts), boolean chains 7 (nesting depth added 157). Of this number, 241 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.
labeling.place (cognitive 231) d2layouts/d2talalayout/internal/labeling/placement.go:28— labeling.place has cognitive complexity 231 (threshold 15). Drivers by points: if/else 64 (198 pts), loops 12 (24 pts), boolean chains 9 (nesting depth added 146). Of this number, 229 points are the body's own statements and 2 belong to one function literal inside it that branches. 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.
graphjson.deserializeGraphContext (cognitive 226) REDACTED:1035— graphjson.deserializeGraphContext has cognitive complexity 226 (threshold 15). Drivers by points: if/else 74 (176 pts), loops 28 (39 pts), boolean chains 11 (nesting depth added 113). 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.
compiler._compileEdges (cognitive 212) REDACTED:2088— compiler._compileEdges has cognitive complexity 212 (threshold 15). Drivers by points: if/else 39 (167 pts), loops 6 (30 pts), boolean chains 15 (nesting depth added 152). 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.
grouping.AddClusters (cognitive 210) REDACTED:167— grouping.AddClusters has cognitive complexity 210 (threshold 15). Drivers by points: if/else 67 (163 pts), loops 20 (36 pts), boolean chains 11 (nesting depth added 112). Of this number, 155 points are the body's own statements and 55 belong to 5 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.
layoutgraph.validateCombineNodeTopology (cognitive 209) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:129— layoutgraph.validateCombineNodeTopology has cognitive complexity 209 (threshold 15). Drivers by points: if/else 73 (164 pts), loops 16 (42 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 118). Of this number, 169 points are the body's own statements and 40 belong to 9 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.
placementcost.nodeSymmetry (cognitive 192) d2layouts/d2talalayout/internal/placementcost/symmetry.go:94— placementcost.nodeSymmetry has cognitive complexity 192 (threshold 15). Drivers by points: if/else 55 (161 pts), loops 10 (22 pts), boolean chains 9 (nesting depth added 118). 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.
grouping.JoinDistancedClusters (cognitive 188) d2layouts/d2talalayout/internal/grouping/join.go:142— grouping.JoinDistancedClusters has cognitive complexity 188 (threshold 15). Drivers by points: if/else 65 (151 pts), loops 10 (24 pts), boolean chains 13 (nesting depth added 100). Of this number, 69 points are the body's own statements and 119 belong to 3 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.
d2isometricimg.classicInkSegments (cognitive 184) d2renderers/d2isometric/d2isometricimg/native_edges.go:102— d2isometricimg.classicInkSegments has cognitive complexity 184 (threshold 15). Drivers by points: if/else 47 (130 pts), loops 15 (29 pts), boolean chains 25 (nesting depth added 97). Of this number, 117 points are the body's own statements and 67 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.
packing.CombineSubgraphs (cognitive 178) d2layouts/d2talalayout/internal/packing/combine.go:92— packing.CombineSubgraphs has cognitive complexity 178 (threshold 15). Drivers by points: if/else 49 (132 pts), loops 20 (42 pts), boolean chains 4 (nesting depth added 105). Of this number, 138 points are the body's own statements and 40 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.
d2dagrelayout.adjustRankSpacing (cognitive 176) d2layouts/d2dagrelayout/layout.go:1123— d2dagrelayout.adjustRankSpacing has cognitive complexity 176 (threshold 15). Drivers by points: if/else 37 (131 pts), loops 14 (37 pts), boolean chains 8 (nesting depth added 117). 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.
d2elklayout.Layout (cognitive 166) d2layouts/d2elklayout/layout.go:257— d2elklayout.Layout has cognitive complexity 166 (threshold 15). Drivers by points: if/else 46 (104 pts), loops 16 (33 pts), boolean chains 17, match/switch 7 (12 pts) (nesting depth added 80). Of this number, 134 points are the body's own statements and 32 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.
d2isometricimg.svgVisibleFacesWithLimits (cognitive 165) REDACTED:343— d2isometricimg.svgVisibleFacesWithLimits has cognitive complexity 165 (threshold 15). Drivers by points: if/else 46 (121 pts), loops 12 (32 pts), boolean chains 12 (nesting depth added 95). Of this number, 139 points are the body's own statements and 26 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.
placementcost.prepareNodeEdgeLength (cognitive 162) d2layouts/d2talalayout/internal/placementcost/edge_length.go:142— placementcost.prepareNodeEdgeLength has cognitive complexity 162 (threshold 15). Drivers by points: if/else 45 (141 pts), loops 6 (14 pts), match/switch 1 (4 pts), boolean chains 3 (nesting depth added 107). 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.
d2isometricimg.nativeResolveLaneRoutes (cognitive 162) d2renderers/d2isometric/d2isometricimg/route_lanes.go:63— d2isometricimg.nativeResolveLaneRoutes has cognitive complexity 162 (threshold 15). Drivers by points: if/else 43 (124 pts), loops 13 (26 pts), boolean chains 12 (nesting depth added 94). Of this number, 153 points are the body's own statements and 9 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.
ovgEdgeSet.intersectsWithChecked (cognitive 161) d2layouts/d2talalayout/internal/routing/ovg_edge_set.go:128— ovgEdgeSet.intersectsWithChecked has cognitive complexity 161 (threshold 15). Drivers by points: if/else 45 (147 pts), loops 6 (14 pts) (nesting depth added 110). Of this number, 160 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.
placement.equidistanceNodeGuarded (cognitive 160) d2layouts/d2talalayout/internal/placement/equidistance.go:103— placement.equidistanceNodeGuarded has cognitive complexity 160 (threshold 15). Drivers by points: if/else 64 (127 pts), loops 11 (18 pts), boolean chains 15 (nesting depth added 70). Of this number, 145 points are the body's own statements and 15 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.
placement.swapOptimize (cognitive 159) d2layouts/d2talalayout/internal/placement/swap.go:60— placement.swapOptimize has cognitive complexity 159 (threshold 15). Drivers by points: if/else 51 (141 pts), boolean chains 15, loops 2 (3 pts) (nesting depth added 91). Of this number, 152 points are the body's own statements and 7 belong to 2 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.
Rasterizer.DrawRGBA (cognitive 157) REDACTED:491— Rasterizer.DrawRGBA has cognitive complexity 157 (threshold 15). Drivers by points: if/else 33 (104 pts), loops 12 (45 pts), boolean chains 8 (nesting depth added 104). Most of this is not in the body itself: 8 of the 157 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 507, 613, 576, …). 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.
d2cli.compile (cognitive 154) d2cli/main.go:452— d2cli.compile has cognitive complexity 154 (threshold 15). Drivers by points: if/else 68 (142 pts), boolean chains 11, match/switch 1 (nesting depth added 74). 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.
compiler._compileField (cognitive 154) REDACTED:1704— compiler._compileField has cognitive complexity 154 (threshold 15). Drivers by points: if/else 46 (119 pts), loops 4 (15 pts), match/switch 5 (13 pts), boolean chains 7 (nesting depth added 92). 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.
Transaction.buildPostStateOverlapCandidates (cognitive 152) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:824— Transaction.buildPostStateOverlapCandidates has cognitive complexity 152 (threshold 15). Drivers by points: if/else 42 (116 pts), loops 10 (22 pts), boolean chains 11, match/switch 1 (3 pts) (nesting depth added 88). Of this number, 144 points are the body's own statements and 8 belong to 2 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.
labeling.findBestEdgeLabelPosition (cognitive 149) d2layouts/d2talalayout/internal/labeling/placement.go:687— labeling.findBestEdgeLabelPosition has cognitive complexity 149 (threshold 15). Drivers by points: if/else 58 (128 pts), loops 6 (11 pts), match/switch 2 (8 pts), boolean chains 2 (nesting depth added 81). Of this number, 119 points are the body's own statements and 30 belong to one function literal inside it that branches. 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.
Map.ensureField (cognitive 148) REDACTED:1216— Map.ensureField has cognitive complexity 148 (threshold 15). Drivers by points: if/else 58 (118 pts), boolean chains 22, loops 4 (8 pts) (nesting depth added 64). Of this number, 120 points are the body's own statements and 28 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.
d2svg.renderValidated (cognitive 148) d2renderers/d2svg/d2svg.go:2896— d2svg.renderValidated has cognitive complexity 148 (threshold 15). Drivers by points: if/else 61 (116 pts), loops 10 (15 pts), boolean chains 14, match/switch 1 (3 pts) (nesting depth added 62). 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.
compiler.compileReserved (cognitive 145) d2compiler/compile.go:863— compiler.compileReserved has cognitive complexity 145 (threshold 15). Drivers by points: if/else 44 (111 pts), match/switch 4 (14 pts), loops 3 (13 pts), boolean chains 7 (nesting depth added 87). 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.
trees.extractTreesInContainer (cognitive 144) d2layouts/d2talalayout/internal/trees/layout.go:14— trees.extractTreesInContainer has cognitive complexity 144 (threshold 15). Drivers by points: if/else 42 (121 pts), loops 10 (17 pts), boolean chains 6 (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.
graphjson.Serialize (cognitive 143) REDACTED:262— graphjson.Serialize has cognitive complexity 143 (threshold 15). Drivers by points: if/else 45 (108 pts), loops 21 (35 pts) (nesting depth added 77). 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.
ShapingWorkspace.ShapeTextTransient (cognitive 138) d2renderers/internal/fontface/shaping.go:111— ShapingWorkspace.ShapeTextTransient has cognitive complexity 138 (threshold 15). Drivers by points: if/else 60 (121 pts), loops 7 (9 pts), boolean chains 8 (nesting depth added 63). 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.
routing.RouteGraphWithWorkLimit (cognitive 135) d2layouts/d2talalayout/internal/routing/graph_stage.go:44— routing.RouteGraphWithWorkLimit has cognitive complexity 135 (threshold 15). Drivers by points: if/else 45 (107 pts), loops 11 (27 pts), boolean chains 1 (nesting depth added 78). Of this number, 25 points are the body's own statements and 110 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.
svgImporter.parse (cognitive 133) d2renderers/d2svgimport/import.go:393— svgImporter.parse has cognitive complexity 133 (threshold 15). Drivers by points: if/else 41 (122 pts), boolean chains 8, match/switch 1 (2 pts), loops 1 (nesting depth added 82). 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.
sizedOptimizer.optimizeGuarded (cognitive 132) REDACTED:279— sizedOptimizer.optimizeGuarded has cognitive complexity 132 (threshold 15). Drivers by points: if/else 42 (124 pts), loops 3 (5 pts), boolean chains 3 (nesting depth added 84). Of this number, 108 points are the body's own statements and 24 belong to one function literal inside it that branches. 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.
d2svg.drawConnection (cognitive 132) d2renderers/d2svg/d2svg.go:1079— d2svg.drawConnection has cognitive complexity 132 (threshold 15). Drivers by points: if/else 52 (113 pts), loops 3 (12 pts), boolean chains 7 (nesting depth added 70). 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.
preflight.text (cognitive 130) d2renderers/d2raster/text.go:183— preflight.text has cognitive complexity 130 (threshold 15). Drivers by points: if/else 60 (120 pts), boolean chains 5, loops 3 (4 pts), match/switch 1 (nesting depth added 61). Of this number, 127 points are the body's own statements and 3 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.
ovgEdgeRouter.addRoute (cognitive 129) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1659— ovgEdgeRouter.addRoute has cognitive complexity 129 (threshold 15). Drivers by points: if/else 28 (104 pts), loops 7 (22 pts), boolean chains 3 (nesting depth added 91). 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.
d2oracle.updateNear (cognitive 129) d2oracle/edit.go:2328— d2oracle.updateNear has cognitive complexity 129 (threshold 15). Drivers by points: if/else 33 (120 pts), loops 4 (6 pts), boolean chains 3 (nesting depth added 89). 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.
placement.transpose (cognitive 128) d2layouts/d2talalayout/internal/placement/transpose.go:35— placement.transpose has cognitive complexity 128 (threshold 15). Drivers by points: if/else 51 (102 pts), loops 9 (19 pts), boolean chains 7 (nesting depth added 61). Of this number, 105 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.
rasterimage.inspectPNG (cognitive 128) internal/rasterimage/firstframe.go:339— rasterimage.inspectPNG has cognitive complexity 128 (threshold 15). Drivers by points: if/else 37 (107 pts), boolean chains 18, match/switch 1 (2 pts), loops 1 (nesting depth added 71). 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.
placement.shiftSubgraphs (cognitive 127) d2layouts/d2talalayout/internal/placement/compaction.go:145— placement.shiftSubgraphs has cognitive complexity 127 (threshold 15). Drivers by points: if/else 41 (105 pts), loops 10 (22 pts) (nesting depth added 76). Of this number, 121 points are the body's own statements and 6 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.
Route.isOpposingColinear (cognitive 127) d2layouts/d2talalayout/internal/routing/route.go:87— Route.isOpposingColinear has cognitive complexity 127 (threshold 15). Drivers by points: if/else 33 (103 pts), boolean chains 20, loops 2 (4 pts) (nesting depth added 72). 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.
Node.reachableNodesGuarded (cognitive 126) d2layouts/d2talalayout/internal/layoutgraph/node.go:1670— Node.reachableNodesGuarded has cognitive complexity 126 (threshold 15). Drivers by points: if/else 32 (97 pts), loops 9 (29 pts) (nesting depth added 85). Of this number, 123 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.
routing.buildChannelProblem (cognitive 126) d2layouts/d2talalayout/internal/routing/nudge_channels.go:200— routing.buildChannelProblem has cognitive complexity 126 (threshold 15). Drivers by points: if/else 26 (69 pts), loops 24 (43 pts), boolean chains 14 (nesting depth added 62). Of this number, 124 points are the body's own statements and 2 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.
d2raster.compositeLayerOver (cognitive 126) d2renderers/d2raster/effects.go:1760— d2raster.compositeLayerOver has cognitive complexity 126 (threshold 15). Drivers by points: if/else 24 (96 pts), loops 8 (25 pts), boolean chains 5 (nesting depth added 89). 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.
quality.scoreExistingLabelPlacements (cognitive 125) d2layouts/d2talalayout/internal/quality/labels.go:16— quality.scoreExistingLabelPlacements has cognitive complexity 125 (threshold 15). Drivers by points: if/else 45 (104 pts), loops 10 (16 pts), boolean chains 5 (nesting depth added 65). 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.
d2svg.collectFontCorporaAndClasses (cognitive 122) d2renderers/d2svg/font_corpus.go:79— d2svg.collectFontCorporaAndClasses has cognitive complexity 122 (threshold 15). Drivers by points: if/else 24 (84 pts), loops 5 (16 pts), boolean chains 13, match/switch 3 (9 pts) (nesting depth added 77). Of this number, 114 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.
graphjson.validateSerializedGraphForDeserialization (cognitive 121) d2layouts/d2talalayout/internal/graphjson/preflight.go:25— graphjson.validateSerializedGraphForDeserialization has cognitive complexity 121 (threshold 15). Drivers by points: if/else 57 (99 pts), loops 14 (19 pts), boolean chains 3 (nesting depth added 47). Of this number, 97 points are the body's own statements and 24 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.
builder.shapeTextRuns (cognitive 120) d2renderers/d2scenebuild/font_fallback.go:432— builder.shapeTextRuns has cognitive complexity 120 (threshold 15). Drivers by points: if/else 35 (84 pts), loops 9 (28 pts), boolean chains 8 (nesting depth added 68). 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.
d2layouts.LayoutNested (cognitive 119) d2layouts/d2layouts.go:78— d2layouts.LayoutNested has cognitive complexity 119 (threshold 15). Drivers by points: if/else 37 (90 pts), loops 11 (24 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 67). Of this number, 116 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.
d2cli.Run (cognitive 118) d2cli/main.go:62— d2cli.Run has cognitive complexity 118 (threshold 15). Drivers by points: if/else 78 (103 pts), boolean chains 10, match/switch 3 (5 pts) (nesting depth added 27). 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.
OVG.addPortConnectionNodesAtBoundaries (cognitive 118) REDACTED:874— OVG.addPortConnectionNodesAtBoundaries has cognitive complexity 118 (threshold 15). Drivers by points: if/else 21 (103 pts), loops 5 (15 pts) (nesting depth added 92). Of this number, 31 points are the body's own statements and 87 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.
graphjson.newEdgeSerializationIDs (cognitive 117) REDACTED:50— graphjson.newEdgeSerializationIDs has cognitive complexity 117 (threshold 15). Drivers by points: if/else 33 (77 pts), loops 24 (39 pts), boolean chains 1 (nesting depth added 59). Of this number, 108 points are the body's own statements and 9 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.
placement.optimizeClusterWithRollback (cognitive 116) d2layouts/d2talalayout/internal/placement/cluster_optimization.go:148— placement.optimizeClusterWithRollback has cognitive complexity 116 (threshold 15). Drivers by points: if/else 42 (95 pts), match/switch 7 (17 pts), boolean chains 3, loops 1 (nesting depth added 63). Of this number, 96 points are the body's own statements and 20 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.
Graph.SetDimensions (cognitive 115) d2graph/d2graph.go:1515— Graph.SetDimensions has cognitive complexity 115 (threshold 15). Drivers by points: if/else 40 (92 pts), boolean chains 15, match/switch 2 (6 pts), loops 2 (nesting depth added 56). 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.
d2isometricimg.nativeResolveBridgeRoutes (cognitive 115) d2renderers/d2isometric/d2isometricimg/route_bridges.go:60— d2isometricimg.nativeResolveBridgeRoutes has cognitive complexity 115 (threshold 15). Drivers by points: if/else 30 (76 pts), loops 14 (31 pts), boolean chains 8 (nesting depth added 63). Of this number, 110 points are the body's own statements and 5 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.
routing.reorderDuplicatesInEdges (cognitive 114) d2layouts/d2talalayout/internal/routing/coordinator.go:1633— routing.reorderDuplicatesInEdges has cognitive complexity 114 (threshold 15). Drivers by points: if/else 29 (74 pts), loops 11 (34 pts), boolean chains 6 (nesting depth added 68). Of this number, 111 points are the body's own statements and 3 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.
d2raster.rgbaToNRGBAInPlaceBounds (cognitive 114) d2renderers/d2raster/raster.go:462— d2raster.rgbaToNRGBAInPlaceBounds has cognitive complexity 114 (threshold 15). Drivers by points: if/else 20 (83 pts), loops 7 (23 pts), boolean chains 8 (nesting depth added 79). 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.
d2dagrelayout.Layout (cognitive 113) d2layouts/d2dagrelayout/layout.go:53— d2dagrelayout.Layout has cognitive complexity 113 (threshold 15). Drivers by points: if/else 40 (84 pts), loops 13 (19 pts), boolean chains 6, match/switch 2 (4 pts) (nesting depth added 52). 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.
Transaction.Commit (cognitive 113) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1166— Transaction.Commit has cognitive complexity 113 (threshold 15). Drivers by points: if/else 45 (102 pts), loops 6 (9 pts), boolean chains 2 (nesting depth added 60). Of this number, 111 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.
routing.reorderDuplicatesInEdgesGuarded (cognitive 113) d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:323— routing.reorderDuplicatesInEdgesGuarded has cognitive complexity 113 (threshold 15). Drivers by points: if/else 38 (99 pts), loops 5 (9 pts), boolean chains 5 (nesting depth added 65). 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.
d2elklayout.deleteBends (cognitive 112) d2layouts/d2elklayout/layout.go:770— d2elklayout.deleteBends has cognitive complexity 112 (threshold 15). Drivers by points: if/else 34 (98 pts), loops 7 (10 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 69). 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.
svgImporter.instantiate (cognitive 111) d2renderers/d2svgimport/compile.go:386— svgImporter.instantiate has cognitive complexity 111 (threshold 15). Drivers by points: if/else 29 (99 pts), boolean chains 6, match/switch 2 (5 pts), loops 1 (nesting depth added 73). 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.
svgImporter.computeStyle (cognitive 111) d2renderers/d2svgimport/style.go:266— svgImporter.computeStyle has cognitive complexity 111 (threshold 15). Drivers by points: if/else 54 (96 pts), match/switch 6 (12 pts), boolean chains 3 (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.
routing.tunnelRangesBetweenChecked (cognitive 110) d2layouts/d2talalayout/internal/routing/tunnel.go:93— routing.tunnelRangesBetweenChecked has cognitive complexity 110 (threshold 15). Drivers by points: if/else 35 (85 pts), boolean chains 20, loops 3 (5 pts) (nesting depth added 52). 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.
trees.layoutTree (cognitive 110) d2layouts/d2talalayout/internal/trees/geometry.go:113— trees.layoutTree has cognitive complexity 110 (threshold 15). Drivers by points: if/else 24 (90 pts), loops 10 (20 pts) (nesting depth added 76). Of this number, 96 points are the body's own statements and 14 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.
quality.measureLabels (cognitive 109) d2layouts/d2talalayout/internal/quality/inspection_labels.go:19— quality.measureLabels has cognitive complexity 109 (threshold 15). Drivers by points: if/else 34 (89 pts), loops 7 (12 pts), boolean chains 8 (nesting depth added 60). Of this number, 107 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.
meshBuilder.edges (cognitive 109) d2renderers/d2isometric/d2isometricimg/geometry_routes.go:332— meshBuilder.edges has cognitive complexity 109 (threshold 15). Drivers by points: if/else 36 (83 pts), boolean chains 18, loops 4 (8 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.
compiler.compileMap (cognitive 108) REDACTED:971— compiler.compileMap has cognitive complexity 108 (threshold 15). Drivers by points: if/else 26 (78 pts), loops 8 (24 pts), boolean chains 4, match/switch 1 (2 pts) (nesting depth added 69). 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.
proximity.assignNearsWithWorkLimit (cognitive 108) d2layouts/d2talalayout/internal/proximity/nears.go:18— proximity.assignNearsWithWorkLimit has cognitive complexity 108 (threshold 15). Drivers by points: if/else 32 (85 pts), loops 13 (20 pts), boolean chains 3 (nesting depth added 60). Of this number, 91 points are the body's own statements and 17 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.
routing.balanceReversalRemovesCrossings (cognitive 108) REDACTED:17— routing.balanceReversalRemovesCrossings has cognitive complexity 108 (threshold 15). Drivers by points: if/else 27 (81 pts), loops 9 (18 pts), boolean chains 9 (nesting depth added 63). 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.
grouping.AddSequences (cognitive 106) REDACTED:206— grouping.AddSequences has cognitive complexity 106 (threshold 15). Drivers by points: if/else 34 (80 pts), loops 13 (24 pts), boolean chains 2 (nesting depth added 57). Of this number, 105 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.
routing.channelProposalSafe (cognitive 106) d2layouts/d2talalayout/internal/routing/nudge_channels.go:602— routing.channelProposalSafe has cognitive complexity 106 (threshold 15). Drivers by points: if/else 22 (75 pts), loops 10 (22 pts), boolean chains 9 (nesting depth added 65). 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.
placement.optimizerAdjacents (cognitive 104) d2layouts/d2talalayout/internal/placement/optimization_guard.go:176— placement.optimizerAdjacents has cognitive complexity 104 (threshold 15). Drivers by points: if/else 39 (83 pts), boolean chains 11, loops 7 (10 pts) (nesting depth added 47). 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.
d2oracle.Delete (cognitive 104) d2oracle/edit.go:937— d2oracle.Delete has cognitive complexity 104 (threshold 15). Drivers by points: if/else 38 (84 pts), loops 4 (19 pts), boolean chains 1 (nesting depth added 61). 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.
d2isometricimg.newNativeSceneWithOptions (cognitive 104) d2renderers/d2isometric/d2isometricimg/geometry.go:431— d2isometricimg.newNativeSceneWithOptions has cognitive complexity 104 (threshold 15). Drivers by points: if/else 39 (87 pts), loops 8 (9 pts), boolean chains 8 (nesting depth added 49). 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.
hierarchy.findCycleEdges (cognitive 101) d2layouts/d2talalayout/internal/hierarchy/discovery.go:579— hierarchy.findCycleEdges has cognitive complexity 101 (threshold 15). Drivers by points: if/else 29 (77 pts), loops 11 (21 pts), boolean chains 3 (nesting depth added 58). Of this number, 87 points are the body's own statements and 14 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.
Node.connectedNodes (cognitive 101) d2layouts/d2talalayout/internal/layoutgraph/node.go:1847— Node.connectedNodes has cognitive complexity 101 (threshold 15). Drivers by points: if/else 19 (67 pts), loops 12 (33 pts), boolean chains 1 (nesting depth added 69). Of this number, 100 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.
proximity.AssignHerds (cognitive 101) d2layouts/d2talalayout/internal/proximity/herding.go:16— proximity.AssignHerds has cognitive complexity 101 (threshold 15). Drivers by points: if/else 23 (64 pts), loops 12 (28 pts), boolean chains 9 (nesting depth added 57). Of this number, 99 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.
d2oracle.DeleteIDDeltas (cognitive 101) d2oracle/edit.go:2972— d2oracle.DeleteIDDeltas has cognitive complexity 101 (threshold 15). Drivers by points: if/else 27 (73 pts), loops 12 (25 pts), boolean chains 3 (nesting depth added 59). Of this number, 85 points are the body's own statements and 16 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.
layoutgraph.collectRuntimeObjectsContext (cognitive 100) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:362— layoutgraph.collectRuntimeObjectsContext has cognitive complexity 100 (threshold 15). Drivers by points: loops 26 (52 pts), if/else 43 (45 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 29). Of this number, 60 points are the body's own statements and 40 belong to 9 function literals inside it that branch. 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.
textPainter.texture (cognitive 100) d2renderers/d2isometric/d2isometricimg/text.go:145— textPainter.texture has cognitive complexity 100 (threshold 15). Drivers by points: if/else 39 (73 pts), loops 8 (14 pts), boolean chains 9, match/switch 1 (4 pts) (nesting depth added 43). Of this number, 81 points are the body's own statements and 19 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.
d2isometricimg.svgOrderPaintUnitsWithLimits (cognitive 99) d2renderers/d2isometric/d2isometricimg/svg_order.go:29— d2isometricimg.svgOrderPaintUnitsWithLimits has cognitive complexity 99 (threshold 15). Drivers by points: if/else 27 (69 pts), loops 15 (27 pts), boolean chains 3 (nesting depth added 54). Of this number, 73 points are the body's own statements and 26 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.
svgImporter.declarationsFor (cognitive 99) d2renderers/d2svgimport/style.go:63— svgImporter.declarationsFor has cognitive complexity 99 (threshold 15). Drivers by points: if/else 35 (84 pts), loops 7 (10 pts), boolean chains 5 (nesting depth added 52). 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.
d2isometricimg.nativeSceneSVG (cognitive 97) d2renderers/d2isometric/d2isometricimg/svg.go:237— d2isometricimg.nativeSceneSVG has cognitive complexity 97 (threshold 15). Drivers by points: if/else 33 (69 pts), loops 10 (18 pts), boolean chains 10 (nesting depth added 44). Of this number, 93 points are the body's own statements and 4 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.
compiler.ampersandFilter (cognitive 96) REDACTED:1364— compiler.ampersandFilter has cognitive complexity 96 (threshold 15). Drivers by points: if/else 28 (60 pts), loops 6 (17 pts), boolean chains 13, match/switch 2 (6 pts) (nesting depth added 47). 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.
hierarchy.newRankProblem (cognitive 96) d2layouts/d2talalayout/internal/hierarchy/rank_graph.go:13— hierarchy.newRankProblem has cognitive complexity 96 (threshold 15). Drivers by points: if/else 39 (75 pts), loops 10 (14 pts), boolean chains 7 (nesting depth added 40). Of this number, 90 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.
parser.parseUnquotedString (cognitive 96) d2parser/parse.go:1129— parser.parseUnquotedString has cognitive complexity 96 (threshold 15). Drivers by points: if/else 31 (77 pts), match/switch 4 (12 pts), boolean chains 5, loops 2 (nesting depth added 54). Of this number, 89 points are the body's own statements and 7 belong to one function literal inside it that branches. 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.
Edge.TraceToShape (cognitive 94) d2graph/layout.go:414— Edge.TraceToShape has cognitive complexity 94 (threshold 15). Drivers by points: if/else 26 (68 pts), boolean chains 14, loops 4 (12 pts) (nesting depth added 50). 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.
d2isometricimg.nativeLaneJoinCorners (cognitive 94) d2renderers/d2isometric/d2isometricimg/route_lanes.go:435— d2isometricimg.nativeLaneJoinCorners has cognitive complexity 94 (threshold 15). Drivers by points: if/else 19 (63 pts), loops 9 (19 pts), boolean chains 12 (nesting depth added 54). Of this number, 84 points are the body's own statements and 10 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.
Map.createEdge (cognitive 92) REDACTED:1717— Map.createEdge has cognitive complexity 92 (threshold 15). Drivers by points: if/else 28 (70 pts), loops 6 (13 pts), boolean chains 9 (nesting depth added 49). 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.
placement.placeNodes (cognitive 92) REDACTED:21— placement.placeNodes has cognitive complexity 92 (threshold 15). Drivers by points: if/else 31 (61 pts), loops 13 (29 pts), boolean chains 2 (nesting depth added 46). Of this number, 87 points are the body's own statements and 5 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.
d2isometric.BuildScene (cognitive 91) d2renderers/d2isometric/scene.go:129— d2isometric.BuildScene has cognitive complexity 91 (threshold 15). Drivers by points: if/else 36 (56 pts), loops 14 (19 pts), boolean chains 16 (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.
d2raster.makeStrokeRuns (cognitive 91) d2renderers/d2raster/geometry.go:529— d2raster.makeStrokeRuns has cognitive complexity 91 (threshold 15). Drivers by points: if/else 30 (81 pts), boolean chains 5, loops 4 (5 pts) (nesting depth added 52). 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.
compiler.compileMap (cognitive 90) d2compiler/compile.go:453— compiler.compileMap has cognitive complexity 90 (threshold 15). Drivers by points: if/else 26 (72 pts), loops 5 (14 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 56). 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.
routing.shortcutContactsPreserved (cognitive 90) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:300— routing.shortcutContactsPreserved has cognitive complexity 90 (threshold 15). Drivers by points: if/else 15 (60 pts), boolean chains 16, loops 5 (14 pts) (nesting depth added 54). 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.
d2oracle.renameConflictsToParent (cognitive 90) d2oracle/edit.go:1162— d2oracle.renameConflictsToParent has cognitive complexity 90 (threshold 15). Drivers by points: if/else 23 (67 pts), loops 9 (21 pts), boolean chains 2 (nesting depth added 56). 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.
Style.Apply (cognitive 89) d2graph/d2graph.go:313— Style.Apply has cognitive complexity 89 (threshold 15). Drivers by points: if/else 40 (80 pts), boolean chains 8, match/switch 1 (nesting depth added 40). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
gridDiagram.layoutDynamic (cognitive 89) d2layouts/d2grid/layout.go:337— gridDiagram.layoutDynamic has cognitive complexity 89 (threshold 15). Drivers by points: loops 23 (67 pts), if/else 10 (22 pts) (nesting depth added 56). 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.
d2talalayout.validateLayoutResultMetadata (cognitive 89) d2layouts/d2talalayout/result_validate.go:129— d2talalayout.validateLayoutResultMetadata has cognitive complexity 89 (threshold 15). Drivers by points: if/else 40 (75 pts), boolean chains 9, loops 5 (nesting depth added 35). 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.
trees.buildPlacementTrees (cognitive 89) d2layouts/d2talalayout/internal/trees/layout.go:1021— trees.buildPlacementTrees has cognitive complexity 89 (threshold 15). Drivers by points: if/else 18 (67 pts), loops 6 (19 pts), boolean chains 3 (nesting depth added 62). 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.
Raster.drawPrepared (cognitive 89) d2renderers/d2isometric/d2isometricimg/raster.go:928— Raster.drawPrepared has cognitive complexity 89 (threshold 15). Drivers by points: if/else 24 (71 pts), loops 5 (10 pts), boolean chains 8 (nesting depth added 52). 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.
grouping.ResetClusters (cognitive 87) d2layouts/d2talalayout/internal/grouping/lifecycle.go:7— grouping.ResetClusters has cognitive complexity 87 (threshold 15). Drivers by points: if/else 21 (53 pts), loops 13 (28 pts), boolean chains 6 (nesting depth added 47). 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.
SystemFallbackResolver.ResolveFallbacks (cognitive 86) d2renderers/d2fonts/fallback.go:121— SystemFallbackResolver.ResolveFallbacks has cognitive complexity 86 (threshold 15). Drivers by points: if/else 35 (75 pts), loops 4 (9 pts), boolean chains 2 (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.
OVG.connectNodesOnSameLine (cognitive 85) REDACTED:1223— OVG.connectNodesOnSameLine has cognitive complexity 85 (threshold 15). Drivers by points: if/else 28 (73 pts), boolean chains 8, loops 3 (4 pts) (nesting depth added 46). Of this number, 77 points are the body's own statements and 8 belong to 3 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.
d2lsp.getKeywordContext (cognitive 85) d2lsp/completion.go:120— d2lsp.getKeywordContext has cognitive complexity 85 (threshold 15). Drivers by points: if/else 27 (72 pts), boolean chains 12, loops 1 (nesting depth added 45). 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.
d2oracle.MoveIDDeltas (cognitive 84) d2oracle/edit.go:2778— d2oracle.MoveIDDeltas has cognitive complexity 84 (threshold 15). Drivers by points: if/else 27 (63 pts), loops 9 (17 pts), boolean chains 4 (nesting depth added 44). Of this number, 69 points are the body's own statements and 15 belong to 3 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.
packing.binPackCanUseRoutedContainerBox (cognitive 83) d2layouts/d2talalayout/internal/packing/routed_container.go:45— packing.binPackCanUseRoutedContainerBox has cognitive complexity 83 (threshold 15). Drivers by points: if/else 38 (66 pts), boolean chains 13, loops 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.
d2wasm.Render (cognitive 83) d2js/d2wasm/functions.go:351— d2wasm.Render has cognitive complexity 83 (threshold 15). Drivers by points: if/else 42 (59 pts), boolean chains 20, match/switch 2 (4 pts) (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.
Nodes.clustersWithWorkGuard (cognitive 82) d2layouts/d2talalayout/internal/layoutgraph/node.go:300— Nodes.clustersWithWorkGuard has cognitive complexity 82 (threshold 15). Drivers by points: if/else 36 (64 pts), loops 11 (17 pts), boolean chains 1 (nesting depth added 34). Of this number, 57 points are the body's own statements and 25 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.
placement.newSizedOptimizer (cognitive 82) REDACTED:106— placement.newSizedOptimizer has cognitive complexity 82 (threshold 15). Drivers by points: if/else 28 (63 pts), boolean chains 11, loops 5 (8 pts) (nesting depth added 38). 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.
OVG.halfwayPoints (cognitive 82) REDACTED:561— OVG.halfwayPoints has cognitive complexity 82 (threshold 15). Drivers by points: if/else 29 (57 pts), loops 10 (20 pts), boolean chains 4, match/switch 1 (nesting depth added 38). 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.
Graph.abductEdges (cognitive 81) d2layouts/d2talalayout/internal/layoutgraph/layout.go:163— Graph.abductEdges has cognitive complexity 81 (threshold 15). Drivers by points: if/else 24 (59 pts), boolean chains 11, loops 7 (11 pts) (nesting depth added 39). 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.
d2raster.compositeBlendLayerOpaquePrefix (cognitive 81) d2renderers/d2raster/effects.go:1516— d2raster.compositeBlendLayerOpaquePrefix has cognitive complexity 81 (threshold 15). Drivers by points: if/else 15 (52 pts), loops 6 (17 pts), match/switch 2 (10 pts), boolean chains 2 (nesting depth added 56). 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.
d2svgimport.inspectEmbeddedJPEG (cognitive 81) d2renderers/d2svgimport/image.go:377— d2svgimport.inspectEmbeddedJPEG has cognitive complexity 81 (threshold 15). Drivers by points: if/else 19 (60 pts), loops 4 (10 pts), boolean chains 9, match/switch 1 (2 pts) (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.
rankSimplex.feasibleTree (cognitive 80) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:136— rankSimplex.feasibleTree has cognitive complexity 80 (threshold 15). Drivers by points: if/else 26 (69 pts), loops 6 (10 pts), boolean chains 1 (nesting depth added 47). Of this number, 60 points are the body's own statements and 20 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.
routing.applyChannelProblem (cognitive 80) d2layouts/d2talalayout/internal/routing/nudge_channels.go:441— routing.applyChannelProblem has cognitive complexity 80 (threshold 15). Drivers by points: if/else 16 (50 pts), loops 14 (27 pts), boolean chains 3 (nesting depth added 47). Of this number, 79 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.
BundledFallbackResolver.resolve (cognitive 80) d2renderers/d2fonts/bundled_fallback.go:94— BundledFallbackResolver.resolve has cognitive complexity 80 (threshold 15). Drivers by points: if/else 34 (74 pts), loops 2 (4 pts), boolean chains 2 (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.
ovgEdgeRouter.bestRoute (cognitive 79) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1490— ovgEdgeRouter.bestRoute has cognitive complexity 79 (threshold 15). Drivers by points: if/else 21 (64 pts), boolean chains 9, loops 3 (6 pts) (nesting depth added 46). 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.
d2raster.planNodeResources (cognitive 79) d2renderers/d2raster/effects.go:322— d2raster.planNodeResources has cognitive complexity 79 (threshold 15). Drivers by points: if/else 40 (74 pts), boolean chains 4, loops 1 (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.
builder.preflightConnection (cognitive 79) d2renderers/d2scenebuild/build.go:404— builder.preflightConnection has cognitive complexity 79 (threshold 15). Drivers by points: if/else 35 (58 pts), boolean chains 16, loops 3, match/switch 1 (2 pts) (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.
d2isometricimg.rasterValidate (cognitive 78) d2renderers/d2isometric/d2isometricimg/raster.go:475— d2isometricimg.rasterValidate has cognitive complexity 78 (threshold 15). Drivers by points: if/else 20 (59 pts), boolean chains 10, loops 3 (6 pts), match/switch 1 (3 pts) (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.
builder.buildDocument (cognitive 78) d2renderers/d2scenebuild/build.go:542— builder.buildDocument has cognitive complexity 78 (threshold 15). Drivers by points: if/else 49 (69 pts), boolean chains 5, loops 4 (nesting depth added 20). Of this number, 74 points are the body's own statements and 4 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.
labeling.findSharedSegmentsChecked (cognitive 77) d2layouts/d2talalayout/internal/labeling/placement.go:1024— labeling.findSharedSegmentsChecked has cognitive complexity 77 (threshold 15). Drivers by points: if/else 29 (69 pts), loops 4 (6 pts), boolean chains 2 (nesting depth added 42). Of this number, 36 points are the body's own statements and 41 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.
GraphState.updateContext (cognitive 77) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:167— GraphState.updateContext has cognitive complexity 77 (threshold 15). Drivers by points: if/else 36 (60 pts), loops 10 (14 pts), boolean chains 3 (nesting depth added 28). Of this number, 62 points are the body's own statements and 15 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.
routing.overshot (cognitive 77) d2layouts/d2talalayout/internal/routing/slingshot.go:219— routing.overshot has cognitive complexity 77 (threshold 15). Drivers by points: if/else 24 (60 pts), boolean chains 16, match/switch 1 (nesting depth added 36). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
imageasset.validateSVGWithLimits (cognitive 76) lib/imageasset/probe.go:457— imageasset.validateSVGWithLimits has cognitive complexity 76 (threshold 15). Drivers by points: if/else 22 (64 pts), boolean chains 6, loops 2 (4 pts), match/switch 1 (2 pts) (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.
compiler.compileField (cognitive 75) d2compiler/compile.go:651— compiler.compileField has cognitive complexity 75 (threshold 15). Drivers by points: if/else 26 (56 pts), boolean chains 11, loops 3 (8 pts) (nesting depth added 35). 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.
d2talalayout.validateD2Edges (cognitive 75) d2layouts/d2talalayout/adapter_validate.go:383— d2talalayout.validateD2Edges has cognitive complexity 75 (threshold 15). Drivers by points: if/else 28 (67 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 40). 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.
packing.allEdgesHaveCompleteRoutesGuarded (cognitive 75) d2layouts/d2talalayout/internal/packing/guard.go:471— packing.allEdgesHaveCompleteRoutesGuarded has cognitive complexity 75 (threshold 15). Drivers by points: if/else 29 (60 pts), loops 6 (8 pts), boolean chains 7 (nesting depth added 33). 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.
placement.initializeByGraphDistance (cognitive 75) d2layouts/d2talalayout/internal/placement/stress_initialize.go:16— placement.initializeByGraphDistance has cognitive complexity 75 (threshold 15). Drivers by points: if/else 14 (39 pts), loops 19 (33 pts), boolean chains 3 (nesting depth added 39). 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.
preflight.positionGlyphs (cognitive 75) d2renderers/d2raster/text.go:456— preflight.positionGlyphs has cognitive complexity 75 (threshold 15). Drivers by points: if/else 27 (60 pts), loops 5 (11 pts), boolean chains 4 (nesting depth added 39). 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.
pathParser.parseGroup (cognitive 75) d2renderers/d2svgimport/path.go:131— pathParser.parseGroup has cognitive complexity 75 (threshold 15). Drivers by points: if/else 35 (68 pts), boolean chains 6, match/switch 1 (nesting depth added 33). Of this number, 74 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.
d2raster.multiplyLayerByRGBALuminance (cognitive 74) d2renderers/d2raster/effects.go:1117— d2raster.multiplyLayerByRGBALuminance has cognitive complexity 74 (threshold 15). Drivers by points: if/else 12 (37 pts), loops 9 (28 pts), boolean chains 5, match/switch 1 (4 pts) (nesting depth added 47). 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.
Rasterizer.WriteAlpha (cognitive 74) REDACTED:724— Rasterizer.WriteAlpha has cognitive complexity 74 (threshold 15). Drivers by points: if/else 15 (46 pts), loops 6 (23 pts), boolean chains 5 (nesting depth added 48). Most of this is not in the body itself: 6 of the 74 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 737, 781). 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.
sizedOptimizer.moveNodeToBestGuarded (cognitive 73) REDACTED:887— sizedOptimizer.moveNodeToBestGuarded has cognitive complexity 73 (threshold 15). Drivers by points: if/else 25 (59 pts), boolean chains 7, loops 2 (4 pts), match/switch 1 (3 pts) (nesting depth added 38). Of this number, 72 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.
ovgEdgeRouter.usedPorts (cognitive 73) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:465— ovgEdgeRouter.usedPorts has cognitive complexity 73 (threshold 15). Drivers by points: if/else 15 (57 pts), loops 5 (14 pts), boolean chains 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.
xgif.validatePalettedImage (cognitive 73) lib/xgif/xgif.go:1341— xgif.validatePalettedImage has cognitive complexity 73 (threshold 15). Drivers by points: if/else 25 (55 pts), loops 8 (16 pts), boolean chains 2 (nesting depth added 38). 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.
d2talalayout.validateD2Objects (cognitive 72) d2layouts/d2talalayout/adapter_validate.go:100— d2talalayout.validateD2Objects has cognitive complexity 72 (threshold 15). Drivers by points: if/else 28 (66 pts), boolean chains 5, loops 1 (nesting depth added 38). 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.
routing.captureRouteMutations (cognitive 72) d2layouts/d2talalayout/internal/routing/route_stage_guard.go:147— routing.captureRouteMutations has cognitive complexity 72 (threshold 15). Drivers by points: if/else 24 (52 pts), loops 9 (20 pts) (nesting depth added 39). Of this number, 62 points are the body's own statements and 10 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.
d2oracle.ReconnectEdge (cognitive 72) d2oracle/edit.go:124— d2oracle.ReconnectEdge has cognitive complexity 72 (threshold 15). Drivers by points: if/else 34 (62 pts), boolean chains 7, loops 2 (3 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.
builder.buildShape (cognitive 72) d2renderers/d2scenebuild/build.go:828— builder.buildShape has cognitive complexity 72 (threshold 15). Drivers by points: if/else 39 (68 pts), boolean chains 4 (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.
sizedOptimizer.bestSwapCandidateGuarded (cognitive 71) REDACTED:1027— sizedOptimizer.bestSwapCandidateGuarded has cognitive complexity 71 (threshold 15). Drivers by points: if/else 34 (66 pts), boolean chains 3, loops 2 (nesting depth added 32). Of this number, 42 points are the body's own statements and 29 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.
trees.placeAtOrientationGuarded (cognitive 71) d2layouts/d2talalayout/internal/trees/layout.go:399— trees.placeAtOrientationGuarded has cognitive complexity 71 (threshold 15). Drivers by points: if/else 30 (55 pts), boolean chains 7, loops 6 (7 pts), match/switch 2 (nesting depth added 26). Of this number, 59 points are the body's own statements and 12 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.
compiler.validateNear (cognitive 70) d2compiler/compile.go:1585— compiler.validateNear has cognitive complexity 70 (threshold 15). Drivers by points: if/else 18 (58 pts), loops 4 (10 pts), boolean chains 2 (nesting depth added 46). 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.
hierarchy.is1N1 (cognitive 70) d2layouts/d2talalayout/internal/hierarchy/discovery.go:367— hierarchy.is1N1 has cognitive complexity 70 (threshold 15). Drivers by points: if/else 27 (61 pts), loops 5 (6 pts), boolean chains 3 (nesting depth added 35). 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.
routing.shortcutRoutesGuarded (cognitive 70) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:69— routing.shortcutRoutesGuarded has cognitive complexity 70 (threshold 15). Drivers by points: if/else 18 (53 pts), loops 5 (12 pts), boolean chains 5 (nesting depth added 42). 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.
d2isometricimg.rasterBuildShadow (cognitive 70) d2renderers/d2isometric/d2isometricimg/raster.go:691— d2isometricimg.rasterBuildShadow has cognitive complexity 70 (threshold 15). Drivers by points: if/else 20 (52 pts), loops 6 (10 pts), boolean chains 8 (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.
d2grid.Layout (cognitive 69) d2layouts/d2grid/layout.go:23— d2grid.Layout has cognitive complexity 69 (threshold 15). Drivers by points: if/else 26 (51 pts), boolean chains 11, match/switch 2 (6 pts), loops 1 (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.
routing.swapEdgesOnAdjacentSides (cognitive 69) d2layouts/d2talalayout/internal/routing/swap_ports.go:541— routing.swapEdgesOnAdjacentSides has cognitive complexity 69 (threshold 15). Drivers by points: if/else 24 (65 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 42). 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.
d2oracle.deleteObject (cognitive 69) d2oracle/edit.go:1523— d2oracle.deleteObject has cognitive complexity 69 (threshold 15). Drivers by points: if/else 22 (54 pts), boolean chains 9, loops 3 (6 pts) (nesting depth added 35). Of this number, 68 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
d2oracle._updateImport (cognitive 69) d2oracle/edit.go:3354— d2oracle._updateImport has cognitive complexity 69 (threshold 15). Drivers by points: if/else 20 (67 pts), boolean chains 1, loops 1 (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.
d2raster.boxBlurRGBAGeneral (cognitive 69) d2renderers/d2raster/filter.go:653— d2raster.boxBlurRGBAGeneral has cognitive complexity 69 (threshold 15). Drivers by points: if/else 15 (48 pts), loops 6 (15 pts), boolean chains 6 (nesting depth added 42). 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.
d2raster.boxBlurAlphaPixelsGeneral (cognitive 69) d2renderers/d2raster/filter.go:838— d2raster.boxBlurAlphaPixelsGeneral has cognitive complexity 69 (threshold 15). Drivers by points: if/else 15 (48 pts), loops 6 (15 pts), boolean chains 6 (nesting depth added 42). 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.
routing.edgeCanOverlapEdges (cognitive 68) d2layouts/d2talalayout/internal/routing/coordinator.go:1208— routing.edgeCanOverlapEdges has cognitive complexity 68 (threshold 15). Drivers by points: if/else 23 (44 pts), loops 8 (14 pts), boolean chains 10 (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.
Canvas.ToByteArray (cognitive 68) d2renderers/d2ascii/asciicanvas/asciicanvas.go:76— Canvas.ToByteArray has cognitive complexity 68 (threshold 15). Drivers by points: if/else 18 (43 pts), loops 9 (18 pts), boolean chains 7 (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.
SystemFallbackResolver.fontPaths (cognitive 68) d2renderers/d2fonts/fallback.go:338— SystemFallbackResolver.fontPaths has cognitive complexity 68 (threshold 15). Drivers by points: if/else 14 (57 pts), loops 4 (10 pts), boolean chains 1 (nesting depth added 49). 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.
d2raster.multiplyLayerByRGBAAlpha (cognitive 68) d2renderers/d2raster/effects.go:1237— d2raster.multiplyLayerByRGBAAlpha has cognitive complexity 68 (threshold 15). Drivers by points: if/else 11 (36 pts), loops 7 (22 pts), boolean chains 7, match/switch 1 (3 pts) (nesting depth added 42). 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.
Node.ConnectedNodeSet (cognitive 67) d2layouts/d2talalayout/internal/layoutgraph/connected_set.go:25— Node.ConnectedNodeSet has cognitive complexity 67 (threshold 15). Drivers by points: if/else 13 (30 pts), loops 14 (30 pts), boolean chains 7 (nesting depth added 33). Of this number, 66 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.
placement.captureOptimizerMutationStateInto (cognitive 67) d2layouts/d2talalayout/internal/placement/optimization_guard.go:814— placement.captureOptimizerMutationStateInto has cognitive complexity 67 (threshold 15). Drivers by points: if/else 28 (52 pts), loops 8 (13 pts), boolean chains 2 (nesting depth added 29). Of this number, 63 points are the body's own statements and 4 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.
routing.newOVGPortIndex (cognitive 67) d2layouts/d2talalayout/internal/routing/ovg_resource.go:690— routing.newOVGPortIndex has cognitive complexity 67 (threshold 15). Drivers by points: if/else 15 (48 pts), loops 8 (15 pts), boolean chains 4 (nesting depth added 40). 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.
markdownPainter.markdownInlineLineHeight (cognitive 67) lib/textmeasure/markdown_svg.go:875— markdownPainter.markdownInlineLineHeight has cognitive complexity 67 (threshold 15). Drivers by points: if/else 21 (57 pts), boolean chains 5, loops 2 (5 pts) (nesting depth added 39). 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.
Map.getEdges (cognitive 66) REDACTED:1593— Map.getEdges has cognitive complexity 66 (threshold 15). Drivers by points: if/else 19 (48 pts), loops 6 (13 pts), boolean chains 5 (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.
layoutgraph.countSegmentCrossingsWithCheck (cognitive 66) d2layouts/d2talalayout/internal/layoutgraph/segment_crossing.go:54— layoutgraph.countSegmentCrossingsWithCheck has cognitive complexity 66 (threshold 15). Drivers by points: if/else 20 (62 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 43). 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.
routing.buildTunnelsBetween (cognitive 66) d2layouts/d2talalayout/internal/routing/tunnel.go:263— routing.buildTunnelsBetween has cognitive complexity 66 (threshold 15). Drivers by points: if/else 23 (57 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 38). 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.
OVG.flagNodesNearPorts (cognitive 66) REDACTED:1540— OVG.flagNodesNearPorts has cognitive complexity 66 (threshold 15). Drivers by points: if/else 13 (51 pts), loops 5 (13 pts), boolean chains 2 (nesting depth added 46). 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.
hierarchy.PlaceCompound (cognitive 65) REDACTED:39— hierarchy.PlaceCompound has cognitive complexity 65 (threshold 15). Drivers by points: if/else 29 (47 pts), loops 8 (10 pts), boolean chains 8 (nesting depth added 20). Of this number, 64 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.
labeling.placeNewEdges (cognitive 65) d2layouts/d2talalayout/internal/labeling/placement.go:462— labeling.placeNewEdges has cognitive complexity 65 (threshold 15). Drivers by points: if/else 28 (52 pts), loops 7, boolean chains 6 (nesting depth added 24). Of this number, 63 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.
placementcost.EdgeLength (cognitive 65) d2layouts/d2talalayout/internal/placementcost/graph.go:111— placementcost.EdgeLength has cognitive complexity 65 (threshold 15). Drivers by points: if/else 22 (56 pts), loops 4 (9 pts) (nesting depth added 39). Of this number, 37 points are the body's own statements and 28 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.
trees.putBackNonBranchingTrees (cognitive 65) d2layouts/d2talalayout/internal/trees/layout.go:573— trees.putBackNonBranchingTrees has cognitive complexity 65 (threshold 15). Drivers by points: if/else 18 (56 pts), loops 3 (6 pts), boolean chains 3 (nesting depth added 41). 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.
d2isometricimg.hierarchyBoardHeaderPlacement (cognitive 65) d2renderers/d2isometric/d2isometricimg/hierarchy_headers.go:25— d2isometricimg.hierarchyBoardHeaderPlacement has cognitive complexity 65 (threshold 15). Drivers by points: if/else 23 (41 pts), boolean chains 14, loops 5 (7 pts), match/switch 1 (3 pts) (nesting depth added 22). Of this number, 60 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.
compiler.compilePosition (cognitive 64) d2compiler/compile.go:798— compiler.compilePosition has cognitive complexity 64 (threshold 15). Drivers by points: if/else 13 (36 pts), match/switch 4 (25 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 45). 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.
sizedOptimizer.fillPlacementPointsGuarded (cognitive 64) REDACTED:715— sizedOptimizer.fillPlacementPointsGuarded has cognitive complexity 64 (threshold 15). Drivers by points: if/else 27 (50 pts), loops 5 (8 pts), boolean chains 6 (nesting depth added 26). Of this number, 57 points are the body's own statements and 7 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.
proximity.GroupSheep (cognitive 64) d2layouts/d2talalayout/internal/proximity/herding.go:237— proximity.GroupSheep has cognitive complexity 64 (threshold 15). Drivers by points: if/else 17 (49 pts), boolean chains 9, loops 3 (6 pts) (nesting depth added 35). 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.
routing.simplifyPoints (cognitive 64) d2layouts/d2talalayout/internal/routing/edge_simplify.go:37— routing.simplifyPoints has cognitive complexity 64 (threshold 15). Drivers by points: if/else 12 (33 pts), boolean chains 24, loops 3 (7 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.
svgImporter.validateXMLDeclaration (cognitive 64) d2renderers/d2svgimport/import.go:604— svgImporter.validateXMLDeclaration has cognitive complexity 64 (threshold 15). Drivers by points: if/else 22 (46 pts), boolean chains 12, loops 4 (6 pts) (nesting depth added 26). Of this number, 57 points are the body's own statements and 7 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.
placement.PlaceChildrenOrder (cognitive 63) REDACTED:461— placement.PlaceChildrenOrder has cognitive complexity 63 (threshold 15). Drivers by points: if/else 22 (51 pts), loops 7 (11 pts), boolean chains 1 (nesting depth added 33). 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.
routing.reorderSelectedRoutes (cognitive 63) d2layouts/d2talalayout/internal/routing/coordinator.go:305— routing.reorderSelectedRoutes has cognitive complexity 63 (threshold 15). Drivers by points: if/else 23 (54 pts), loops 6 (9 pts) (nesting depth added 34). Of this number, 52 points are the body's own statements and 11 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.
nativeSurfaceSVGWriter.text (cognitive 63) d2renderers/d2isometric/d2isometricimg/vector_surface_text.go:49— nativeSurfaceSVGWriter.text has cognitive complexity 63 (threshold 15). Drivers by points: if/else 26 (50 pts), loops 5 (10 pts), boolean chains 3 (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.
preflight.finishPrimitive (cognitive 63) d2renderers/d2raster/raster.go:1327— preflight.finishPrimitive has cognitive complexity 63 (threshold 15). Drivers by points: if/else 17 (44 pts), loops 8 (17 pts), boolean chains 2 (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.
markdownSubstitutionMatcher.replaceBounded (cognitive 63) lib/textmeasure/substitutions.go:214— markdownSubstitutionMatcher.replaceBounded has cognitive complexity 63 (threshold 15). Drivers by points: if/else 23 (52 pts), loops 6 (8 pts), boolean chains 3 (nesting depth added 31). 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.
Key.Equals (cognitive 62) d2ast/d2ast.go:895— Key.Equals has cognitive complexity 62 (threshold 15). Drivers by points: if/else 31 (50 pts), loops 4 (7 pts), boolean chains 5 (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.
compiler.compileSubstitutionsWalk (cognitive 62) REDACTED:270— compiler.compileSubstitutionsWalk has cognitive complexity 62 (threshold 15). Drivers by points: if/else 23 (54 pts), loops 4 (6 pts), boolean chains 2 (nesting depth added 33). 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.
d2dagrelayout.shiftDown (cognitive 62) d2layouts/d2dagrelayout/layout.go:664— d2dagrelayout.shiftDown has cognitive complexity 62 (threshold 15). Drivers by points: if/else 14 (44 pts), loops 6 (14 pts), boolean chains 4 (nesting depth added 38). 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 (d2dagrelayout.shiftUp) 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.
d2dagrelayout.shiftUp (cognitive 62) d2layouts/d2dagrelayout/layout.go:728— d2dagrelayout.shiftUp has cognitive complexity 62 (threshold 15). Drivers by points: if/else 14 (44 pts), loops 6 (14 pts), boolean chains 4 (nesting depth added 38). 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 (d2dagrelayout.shiftDown) 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.
placement.alignAxes (cognitive 62) d2layouts/d2talalayout/internal/placement/alignment.go:26— placement.alignAxes has cognitive complexity 62 (threshold 15). Drivers by points: if/else 24 (48 pts), loops 6 (9 pts), boolean chains 5 (nesting depth added 27). Of this number, 59 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.
placement.candidateMoves (cognitive 62) d2layouts/d2talalayout/internal/placement/compaction.go:577— placement.candidateMoves has cognitive complexity 62 (threshold 15). Drivers by points: if/else 33 (56 pts), boolean chains 5, loops 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.
placementcost.computeSymmetryScoreInto (cognitive 62) d2layouts/d2talalayout/internal/placementcost/symmetry.go:397— placementcost.computeSymmetryScoreInto has cognitive complexity 62 (threshold 15). Drivers by points: if/else 21 (54 pts), loops 3 (6 pts), boolean chains 2 (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.
svgImporter.compileGeometry (cognitive 62) d2renderers/d2svgimport/geometry.go:33— svgImporter.compileGeometry has cognitive complexity 62 (threshold 15). Drivers by points: if/else 29 (57 pts), boolean chains 4, match/switch 1 (nesting depth added 28). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
d2exporter.applyTheme (cognitive 61) d2exporter/export.go:80— d2exporter.applyTheme has cognitive complexity 61 (threshold 15). Drivers by points: if/else 23 (54 pts), boolean chains 7 (nesting depth added 31). 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.
placementcost.AxisScore (cognitive 61) d2layouts/d2talalayout/internal/placementcost/axis.go:11— placementcost.AxisScore has cognitive complexity 61 (threshold 15). Drivers by points: if/else 23 (48 pts), loops 7 (13 pts) (nesting depth added 31). 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.
routing.routeEdgesWithBudgets (cognitive 61) d2layouts/d2talalayout/internal/routing/standalone_router.go:27— routing.routeEdgesWithBudgets has cognitive complexity 61 (threshold 15). Drivers by points: if/else 33 (52 pts), loops 8, boolean chains 1 (nesting depth added 19). Of this number, 33 points are the body's own statements and 28 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.
d2oracle.deleteReserved (cognitive 61) d2oracle/edit.go:1313— d2oracle.deleteReserved has cognitive complexity 61 (threshold 15). Drivers by points: if/else 22 (55 pts), boolean chains 5, loops 1 (nesting depth added 33). 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.
meshBuilder.sequenceEdge (cognitive 61) d2renderers/d2isometric/d2isometricimg/sequence_routes.go:175— meshBuilder.sequenceEdge has cognitive complexity 61 (threshold 15). Drivers by points: if/else 18 (39 pts), boolean chains 12, loops 5 (10 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.
d2dagrelayout.adjustCrossRankSpacing (cognitive 60) d2layouts/d2dagrelayout/layout.go:1306— d2dagrelayout.adjustCrossRankSpacing has cognitive complexity 60 (threshold 15). Drivers by points: if/else 17 (43 pts), loops 5 (17 pts) (nesting depth added 38). 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.
placement.placeNodesOrthogonally (cognitive 60) REDACTED:246— placement.placeNodesOrthogonally has cognitive complexity 60 (threshold 15). Drivers by points: if/else 27 (45 pts), loops 8 (12 pts), boolean chains 3 (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.
OVGNode.hasUnobstructedLineToPorts (cognitive 60) d2layouts/d2talalayout/internal/routing/ovg_node.go:184— OVGNode.hasUnobstructedLineToPorts has cognitive complexity 60 (threshold 15). Drivers by points: if/else 15 (47 pts), boolean chains 7, loops 3 (6 pts) (nesting depth added 35). 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.
preflight.node (cognitive 60) d2renderers/d2raster/raster.go:977— preflight.node has cognitive complexity 60 (threshold 15). Drivers by points: if/else 33 (49 pts), boolean chains 7, loops 2, match/switch 1 (2 pts) (nesting depth added 17). 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.
placement.captureOptimizerNodePositions (cognitive 59) d2layouts/d2talalayout/internal/placement/optimization_guard.go:962— placement.captureOptimizerNodePositions has cognitive complexity 59 (threshold 15). Drivers by points: if/else 16 (44 pts), loops 6 (14 pts), boolean chains 1 (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.
svgImporter.stylesheetDeclarations (cognitive 59) d2renderers/d2svgimport/stylesheet.go:185— svgImporter.stylesheetDeclarations has cognitive complexity 59 (threshold 15). Drivers by points: if/else 20 (50 pts), loops 4 (7 pts), boolean chains 2 (nesting depth added 33). 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.
rasterimage.buildFramePNG (cognitive 59) internal/rasterimage/firstframe.go:524— rasterimage.buildFramePNG has cognitive complexity 59 (threshold 15). Drivers by points: if/else 23 (52 pts), boolean chains 4, match/switch 1 (2 pts), loops 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.
MarkdownLayout.SVG (cognitive 59) lib/textmeasure/markdown_svg.go:219— MarkdownLayout.SVG has cognitive complexity 59 (threshold 15). Drivers by points: if/else 20 (51 pts), boolean chains 3, loops 3, match/switch 1 (2 pts) (nesting depth added 32). 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.
d2cli.renderIsometricImages (cognitive 58) d2cli/isometric_image.go:120— d2cli.renderIsometricImages has cognitive complexity 58 (threshold 15). Drivers by points: if/else 27 (48 pts), boolean chains 6, loops 3 (4 pts) (nesting depth added 22). Of this number, 45 points are the body's own statements and 13 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.
ASCIIartist.calculateExtendedBounds (cognitive 58) d2renderers/d2ascii/d2ascii.go:133— ASCIIartist.calculateExtendedBounds has cognitive complexity 58 (threshold 15). Drivers by points: if/else 17 (51 pts), loops 2 (4 pts), boolean chains 3 (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.
d2raster.flattenScenePath (cognitive 58) d2renderers/d2raster/geometry.go:60— d2raster.flattenScenePath has cognitive complexity 58 (threshold 15). Drivers by points: if/else 22 (51 pts), boolean chains 4, match/switch 1 (2 pts), loops 1 (nesting depth added 30). Of this number, 50 points are the body's own statements and 8 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.
ThemableElement.Render (cognitive 58) d2themes/element.go:138— ThemableElement.Render has cognitive complexity 58 (threshold 15). Drivers by points: if/else 45 (53 pts), boolean chains 5 (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.
Graph.Texts (cognitive 57) d2graph/d2graph.go:1710— Graph.Texts has cognitive complexity 57 (threshold 15). Drivers by points: if/else 11 (27 pts), loops 12 (24 pts), boolean chains 6 (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.
compiler.IsContainer (cognitive 57) REDACTED:1032— compiler.IsContainer has cognitive complexity 57 (threshold 15). Drivers by points: if/else 10 (41 pts), loops 4 (12 pts), boolean chains 4 (nesting depth added 39). 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.
graphCloneState.copy (cognitive 57) REDACTED:86— graphCloneState.copy has cognitive complexity 57 (threshold 15). Drivers by points: if/else 25 (46 pts), loops 7 (9 pts), boolean chains 2 (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.
routing.routeInSShape (cognitive 57) d2layouts/d2talalayout/internal/routing/coordinator.go:725— routing.routeInSShape has cognitive complexity 57 (threshold 15). Drivers by points: if/else 17 (42 pts), boolean chains 9, loops 4, match/switch 1 (2 pts) (nesting depth added 26). Of this number, 18 points are the body's own statements and 39 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.
Diagram.BoundingBox (cognitive 57) d2target/d2target.go:450— Diagram.BoundingBox has cognitive complexity 57 (threshold 15). Drivers by points: if/else 22 (49 pts), boolean chains 4, loops 3 (4 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.
main.verifyArchive (cognitive 56) ci/release/releasetool/main.go:669— main.verifyArchive has cognitive complexity 56 (threshold 15). Drivers by points: if/else 22 (42 pts), boolean chains 10, loops 2, match/switch 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.
d2graph.compareSerializedObject (cognitive 56) REDACTED:231— d2graph.compareSerializedObject has cognitive complexity 56 (threshold 15). Drivers by points: if/else 34 (43 pts), boolean chains 11, loops 2 (nesting depth added 9). 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.
d2ir.walkVariableExpansion (cognitive 56) d2ir/expansion.go:193— d2ir.walkVariableExpansion has cognitive complexity 56 (threshold 15). Drivers by points: if/else 17 (43 pts), loops 4 (10 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 33). 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.
builder.preflightShape (cognitive 56) d2renderers/d2scenebuild/build.go:324— builder.preflightShape has cognitive complexity 56 (threshold 15). Drivers by points: if/else 22 (45 pts), boolean chains 7, match/switch 2 (4 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.
d2dagrelayout.adjustDeltaForEdges (cognitive 55) d2layouts/d2dagrelayout/layout.go:1712— d2dagrelayout.adjustDeltaForEdges has cognitive complexity 55 (threshold 15). Drivers by points: if/else 27 (50 pts), boolean chains 4, loops 1 (nesting depth added 23). Of this number, 35 points are the body's own statements and 20 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.
Graph.splitSubgraphsWithOwnership (cognitive 55) d2layouts/d2talalayout/internal/layoutgraph/graph.go:674— Graph.splitSubgraphsWithOwnership has cognitive complexity 55 (threshold 15). Drivers by points: if/else 27 (46 pts), loops 7 (8 pts), boolean chains 1 (nesting depth added 20). Of this number, 40 points are the body's own statements and 15 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.
quality.measureGeometry (cognitive 55) d2layouts/d2talalayout/internal/quality/inspection_geometry.go:15— quality.measureGeometry has cognitive complexity 55 (threshold 15). Drivers by points: if/else 13 (40 pts), loops 4 (8 pts), boolean chains 7 (nesting depth added 31). 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.
meshBuilder.rootDecorations (cognitive 55) d2renderers/d2isometric/d2isometricimg/source_panels.go:128— meshBuilder.rootDecorations has cognitive complexity 55 (threshold 15). Drivers by points: if/else 19 (41 pts), loops 4 (10 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.
d2raster.planPrimitiveResources (cognitive 55) d2renderers/d2raster/effects.go:502— d2raster.planPrimitiveResources has cognitive complexity 55 (threshold 15). Drivers by points: if/else 23 (55 pts) (nesting depth added 32). 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.
d2layouts.extractSubgraphs (cognitive 54) d2layouts/d2layouts.go:456— d2layouts.extractSubgraphs has cognitive complexity 54 (threshold 15). Drivers by points: if/else 17 (36 pts), loops 8 (13 pts), boolean chains 5 (nesting depth added 24). Of this number, 47 points are the body's own statements and 7 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.
OVG.addPorts (cognitive 54) REDACTED:233— OVG.addPorts has cognitive complexity 54 (threshold 15). Drivers by points: if/else 16 (40 pts), loops 7 (14 pts) (nesting depth added 31). 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.
trees.positionEdgeLabels (cognitive 54) d2layouts/d2talalayout/internal/trees/geometry.go:285— trees.positionEdgeLabels has cognitive complexity 54 (threshold 15). Drivers by points: if/else 19 (48 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 31). 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.
trees.placeTree (cognitive 54) d2layouts/d2talalayout/internal/trees/layout.go:750— trees.placeTree has cognitive complexity 54 (threshold 15). Drivers by points: if/else 23 (45 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 26). 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.
d2isometricimg.rasterSnapshot (cognitive 54) d2renderers/d2isometric/d2isometricimg/raster.go:307— d2isometricimg.rasterSnapshot has cognitive complexity 54 (threshold 15). Drivers by points: if/else 15 (43 pts), loops 2 (6 pts), match/switch 1 (5 pts) (nesting depth added 36). 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.
pathParser.number (cognitive 54) d2renderers/d2svgimport/path.go:324— pathParser.number has cognitive complexity 54 (threshold 15). Drivers by points: if/else 19 (37 pts), boolean chains 12, loops 3 (5 pts) (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.
markdownPainter.paintInlineNodes (cognitive 54) lib/textmeasure/markdown_svg.go:753— markdownPainter.paintInlineNodes has cognitive complexity 54 (threshold 15). Drivers by points: if/else 12 (34 pts), loops 9 (17 pts), boolean chains 3 (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.
Ruler.scaleUnicodeFallback (cognitive 54) lib/textmeasure/textmeasure.go:322— Ruler.scaleUnicodeFallback has cognitive complexity 54 (threshold 15). Drivers by points: if/else 12 (47 pts), loops 2 (5 pts), boolean chains 2 (nesting depth added 38). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
d2exporter.toConnection (cognitive 53) d2exporter/export.go:338— d2exporter.toConnection has cognitive complexity 53 (threshold 15). Drivers by points: if/else 37 (49 pts), boolean chains 3, loops 1 (nesting depth added 12). 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.
placement.BalanceSymmetry (cognitive 53) d2layouts/d2talalayout/internal/placement/symmetry.go:12— placement.BalanceSymmetry has cognitive complexity 53 (threshold 15). Drivers by points: if/else 20 (41 pts), loops 5 (9 pts), boolean chains 3 (nesting depth added 25). Of this number, 48 points are the body's own statements and 5 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.
routing.treeEdgePathForBuild (cognitive 53) d2layouts/d2talalayout/internal/routing/tree_routes.go:28— routing.treeEdgePathForBuild has cognitive complexity 53 (threshold 15). Drivers by points: if/else 18 (48 pts), loops 2 (5 pts) (nesting depth added 33). Of this number, 52 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
d2isometricimg.nativeLaneClear (cognitive 53) d2renderers/d2isometric/d2isometricimg/route_lanes.go:373— d2isometricimg.nativeLaneClear has cognitive complexity 53 (threshold 15). Drivers by points: if/else 10 (37 pts), loops 4 (11 pts), boolean chains 5 (nesting depth added 34). Of this number, 52 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.
d2isometricimg.RenderTimeline (cognitive 53) d2renderers/d2isometric/d2isometricimg/timeline.go:26— d2isometricimg.RenderTimeline has cognitive complexity 53 (threshold 15). Drivers by points: if/else 18 (33 pts), loops 7 (14 pts), boolean chains 6 (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.
svgImporter.validateNonRenderingTree (cognitive 53) d2renderers/d2svgimport/boilerplate.go:63— svgImporter.validateNonRenderingTree has cognitive complexity 53 (threshold 15). Drivers by points: if/else 14 (40 pts), match/switch 2 (5 pts), boolean chains 4, loops 3 (4 pts) (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.
svgImporter.parseStylesheet (cognitive 53) d2renderers/d2svgimport/stylesheet.go:66— svgImporter.parseStylesheet has cognitive complexity 53 (threshold 15). Drivers by points: if/else 17 (43 pts), loops 4 (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.
imageasset.probeResource (cognitive 53) lib/imageasset/probe.go:40— imageasset.probeResource has cognitive complexity 53 (threshold 15). Drivers by points: if/else 24 (50 pts), boolean chains 3 (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.
markdownPainter.wrapInlineTokens (cognitive 53) lib/textmeasure/markdown_svg.go:983— markdownPainter.wrapInlineTokens has cognitive complexity 53 (threshold 15). Drivers by points: if/else 16 (36 pts), boolean chains 10, loops 3 (6 pts), jumps 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.
hierarchy.markConflicts (cognitive 52) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:467— hierarchy.markConflicts has cognitive complexity 52 (threshold 15). Drivers by points: if/else 13 (37 pts), loops 5 (14 pts), boolean chains 1 (nesting depth added 33). Of this number, 51 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.
placement.orientSourceInterior (cognitive 52) d2layouts/d2talalayout/internal/placement/container_orientation.go:37— placement.orientSourceInterior has cognitive complexity 52 (threshold 15). Drivers by points: if/else 24 (35 pts), loops 8 (10 pts), boolean chains 7 (nesting depth added 13). Of this number, 36 points are the body's own statements and 16 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.
quality.findSharedSegments (cognitive 52) d2layouts/d2talalayout/internal/quality/labels.go:418— quality.findSharedSegments has cognitive complexity 52 (threshold 15). Drivers by points: if/else 22 (46 pts), loops 4 (6 pts) (nesting depth added 26). Of this number, 23 points are the body's own statements and 29 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.
meshBuilder.classicInkEdges (cognitive 52) d2renderers/d2isometric/d2isometricimg/native_edges.go:429— meshBuilder.classicInkEdges has cognitive complexity 52 (threshold 15). Drivers by points: if/else 19 (40 pts), loops 4 (7 pts), boolean chains 5 (nesting depth added 24). Of this number, 49 points are the body's own statements and 3 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.
d2svg.arrowheadMarker (cognitive 52) d2renderers/d2svg/d2svg.go:531— d2svg.arrowheadMarker has cognitive complexity 52 (threshold 15). Drivers by points: if/else 32 (48 pts), boolean chains 2, match/switch 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.
d2svg.pruneThemeCSSWithClasses (cognitive 52) d2renderers/d2svg/theme.go:19— d2svg.pruneThemeCSSWithClasses has cognitive complexity 52 (threshold 15). Drivers by points: if/else 11 (37 pts), loops 4 (11 pts), boolean chains 4 (nesting depth added 33). 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.
Key.D2OracleEquals (cognitive 51) d2ast/d2ast.go:813— Key.D2OracleEquals has cognitive complexity 51 (threshold 15). Drivers by points: if/else 25 (40 pts), loops 3 (6 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.
grouping.Cleanup (cognitive 51) d2layouts/d2talalayout/internal/grouping/lifecycle.go:126— grouping.Cleanup has cognitive complexity 51 (threshold 15). Drivers by points: loops 13 (29 pts), if/else 8 (22 pts) (nesting depth added 30). 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.
labeling.sortSharedSegmentGroup (cognitive 51) d2layouts/d2talalayout/internal/labeling/guard.go:557— labeling.sortSharedSegmentGroup has cognitive complexity 51 (threshold 15). Drivers by points: if/else 12 (37 pts), loops 5 (12 pts), boolean chains 2 (nesting depth added 32). Of this number, 50 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.
placement.moveNodeToBest (cognitive 51) d2layouts/d2talalayout/internal/placement/moves.go:16— placement.moveNodeToBest has cognitive complexity 51 (threshold 15). Drivers by points: if/else 22 (41 pts), boolean chains 7, match/switch 1 (2 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.
compiler.compileArray (cognitive 50) REDACTED:2285— compiler.compileArray has cognitive complexity 50 (threshold 15). Drivers by points: if/else 14 (43 pts), match/switch 2 (5 pts), boolean chains 1, loops 1 (nesting depth added 32). 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.
layoutgraph.buildTransactionOverlapsWithReferenceLimit (cognitive 50) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:509— layoutgraph.buildTransactionOverlapsWithReferenceLimit has cognitive complexity 50 (threshold 15). Drivers by points: if/else 19 (40 pts), boolean chains 4, loops 3 (4 pts), match/switch 1 (2 pts) (nesting depth added 23). Of this number, 42 points are the body's own statements and 8 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.
placement.Equidistance (cognitive 50) d2layouts/d2talalayout/internal/placement/equidistance.go:18— placement.Equidistance has cognitive complexity 50 (threshold 15). Drivers by points: if/else 18 (38 pts), loops 5 (11 pts), boolean chains 1 (nesting depth added 26). Of this number, 49 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.
placement.adjacents (cognitive 50) d2layouts/d2talalayout/internal/placement/metrics.go:105— placement.adjacents has cognitive complexity 50 (threshold 15). Drivers by points: if/else 16 (29 pts), loops 10 (18 pts), boolean chains 3 (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.
d2isometricimg.nativeDocumentGlyphCoverage (cognitive 50) d2renderers/d2isometric/d2isometricimg/surface_fonts.go:83— d2isometricimg.nativeDocumentGlyphCoverage has cognitive complexity 50 (threshold 15). Drivers by points: if/else 21 (42 pts), loops 4 (7 pts), boolean chains 1 (nesting depth added 24). Most of this is not in the body itself: 7 of the 50 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 131, 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.
meshBuilder.extrudedProfile (cognitive 50) d2renderers/d2isometric/d2isometricimg/native_shapes.go:651— meshBuilder.extrudedProfile has cognitive complexity 50 (threshold 15). Drivers by points: if/else 14 (37 pts), loops 7 (10 pts), boolean chains 3 (nesting depth added 26). Of this number, 49 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.
d2raster.multiplyLayerByAlpha (cognitive 50) d2renderers/d2raster/effects.go:1023— d2raster.multiplyLayerByAlpha has cognitive complexity 50 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 6 (19 pts), boolean chains 3, match/switch 1 (3 pts) (nesting depth added 32). 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.
main.writeArchive (cognitive 49) ci/release/releasetool/main.go:158— main.writeArchive has cognitive complexity 49 (threshold 15). Drivers by points: if/else 33 (43 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (nesting depth added 11). Of this number, 38 points are the body's own statements and 11 belong to 2 function literals 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.
labeling.isClusterPathSharedChecked (cognitive 49) d2layouts/d2talalayout/internal/labeling/placement.go:1189— labeling.isClusterPathSharedChecked has cognitive complexity 49 (threshold 15). Drivers by points: if/else 19 (42 pts), boolean chains 4, loops 2 (3 pts) (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.
sizedOptimizer.findClosestUnoccupiedDistanceGuarded (cognitive 49) REDACTED:528— sizedOptimizer.findClosestUnoccupiedDistanceGuarded has cognitive complexity 49 (threshold 15). Drivers by points: if/else 14 (40 pts), boolean chains 6, loops 2 (3 pts) (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.
routing.shortcutCandidateSafe (cognitive 49) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:227— routing.shortcutCandidateSafe has cognitive complexity 49 (threshold 15). Drivers by points: if/else 15 (33 pts), boolean chains 8, loops 5 (8 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.
Raster.renderStrips (cognitive 49) d2renderers/d2isometric/d2isometricimg/raster.go:396— Raster.renderStrips has cognitive complexity 49 (threshold 15). Drivers by points: if/else 14 (28 pts), loops 7 (16 pts), boolean chains 5 (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.
d2raster.compositeCOLRv1SoftLightLayer (cognitive 49) d2renderers/d2raster/effects.go:1391— d2raster.compositeCOLRv1SoftLightLayer has cognitive complexity 49 (threshold 15). Drivers by points: if/else 12 (39 pts), loops 4 (9 pts), boolean chains 1 (nesting depth added 32). 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.
prepare.main (cognitive 49) ci/release/prepare.py:27— prepare.main has cognitive complexity 49 (threshold 15). Drivers by points: if/else 27 (30 pts), boolean chains 16, loops 2, 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.
compiler.extendLinks (cognitive 48) REDACTED:1928— compiler.extendLinks has cognitive complexity 48 (threshold 15). Drivers by points: if/else 13 (36 pts), boolean chains 8, loops 2 (4 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.
layoutgraph.transactionSweepPadding (cognitive 48) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:407— layoutgraph.transactionSweepPadding has cognitive complexity 48 (threshold 15). Drivers by points: if/else 15 (38 pts), loops 6 (9 pts), boolean chains 1 (nesting depth added 26). 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.
Node.IsBlocked (cognitive 48) d2layouts/d2talalayout/internal/layoutgraph/node.go:1172— Node.IsBlocked has cognitive complexity 48 (threshold 15). Drivers by points: if/else 20 (40 pts), boolean chains 8 (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.
placement.nearestConnectedAhead (cognitive 48) d2layouts/d2talalayout/internal/placement/gapreduction.go:197— placement.nearestConnectedAhead has cognitive complexity 48 (threshold 15). Drivers by points: if/else 14 (43 pts), boolean chains 4, loops 1 (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.
OVG.addIntersections (cognitive 48) REDACTED:330— OVG.addIntersections has cognitive complexity 48 (threshold 15). Drivers by points: if/else 21 (43 pts), loops 4 (5 pts) (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.
meshBuilder.routeCaptionKnockout (cognitive 48) d2renderers/d2isometric/d2isometricimg/route_caption_mask.go:10— meshBuilder.routeCaptionKnockout has cognitive complexity 48 (threshold 15). Drivers by points: if/else 11 (34 pts), loops 4 (9 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 30). Of this number, 45 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.
d2raster.compositeLayerOverOpaquePartialPrefix (cognitive 48) d2renderers/d2raster/effects.go:1689— d2raster.compositeLayerOverOpaquePartialPrefix has cognitive complexity 48 (threshold 15). Drivers by points: if/else 11 (37 pts), loops 4 (9 pts), boolean chains 2 (nesting depth added 31). 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.
builder.compileLinkRegions (cognitive 48) d2renderers/d2scenebuild/metadata.go:16— builder.compileLinkRegions has cognitive complexity 48 (threshold 15). Drivers by points: if/else 20 (38 pts), boolean chains 5, loops 4 (5 pts) (nesting depth added 19). Of this number, 47 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.
builder.buildSketchStructuredShape (cognitive 48) d2renderers/d2scenebuild/sketch_shapes.go:592— builder.buildSketchStructuredShape has cognitive complexity 48 (threshold 15). Drivers by points: if/else 15 (40 pts), boolean chains 5, match/switch 1 (2 pts), loops 1 (nesting depth added 26). 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.
d2svg.dimensions (cognitive 48) d2renderers/d2svg/d2svg.go:178— d2svg.dimensions has cognitive complexity 48 (threshold 15). Drivers by points: if/else 12 (37 pts), loops 2 (6 pts), boolean chains 5 (nesting depth added 29). 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.
d2target.stabilizeHashURLs (cognitive 48) d2target/d2target.go:250— d2target.stabilizeHashURLs has cognitive complexity 48 (threshold 15). Drivers by points: if/else 17 (42 pts), loops 2 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 27). Most of this is not in the body itself: 1 of the 48 points is its own statement and the rest belongs to one function literal inside it that branches (line 256). 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.
d2dagrelayout.adjustEdges (cognitive 47) d2layouts/d2dagrelayout/layout.go:1802— d2dagrelayout.adjustEdges has cognitive complexity 47 (threshold 15). Drivers by points: if/else 20 (42 pts), boolean chains 4, loops 1 (nesting depth added 22). Most of this is not in the body itself: 5 of the 47 points are its own statements and the rest belongs to one function literal inside it that branches (line 1803). 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.
rankSimplex.optimize (cognitive 47) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:281— rankSimplex.optimize has cognitive complexity 47 (threshold 15). Drivers by points: if/else 15 (38 pts), loops 4 (7 pts), boolean chains 2 (nesting depth added 26). 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.
packing.snapshotCombineNodePositions (cognitive 47) d2layouts/d2talalayout/internal/packing/combine_snapshot.go:25— packing.snapshotCombineNodePositions has cognitive complexity 47 (threshold 15). Drivers by points: if/else 16 (35 pts), loops 5 (12 pts) (nesting depth added 26). Of this number, 43 points are the body's own statements and 4 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.
placement.snapshotNodePositionsContext (cognitive 47) d2layouts/d2talalayout/internal/placement/types.go:47— placement.snapshotNodePositionsContext has cognitive complexity 47 (threshold 15). Drivers by points: if/else 16 (35 pts), loops 5 (12 pts) (nesting depth added 26). Of this number, 43 points are the body's own statements and 4 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.
routing.finalizeSelectedRoutes (cognitive 47) d2layouts/d2talalayout/internal/routing/coordinator.go:205— routing.finalizeSelectedRoutes has cognitive complexity 47 (threshold 15). Drivers by points: if/else 20 (38 pts), loops 5 (7 pts), boolean chains 2 (nesting depth added 20). Of this number, 46 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.
routing.routeAdditionalEdgesWithResourceLimits (cognitive 47) d2layouts/d2talalayout/internal/routing/coordinator.go:531— routing.routeAdditionalEdgesWithResourceLimits has cognitive complexity 47 (threshold 15). Drivers by points: if/else 21 (40 pts), loops 5 (6 pts), boolean chains 1 (nesting depth added 20). Of this number, 31 points are the body's own statements and 16 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.
trees.handleTreeSubgraph (cognitive 47) d2layouts/d2talalayout/internal/trees/layout.go:251— trees.handleTreeSubgraph has cognitive complexity 47 (threshold 15). Drivers by points: if/else 16 (39 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 26). 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.
d2isometricimg.nativeShapeProfile (cognitive 47) d2renderers/d2isometric/d2isometricimg/native_shapes.go:510— d2isometricimg.nativeShapeProfile has cognitive complexity 47 (threshold 15). Drivers by points: if/else 11 (25 pts), loops 6 (15 pts), boolean chains 4, match/switch 1 (3 pts) (nesting depth added 25). 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 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.
Rasterizer.accumulateEdgeRow (cognitive 47) REDACTED:1169— Rasterizer.accumulateEdgeRow has cognitive complexity 47 (threshold 15). Drivers by points: if/else 20 (40 pts), loops 2 (5 pts), boolean chains 2 (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.
xgif.buildFewOpaquePaletted (cognitive 47) lib/xgif/xgif.go:392— xgif.buildFewOpaquePaletted has cognitive complexity 47 (threshold 15). Drivers by points: if/else 12 (27 pts), loops 11 (19 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.
d2cli.renderGIFWithSession (cognitive 46) d2cli/raster.go:555— d2cli.renderGIFWithSession has cognitive complexity 46 (threshold 15). Drivers by points: if/else 27 (44 pts), boolean chains 1, loops 1 (nesting depth added 17). Of this number, 35 points are the body's own statements and 11 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.
compiler.compileEdgeMap (cognitive 46) d2compiler/compile.go:1247— compiler.compileEdgeMap has cognitive complexity 46 (threshold 15). Drivers by points: if/else 14 (38 pts), loops 3 (7 pts), boolean chains 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.
d2elklayout.ConvertGraph (cognitive 46) d2layouts/d2elklayout/wasm.go:23— d2elklayout.ConvertGraph has cognitive complexity 46 (threshold 15). Drivers by points: if/else 16 (22 pts), match/switch 7 (12 pts), loops 6 (8 pts), boolean chains 4 (nesting depth added 13). Of this number, 16 points are the body's own statements and 30 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.
grouping.buildClusterDiscoveryIndex (cognitive 46) d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:265— grouping.buildClusterDiscoveryIndex has cognitive complexity 46 (threshold 15). Drivers by points: if/else 17 (35 pts), loops 7 (9 pts), boolean chains 2 (nesting depth added 20). Of this number, 42 points are the body's own statements and 4 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.
placement.initializeNodes (cognitive 46) d2layouts/d2talalayout/internal/placement/initialize.go:14— placement.initializeNodes has cognitive complexity 46 (threshold 15). Drivers by points: if/else 20 (31 pts), loops 8 (15 pts) (nesting depth added 18). Of this number, 34 points are the body's own statements and 12 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.
routing.validateRouteStageGeometry (cognitive 46) d2layouts/d2talalayout/internal/routing/route_stage_guard.go:278— routing.validateRouteStageGeometry has cognitive complexity 46 (threshold 15). Drivers by points: if/else 23 (34 pts), loops 7 (8 pts), boolean chains 4 (nesting depth added 12). Of this number, 16 points are the body's own statements and 30 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.
Route.canSwapEdgesGuarded (cognitive 46) d2layouts/d2talalayout/internal/routing/route.go:202— Route.canSwapEdgesGuarded has cognitive complexity 46 (threshold 15). Drivers by points: if/else 18 (36 pts), boolean chains 9, loops 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.
d2oracle.ReconnectEdgeIDDeltas (cognitive 46) d2oracle/edit.go:2500— d2oracle.ReconnectEdgeIDDeltas has cognitive complexity 46 (threshold 15). Drivers by points: if/else 25 (40 pts), boolean chains 4, loops 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.
d2isometricimg.richLabelDocumentWithResources (cognitive 46) d2renderers/d2isometric/d2isometricimg/rich_labels.go:222— d2isometricimg.richLabelDocumentWithResources has cognitive complexity 46 (threshold 15). Drivers by points: if/else 30 (41 pts), boolean chains 5 (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.
meshBuilder.classicInkJunctions (cognitive 46) d2renderers/d2isometric/d2isometricimg/native_ink_joins.go:12— meshBuilder.classicInkJunctions has cognitive complexity 46 (threshold 15). Drivers by points: if/else 13 (33 pts), loops 7 (11 pts), boolean chains 2 (nesting depth added 24). Of this number, 44 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.
d2raster.prepareWithSessionBands (cognitive 46) d2renderers/d2raster/raster.go:615— d2raster.prepareWithSessionBands has cognitive complexity 46 (threshold 15). Drivers by points: if/else 36 (40 pts), boolean chains 4, loops 1 (2 pts) (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.
d2raster.flattenGlyph (cognitive 46) d2renderers/d2raster/text.go:626— d2raster.flattenGlyph has cognitive complexity 46 (threshold 15). Drivers by points: if/else 18 (37 pts), loops 3 (4 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 21). Of this number, 37 points are the body's own statements and 9 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.
builder.buildConnectionLabels (cognitive 46) d2renderers/d2scenebuild/labels.go:159— builder.buildConnectionLabels has cognitive complexity 46 (threshold 15). Drivers by points: if/else 19 (44 pts), boolean chains 1, loops 1 (nesting depth added 25). 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.
placement.inflateAlongAxis (cognitive 45) d2layouts/d2talalayout/internal/placement/compaction.go:330— placement.inflateAlongAxis has cognitive complexity 45 (threshold 15). Drivers by points: if/else 17 (42 pts), boolean chains 2, loops 1 (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.
builder.preflightAssets (cognitive 45) d2renderers/d2scenebuild/assets.go:27— builder.preflightAssets has cognitive complexity 45 (threshold 15). Drivers by points: if/else 17 (37 pts), loops 5 (6 pts), boolean chains 2 (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.
d2sketch.ConnectionDrawable (cognitive 45) d2renderers/d2sketch/scene_connection.go:25— d2sketch.ConnectionDrawable has cognitive complexity 45 (threshold 15). Drivers by points: if/else 17 (33 pts), loops 4 (6 pts), match/switch 2 (4 pts), boolean chains 2 (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.
svgImporter.compileClipPathResource (cognitive 45) d2renderers/d2svgimport/clip.go:113— svgImporter.compileClipPathResource has cognitive complexity 45 (threshold 15). Drivers by points: if/else 20 (44 pts), loops 1 (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.
transformParser.number (cognitive 45) d2renderers/d2svgimport/transform.go:142— transformParser.number has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (29 pts), boolean chains 11, loops 3 (5 pts) (nesting depth added 17). 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.
d2wasm.Compile (cognitive 45) d2js/d2wasm/functions.go:196— d2wasm.Compile has cognitive complexity 45 (threshold 15). Drivers by points: if/else 26 (29 pts), boolean chains 15, match/switch 1 (nesting depth added 3). Of this number, 43 points are the body's own statements and 2 belong to 2 function literals 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.
watcher.watchLoop (cognitive 44) REDACTED:244— watcher.watchLoop has cognitive complexity 44 (threshold 15). Drivers by points: if/else 10 (31 pts), loops 4 (10 pts), match/switch 1 (2 pts), boolean chains 1 (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.
compiler.validateKey (cognitive 44) d2compiler/compile.go:1510— compiler.validateKey has cognitive complexity 44 (threshold 15). Drivers by points: if/else 11 (29 pts), boolean chains 11, match/switch 2 (4 pts) (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.
Object.GetDefaultSize (cognitive 44) d2graph/d2graph.go:996— Object.GetDefaultSize has cognitive complexity 44 (threshold 15). Drivers by points: if/else 17 (37 pts), loops 3 (6 pts), match/switch 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.
rankSimplex.computeCutValues (cognitive 44) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:354— rankSimplex.computeCutValues has cognitive complexity 44 (threshold 15). Drivers by points: if/else 18 (36 pts), loops 6 (7 pts), boolean chains 1 (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.
layoutgraph.ValidatePositionedGraphSelection (cognitive 44) d2layouts/d2talalayout/internal/layoutgraph/positioned_validation.go:16— layoutgraph.ValidatePositionedGraphSelection has cognitive complexity 44 (threshold 15). Drivers by points: if/else 26 (35 pts), boolean chains 5, loops 4 (nesting depth added 9). Of this number, 27 points are the body's own statements and 17 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.
Node.deltaToGuarded (cognitive 44) d2layouts/d2talalayout/internal/layoutgraph/node.go:788— Node.deltaToGuarded has cognitive complexity 44 (threshold 15). Drivers by points: if/else 21 (35 pts), boolean chains 5, match/switch 3, loops 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.
routing.traceToShapeBorder (cognitive 44) d2layouts/d2talalayout/internal/routing/trace.go:27— routing.traceToShapeBorder has cognitive complexity 44 (threshold 15). Drivers by points: if/else 17 (35 pts), boolean chains 9 (nesting depth added 18). Of this number, 42 points are the body's own statements and 2 belong to one function literal inside it that branches. 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.
OVG.fixedOverlapsForBuild (cognitive 44) d2layouts/d2talalayout/internal/routing/ovg_resource.go:607— OVG.fixedOverlapsForBuild has cognitive complexity 44 (threshold 15). Drivers by points: if/else 14 (37 pts), loops 4 (5 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.
routeCaptionPlacer.Place (cognitive 44) d2renderers/d2isometric/d2isometricimg/route_labels.go:58— routeCaptionPlacer.Place has cognitive complexity 44 (threshold 15). Drivers by points: if/else 14 (31 pts), boolean chains 7, loops 3 (6 pts) (nesting depth added 20). Of this number, 43 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.
builder.measureLegend (cognitive 44) d2renderers/d2scenebuild/legend.go:147— builder.measureLegend has cognitive complexity 44 (threshold 15). Drivers by points: if/else 26 (35 pts), boolean chains 6, loops 3 (nesting depth added 9). Of this number, 40 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.
svgImporter.attributes (cognitive 44) d2renderers/d2svgimport/import.go:770— svgImporter.attributes has cognitive complexity 44 (threshold 15). Drivers by points: if/else 17 (39 pts), boolean chains 2, match/switch 1 (2 pts), loops 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.
main.verifyStripped (cognitive 43) ci/release/releasetool/main.go:612— main.verifyStripped has cognitive complexity 43 (threshold 15). Drivers by points: if/else 11 (27 pts), loops 4 (9 pts), boolean chains 6, match/switch 1 (nesting depth added 21). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
printer._map (cognitive 43) d2format/format.go:287— printer._map has cognitive complexity 43 (threshold 15). Drivers by points: if/else 16 (34 pts), boolean chains 7, loops 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.
d2sequence.newSequenceDiagram (cognitive 43) d2layouts/d2sequence/sequence_diagram.go:78— d2sequence.newSequenceDiagram has cognitive complexity 43 (threshold 15). Drivers by points: if/else 15 (29 pts), loops 6 (11 pts), match/switch 1 (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.
d2talalayout.validateTopology (cognitive 43) d2layouts/d2talalayout/result_validate.go:37— d2talalayout.validateTopology has cognitive complexity 43 (threshold 15). Drivers by points: if/else 18 (34 pts), loops 5, boolean chains 4 (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.
GraphState.captureGeometryStateContext (cognitive 43) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:278— GraphState.captureGeometryStateContext has cognitive complexity 43 (threshold 15). Drivers by points: if/else 11 (30 pts), loops 6 (13 pts) (nesting depth added 26). 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.
placement.optimizerDescendants (cognitive 43) d2layouts/d2talalayout/internal/placement/optimization_guard.go:602— placement.optimizerDescendants has cognitive complexity 43 (threshold 15). Drivers by points: if/else 18 (32 pts), loops 4 (8 pts), boolean chains 3 (nesting depth added 18). Most of this is not in the body itself: 8 of the 43 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 629, 612). 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.
OVG.addTreeNodes (cognitive 43) REDACTED:739— OVG.addTreeNodes has cognitive complexity 43 (threshold 15). Drivers by points: if/else 14 (42 pts), loops 1 (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.
d2isometricimg.writeSVGGroundShadow (cognitive 43) d2renderers/d2isometric/d2isometricimg/svg_lighting.go:274— d2isometricimg.writeSVGGroundShadow has cognitive complexity 43 (threshold 15). Drivers by points: if/else 15 (30 pts), loops 6 (10 pts), boolean chains 3 (nesting depth added 19). Of this number, 41 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.
builder.arrowhead (cognitive 43) d2renderers/d2scenebuild/connection.go:430— builder.arrowhead has cognitive complexity 43 (threshold 15). Drivers by points: if/else 24 (38 pts), boolean chains 2, loops 2, match/switch 1 (nesting depth added 14). Of this number, 41 points are the body's own statements and 2 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.
svgImporter.compileElement (cognitive 43) d2renderers/d2svgimport/compile.go:242— svgImporter.compileElement has cognitive complexity 43 (threshold 15). Drivers by points: if/else 26 (37 pts), boolean chains 5, 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.
labeling.sortLabelPlacementEdges (cognitive 42) d2layouts/d2talalayout/internal/labeling/guard.go:486— labeling.sortLabelPlacementEdges has cognitive complexity 42 (threshold 15). Drivers by points: if/else 10 (25 pts), loops 7 (14 pts), boolean chains 3 (nesting depth added 22). Of this number, 38 points are the body's own statements and 4 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.
packing.blocksRoutesWithDeltasGuarded (cognitive 42) d2layouts/d2talalayout/internal/packing/binpack.go:1129— packing.blocksRoutesWithDeltasGuarded has cognitive complexity 42 (threshold 15). Drivers by points: if/else 12 (33 pts), loops 5 (9 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.
routing.positionedArrowheadLabelCostGuarded (cognitive 42) d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:207— routing.positionedArrowheadLabelCostGuarded has cognitive complexity 42 (threshold 15). Drivers by points: if/else 14 (33 pts), loops 6 (8 pts), boolean chains 1 (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.
meshBuilder.canonicalNode (cognitive 42) d2renderers/d2isometric/d2isometricimg/native_shapes.go:313— meshBuilder.canonicalNode has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (26 pts), loops 5 (12 pts), boolean chains 4 (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.
d2isometric.classifySequence (cognitive 42) d2renderers/d2isometric/sequence.go:15— d2isometric.classifySequence has cognitive complexity 42 (threshold 15). Drivers by points: if/else 11 (23 pts), loops 9 (11 pts), boolean chains 6, match/switch 1 (2 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.
d2raster.addStrokeRun (cognitive 42) d2renderers/d2raster/geometry.go:677— d2raster.addStrokeRun has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (32 pts), loops 3 (5 pts), boolean chains 4, match/switch 1 (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.
retainedVectorValidator.path (cognitive 42) d2renderers/d2raster/vector_validation.go:519— retainedVectorValidator.path has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (36 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (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.
d2scenebuild.flattenSketchPath (cognitive 42) d2renderers/d2scenebuild/sketch_shapes.go:318— d2scenebuild.flattenSketchPath has cognitive complexity 42 (threshold 15). Drivers by points: if/else 16 (34 pts), loops 2 (4 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 21). Of this number, 36 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.
d2svgimport.inspectEmbeddedGIF (cognitive 42) d2renderers/d2svgimport/image.go:492— d2svgimport.inspectEmbeddedGIF has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (39 pts), match/switch 1 (2 pts), loops 1 (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.
d2layoutfeatures.Check (cognitive 42) internal/d2layoutfeatures/features.go:21— d2layoutfeatures.Check has cognitive complexity 42 (threshold 15). Drivers by points: if/else 12 (32 pts), boolean chains 6, loops 2 (3 pts), match/switch 1 (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.
rasterimage.DecodeFirst (cognitive 42) internal/rasterimage/firstframe.go:87— rasterimage.DecodeFirst has cognitive complexity 42 (threshold 15). Drivers by points: if/else 20 (39 pts), boolean chains 2, match/switch 1 (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.
run.run (cognitive 42) ci/nonlayout-perf/run.py:41— run.run has cognitive complexity 42 (threshold 15). Drivers by points: if/else 17 (33 pts), loops 3 (5 pts), boolean chains 2, ternaries 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.
graphbounds.NodeBoundingBox (cognitive 41) d2layouts/d2talalayout/internal/graphbounds/bounds.go:45— graphbounds.NodeBoundingBox has cognitive complexity 41 (threshold 15). Drivers by points: if/else 17 (37 pts), boolean chains 4 (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.
labeling.clusterNodeBoundingBoxPlacement (cognitive 41) d2layouts/d2talalayout/internal/labeling/guard.go:325— labeling.clusterNodeBoundingBoxPlacement has cognitive complexity 41 (threshold 15). Drivers by points: if/else 17 (37 pts), boolean chains 4 (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.
Graph.doesOverlapWithDimensionsContext (cognitive 41) d2layouts/d2talalayout/internal/layoutgraph/graph.go:338— Graph.doesOverlapWithDimensionsContext has cognitive complexity 41 (threshold 15). Drivers by points: if/else 15 (34 pts), boolean chains 4, loops 2 (3 pts) (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.
Transaction.markDescendantOverlapExceptions (cognitive 41) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1021— Transaction.markDescendantOverlapExceptions has cognitive complexity 41 (threshold 15). Drivers by points: if/else 16 (29 pts), loops 5 (9 pts), boolean chains 3 (nesting depth added 17). Of this number, 17 points are the body's own statements and 24 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.
sizedOptimizer.findUnoccupiedGuarded (cognitive 41) REDACTED:619— sizedOptimizer.findUnoccupiedGuarded has cognitive complexity 41 (threshold 15). Drivers by points: if/else 16 (37 pts), loops 2 (3 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.
routing.buildTunnels (cognitive 41) d2layouts/d2talalayout/internal/routing/tunnel.go:366— routing.buildTunnels has cognitive complexity 41 (threshold 15). Drivers by points: if/else 14 (34 pts), loops 5 (7 pts) (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.
trees.treeContainerRDFSOrder (cognitive 41) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:20— trees.treeContainerRDFSOrder has cognitive complexity 41 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 4 (8 pts), boolean chains 1 (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.
parser.parseMap (cognitive 41) d2parser/parse.go:443— parser.parseMap has cognitive complexity 41 (threshold 15). Drivers by points: if/else 14 (34 pts), loops 2 (3 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 22). 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.
Rasterizer.rasterize (cognitive 41) REDACTED:1026— Rasterizer.rasterize has cognitive complexity 41 (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.
svgImporter.parseEmbeddedRasterDataURI (cognitive 41) d2renderers/d2svgimport/image.go:199— svgImporter.parseEmbeddedRasterDataURI has cognitive complexity 41 (threshold 15). Drivers by points: if/else 16 (29 pts), boolean chains 9, loops 2, match/switch 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.
main.discoverTests (cognitive 41) e2etests/report/main.go:46— main.discoverTests has cognitive complexity 41 (threshold 15). Drivers by points: if/else 23 (30 pts), boolean chains 7, loops 2, match/switch 1 (2 pts) (nesting depth added 8). Of this number, 23 points are the body's own statements and 18 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.
textmeasure.newMarkdownSubstitutionMatcher (cognitive 41) lib/textmeasure/substitutions.go:139— textmeasure.newMarkdownSubstitutionMatcher has cognitive complexity 41 (threshold 15). Drivers by points: if/else 12 (31 pts), loops 6 (10 pts) (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.
d2cli.bundleRasterPreview (cognitive 40) d2cli/raster.go:756— d2cli.bundleRasterPreview has cognitive complexity 40 (threshold 15). Drivers by points: if/else 19 (34 pts), loops 4, 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.
routing.sourceAndTargetClusterNodesGuarded (cognitive 40) d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:115— routing.sourceAndTargetClusterNodesGuarded has cognitive complexity 40 (threshold 15). Drivers by points: if/else 10 (31 pts), loops 4 (9 pts) (nesting depth added 26). 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.
d2lib.compileBoard (cognitive 40) d2lib/d2.go:184— d2lib.compileBoard has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (32 pts), boolean chains 5, loops 3 (nesting depth added 17). 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.
d2oracle.generateUniqueKey (cognitive 40) d2oracle/edit.go:2650— d2oracle.generateUniqueKey has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (32 pts), loops 3 (5 pts), boolean chains 3 (nesting depth added 19). 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.
d2isometricimg.newRaster (cognitive 40) d2renderers/d2isometric/d2isometricimg/raster.go:165— d2isometricimg.newRaster has cognitive complexity 40 (threshold 15). Drivers by points: if/else 22 (31 pts), boolean chains 5, 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.
meshBuilder.hierarchyBoard (cognitive 40) d2renderers/d2isometric/d2isometricimg/hierarchy_boards.go:296— meshBuilder.hierarchyBoard has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (23 pts), loops 4 (10 pts), boolean chains 7 (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.
d2isometric.composeHierarchy (cognitive 40) REDACTED:13— d2isometric.composeHierarchy has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (29 pts), loops 7 (10 pts), boolean chains 1 (nesting depth added 17). 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.
d2raster.paintDropShadowInteger (cognitive 40) d2renderers/d2raster/filter.go:955— d2raster.paintDropShadowInteger has cognitive complexity 40 (threshold 15). Drivers by points: if/else 14 (32 pts), boolean chains 5, loops 2 (3 pts) (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.
d2raster.drawSampledPreparedImage (cognitive 40) d2renderers/d2raster/image.go:1022— d2raster.drawSampledPreparedImage has cognitive complexity 40 (threshold 15). Drivers by points: if/else 7 (25 pts), loops 5 (13 pts), boolean chains 2 (nesting depth added 26). 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.
imagediff.CompareImages (cognitive 40) REDACTED:118— imagediff.CompareImages has cognitive complexity 40 (threshold 15). Drivers by points: if/else 17 (29 pts), loops 3 (6 pts), boolean chains 5 (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.
xgif.quantizeFewOpaqueColorsWithWorkspace (cognitive 40) lib/xgif/xgif.go:309— xgif.quantizeFewOpaqueColorsWithWorkspace has cognitive complexity 40 (threshold 15). Drivers by points: if/else 11 (34 pts), loops 3 (6 pts) (nesting depth added 26). 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.
d2cli.relink (cognitive 39) d2cli/main.go:817— d2cli.relink has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (28 pts), loops 7 (11 pts) (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.
bendCollisionIndex.countEdgeIntersects (cognitive 39) d2layouts/d2elklayout/spatial_index.go:269— bendCollisionIndex.countEdgeIntersects has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (39 pts) (nesting depth added 27). None of this is in the body itself: all 39 points belong to one function literal inside it that branches (line 276). 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.
d2grid.newGridDiagram (cognitive 39) d2layouts/d2grid/grid_diagram.go:28— d2grid.newGridDiagram has cognitive complexity 39 (threshold 15). Drivers by points: if/else 21 (34 pts), boolean chains 4, loops 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.
Graph.isStructurallyBadStateWithFixedOriginContext (cognitive 39) d2layouts/d2talalayout/internal/layoutgraph/graph.go:128— Graph.isStructurallyBadStateWithFixedOriginContext has cognitive complexity 39 (threshold 15). Drivers by points: if/else 15 (28 pts), boolean chains 8, loops 1 (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.
Node.boundingBoxValues (cognitive 39) d2layouts/d2talalayout/internal/layoutgraph/node.go:93— Node.boundingBoxValues has cognitive complexity 39 (threshold 15). Drivers by points: if/else 20 (36 pts), boolean chains 3 (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.
packing.binPackHasExternalConnection (cognitive 39) d2layouts/d2talalayout/internal/packing/guard.go:86— packing.binPackHasExternalConnection has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (31 pts), loops 4 (7 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.
placement.optimizerMedian (cognitive 39) d2layouts/d2talalayout/internal/placement/optimization_guard.go:332— placement.optimizerMedian has cognitive complexity 39 (threshold 15). Drivers by points: if/else 22 (34 pts), boolean chains 4, loops 1 (nesting depth added 12). Of this number, 35 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.
routing.nudgeChannelsGuarded (cognitive 39) d2layouts/d2talalayout/internal/routing/nudge_channels.go:50— routing.nudgeChannelsGuarded has cognitive complexity 39 (threshold 15). Drivers by points: if/else 14 (32 pts), loops 3 (6 pts), boolean chains 1 (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.
OVG.addEdgesNodes (cognitive 39) REDACTED:433— OVG.addEdgesNodes has cognitive complexity 39 (threshold 15). Drivers by points: if/else 15 (35 pts), loops 2 (3 pts), boolean chains 1 (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.
asciishapes.DrawPerson (cognitive 39) d2renderers/d2ascii/asciishapes/person.go:5— asciishapes.DrawPerson has cognitive complexity 39 (threshold 15). Drivers by points: if/else 8 (23 pts), boolean chains 10, loops 2 (3 pts), match/switch 1 (3 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.
meshBuilder.arrowRetreat (cognitive 39) d2renderers/d2isometric/d2isometricimg/arrow_visibility.go:328— meshBuilder.arrowRetreat has cognitive complexity 39 (threshold 15). Drivers by points: if/else 13 (29 pts), boolean chains 5, loops 3 (5 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.
d2raster.boxBlurRGBAExpanded (cognitive 39) d2renderers/d2raster/filter.go:560— d2raster.boxBlurRGBAExpanded has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (31 pts), loops 4 (8 pts) (nesting depth added 26). 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 (d2raster.boxBlurAlphaPixelsExpanded) 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.
d2raster.boxBlurAlphaPixelsExpanded (cognitive 39) d2renderers/d2raster/filter.go:778— d2raster.boxBlurAlphaPixelsExpanded has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (31 pts), loops 4 (8 pts) (nesting depth added 26). 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 (d2raster.boxBlurRGBAExpanded) 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.
d2raster.planFilterResources (cognitive 39) d2renderers/d2raster/filter.go:1214— d2raster.planFilterResources has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (30 pts), loops 3 (7 pts), match/switch 1 (2 pts) (nesting depth added 26). 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.
d2raster.drawDirectPatternMaskPixels (cognitive 39) d2renderers/d2raster/gradient.go:1022— d2raster.drawDirectPatternMaskPixels has cognitive complexity 39 (threshold 15). Drivers by points: if/else 14 (34 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 21). Of this number, 37 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.
svgImporter.validateClipTree (cognitive 39) d2renderers/d2svgimport/clip.go:38— svgImporter.validateClipTree has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (32 pts), boolean chains 4, loops 2 (3 pts) (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.
imageasset.expandDeclaredSVG (cognitive 39) lib/imageasset/probe.go:148— imageasset.expandDeclaredSVG has cognitive complexity 39 (threshold 15). Drivers by points: if/else 15 (35 pts), boolean chains 3, 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.
markdownPainter.atomizeInlineTokens (cognitive 39) lib/textmeasure/markdown_svg.go:1191— markdownPainter.atomizeInlineTokens has cognitive complexity 39 (threshold 15). Drivers by points: if/else 7 (22 pts), loops 6 (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.
d2compiler.compileConfig (cognitive 38) d2compiler/compile.go:1823— d2compiler.compileConfig has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15 (19 pts), match/switch 2 (10 pts), loops 2 (7 pts), boolean chains 2 (nesting depth added 17). 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.
Graph.allDescendantNodesGuarded (cognitive 38) d2layouts/d2talalayout/internal/layoutgraph/graph.go:955— Graph.allDescendantNodesGuarded has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15 (28 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 17). Most of this is not in the body itself: 14 of the 38 points are its own statements and the rest belongs to one function literal inside it that branches (line 971). 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.
Graph.buildNodeToTreeGuarded (cognitive 38) d2layouts/d2talalayout/internal/layoutgraph/tree_access.go:48— Graph.buildNodeToTreeGuarded has cognitive complexity 38 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 5 (11 pts), boolean chains 2 (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.
Node.isVisibilityGraphCandidate (cognitive 38) d2layouts/d2talalayout/internal/layoutgraph/node.go:1359— Node.isVisibilityGraphCandidate has cognitive complexity 38 (threshold 15). Drivers by points: if/else 16 (36 pts), boolean chains 2 (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.
packing.placementCandidatesGuarded (cognitive 38) d2layouts/d2talalayout/internal/packing/binpack.go:1032— packing.placementCandidatesGuarded has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 2 (4 pts), match/switch 1 (4 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.
placement.mirrorAxes (cognitive 38) d2layouts/d2talalayout/internal/placement/direct.go:167— placement.mirrorAxes has cognitive complexity 38 (threshold 15). Drivers by points: if/else 19 (28 pts), loops 5 (6 pts), boolean chains 4 (nesting depth added 10). Of this number, 20 points are the body's own statements and 18 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.
routing.checkBalanceOrder (cognitive 38) d2layouts/d2talalayout/internal/routing/balance_route_guard.go:167— routing.checkBalanceOrder has cognitive complexity 38 (threshold 15). Drivers by points: if/else 13 (32 pts), loops 3 (4 pts), boolean chains 2 (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.
routing.buildOVGFromGraphWithGuard (cognitive 38) REDACTED:130— routing.buildOVGFromGraphWithGuard has cognitive complexity 38 (threshold 15). Drivers by points: if/else 25 (34 pts), loops 4 (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.
routing.fixedOverlapsForRoute (cognitive 38) d2layouts/d2talalayout/internal/routing/route_search_guard.go:304— routing.fixedOverlapsForRoute has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (33 pts), loops 3 (4 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.
OVG.createPortsConnectionsToBoundaries (cognitive 38) REDACTED:1455— OVG.createPortsConnectionsToBoundaries has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (30 pts), match/switch 2 (5 pts), loops 2 (3 pts) (nesting depth added 23). Most of this is not in the body itself: 8 of the 38 points are its own statements and the rest belongs to one function literal inside it that branches (line 1470). 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.
trees.buildNodeToTreeGuarded (cognitive 38) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:651— trees.buildNodeToTreeGuarded has cognitive complexity 38 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 5 (11 pts), boolean chains 2 (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.
d2fonts.probeFontFileCoverage (cognitive 38) d2renderers/d2fonts/fallback.go:483— d2fonts.probeFontFileCoverage has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15 (30 pts), boolean chains 5, loops 2 (3 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.
retainedVectorValidator.node (cognitive 38) d2renderers/d2raster/vector_validation.go:127— retainedVectorValidator.node has cognitive complexity 38 (threshold 15). Drivers by points: if/else 23 (31 pts), boolean chains 6, 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.
run.fingerprints (cognitive 38) ci/nonlayout-perf/run.py:142— run.fingerprints has cognitive complexity 38 (threshold 15). Drivers by points: if/else 13 (29 pts), loops 3 (6 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.
gridDiagram.layoutEvenly (cognitive 37) d2layouts/d2grid/layout.go:233— gridDiagram.layoutEvenly has cognitive complexity 37 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 10 (18 pts) (nesting depth added 18). Of this number, 34 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.
d2near.Layout (cognitive 37) d2layouts/d2near/layout.go:35— d2near.Layout has cognitive complexity 37 (threshold 15). Drivers by points: loops 8 (21 pts), if/else 5 (16 pts) (nesting depth added 24). 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.
hierarchy.assign (cognitive 37) d2layouts/d2talalayout/internal/hierarchy/discovery.go:111— hierarchy.assign has cognitive complexity 37 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 7 (14 pts), boolean chains 1 (nesting depth added 18). Of this number, 36 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.
Cluster.arrangeNodesWithWork (cognitive 37) d2layouts/d2talalayout/internal/layoutgraph/cluster.go:115— Cluster.arrangeNodesWithWork has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (33 pts), loops 2 (4 pts) (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.
Graph.restoreEdgeAbductions (cognitive 37) d2layouts/d2talalayout/internal/layoutgraph/layout.go:72— Graph.restoreEdgeAbductions has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (34 pts), loops 2, boolean chains 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.
packing.routedEdgeSegments (cognitive 37) d2layouts/d2talalayout/internal/packing/binpack.go:1224— packing.routedEdgeSegments has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 2 (3 pts), boolean chains 2 (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.
placement.nearestFrom (cognitive 37) d2layouts/d2talalayout/internal/placement/compaction.go:487— placement.nearestFrom has cognitive complexity 37 (threshold 15). Drivers by points: if/else 11 (36 pts), loops 1 (nesting depth added 25). 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.
placement.nearestBetween (cognitive 37) d2layouts/d2talalayout/internal/placement/gapreduction.go:155— placement.nearestBetween has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (35 pts), boolean chains 1, loops 1 (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.
routing.shortcutParallelClearance (cognitive 37) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:469— routing.shortcutParallelClearance has cognitive complexity 37 (threshold 15). Drivers by points: if/else 9 (29 pts), loops 3 (6 pts), boolean chains 2 (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.
OVG.addNewBoundaryLayers (cognitive 37) REDACTED:829— OVG.addNewBoundaryLayers has cognitive complexity 37 (threshold 15). Drivers by points: if/else 11 (34 pts), loops 2 (3 pts) (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.
ovgEdgeRouter.generateRoutes (cognitive 37) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:349— ovgEdgeRouter.generateRoutes has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (35 pts), boolean chains 1, loops 1 (nesting depth added 21). Of this number, 35 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.
ASCIIartist.Render (cognitive 37) d2renderers/d2ascii/d2ascii.go:215— ASCIIartist.Render has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (19 pts), loops 6 (9 pts), match/switch 2 (5 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.
preflight.assets (cognitive 37) d2renderers/d2raster/raster.go:837— preflight.assets has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (33 pts), loops 2, match/switch 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.
builder.buildConnection (cognitive 37) d2renderers/d2scenebuild/connection.go:28— builder.buildConnection has cognitive complexity 37 (threshold 15). Drivers by points: if/else 24 (33 pts), boolean chains 4 (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.
colrv1Builder.paint (cognitive 37) d2renderers/internal/fontface/colrv1.go:223— colrv1Builder.paint has cognitive complexity 37 (threshold 15). Drivers by points: if/else 18 (34 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 17). 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.
d2target.validateRenderConnection (cognitive 37) d2target/render_validation.go:166— d2target.validateRenderConnection has cognitive complexity 37 (threshold 15). Drivers by points: if/else 17 (29 pts), boolean chains 6, loops 2 (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.
xgif.NormalizePalettedImage (cognitive 37) lib/xgif/xgif.go:1069— xgif.NormalizePalettedImage has cognitive complexity 37 (threshold 15). Drivers by points: if/else 16 (22 pts), loops 4 (8 pts), boolean chains 7 (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.
Graph.IDA (cognitive 36) d2graph/d2graph.go:92— Graph.IDA has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (25 pts), loops 5 (11 pts) (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.
Object.GetFill (cognitive 36) d2graph/d2graph.go:510— Object.GetFill has cognitive complexity 36 (threshold 15). Drivers by points: if/else 23 (29 pts), boolean chains 7 (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.
d2talalayout.buildLayoutPatch (cognitive 36) d2layouts/d2talalayout/patch.go:158— d2talalayout.buildLayoutPatch has cognitive complexity 36 (threshold 15). Drivers by points: if/else 16 (32 pts), loops 4 (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.
placementcost.flowContinuityCost (cognitive 36) d2layouts/d2talalayout/internal/placementcost/flow_continuity.go:19— placementcost.flowContinuityCost has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (24 pts), boolean chains 6, loops 4 (6 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.
quality.sortSharedSegments (cognitive 36) d2layouts/d2talalayout/internal/quality/labels.go:512— quality.sortSharedSegments has cognitive complexity 36 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 5 (12 pts), boolean chains 2 (nesting depth added 20). Of this number, 35 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.
routing.routeEdgesWithResourceGuards (cognitive 36) d2layouts/d2talalayout/internal/routing/coordinator.go:419— routing.routeEdgesWithResourceGuards has cognitive complexity 36 (threshold 15). Drivers by points: if/else 15 (29 pts), loops 5 (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.
routing.newOVGForHierarchy (cognitive 36) d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:15— routing.newOVGForHierarchy has cognitive complexity 36 (threshold 15). Drivers by points: if/else 19 (26 pts), loops 5 (9 pts), match/switch 1 (nesting depth added 11). Of this number, 32 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.
routing.routeStageGraphBoundingBox (cognitive 36) d2layouts/d2talalayout/internal/routing/route_stage_guard.go:400— routing.routeStageGraphBoundingBox has cognitive complexity 36 (threshold 15). Drivers by points: if/else 14 (28 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 15). Of this number, 31 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.
routing.swapEdgesOnSameSide (cognitive 36) d2layouts/d2talalayout/internal/routing/swap_ports.go:82— routing.swapEdgesOnSameSide has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 21). Of this number, 30 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.
d2oracle.deleteMapField (cognitive 36) d2oracle/edit.go:1417— d2oracle.deleteMapField has cognitive complexity 36 (threshold 15). Drivers by points: if/else 9 (32 pts), boolean chains 3, loops 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.
asciishapes.DrawCylinder (cognitive 36) d2renderers/d2ascii/asciishapes/cylinder.go:3— asciishapes.DrawCylinder has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 9, loops 2 (3 pts), match/switch 1 (3 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.
d2isometricimg.surfaceIconLayout (cognitive 36) d2renderers/d2isometric/d2isometricimg/surface_icons.go:306— d2isometricimg.surfaceIconLayout has cognitive complexity 36 (threshold 15). Drivers by points: if/else 19 (27 pts), boolean chains 9 (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.
d2raster.applyNonZeroClip (cognitive 36) d2renderers/d2raster/effects.go:791— d2raster.applyNonZeroClip has cognitive complexity 36 (threshold 15). Drivers by points: if/else 15 (26 pts), boolean chains 5, loops 3 (5 pts) (nesting depth added 13). Most of this is not in the body itself: 13 of the 36 points are its own statements and the rest belongs to one function literal inside it that branches (line 815). 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.
d2raster.drawRadialGradientMaskPixels (cognitive 36) d2renderers/d2raster/gradient.go:1268— d2raster.drawRadialGradientMaskPixels has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (32 pts), loops 2 (3 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.
preflight.prepareFilters (cognitive 36) d2renderers/d2raster/filter.go:132— preflight.prepareFilters has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (29 pts), boolean chains 4, match/switch 1 (2 pts), loops 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.
d2scenebuild.parsePaperPatternSource (cognitive 36) d2renderers/d2scenebuild/pattern_sources.go:139— d2scenebuild.parsePaperPatternSource has cognitive complexity 36 (threshold 15). Drivers by points: if/else 14 (25 pts), boolean chains 4, loops 3 (4 pts), match/switch 1 (3 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.
builder.preflightLegend (cognitive 36) d2renderers/d2scenebuild/legend.go:47— builder.preflightLegend has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (25 pts), boolean chains 9, loops 2 (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.
rasterimage.inspectGIF (cognitive 36) internal/rasterimage/firstframe.go:232— rasterimage.inspectGIF has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (33 pts), match/switch 1 (2 pts), loops 1 (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.
boardOutputTransaction.removeStaleDirectories (cognitive 35) d2cli/board_output_publish.go:815— boardOutputTransaction.removeStaleDirectories has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (28 pts), boolean chains 4, loops 3 (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.
compiler.spreadCompositeReferencesNode (cognitive 35) REDACTED:670— compiler.spreadCompositeReferencesNode has cognitive complexity 35 (threshold 15). Drivers by points: if/else 7 (24 pts), loops 4 (10 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.
Map.createEdge2 (cognitive 35) REDACTED:1846— Map.createEdge2 has cognitive complexity 35 (threshold 15). Drivers by points: if/else 16 (28 pts), loops 3 (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.
Map.FindBoardRoot (cognitive 35) REDACTED:2405— Map.FindBoardRoot has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 3 (6 pts), boolean chains 3 (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.
grouping.SequenceDefiningEdges (cognitive 35) REDACTED:80— grouping.SequenceDefiningEdges has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 4 (10 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.
routing.stableSortRouteValues (cognitive 35) d2layouts/d2talalayout/internal/routing/route_stage_guard.go:554— routing.stableSortRouteValues has cognitive complexity 35 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 5 (12 pts), boolean chains 1 (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.
OVG.addLevelNodes (cognitive 35) d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:351— OVG.addLevelNodes has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (28 pts), loops 3 (6 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.
trees.treePlacementDescendants (cognitive 35) d2layouts/d2talalayout/internal/trees/geometry.go:571— trees.treePlacementDescendants has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 16). Most of this is not in the body itself: 12 of the 35 points are its own statements and the rest belongs to one function literal inside it that branches (line 578). 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.
asciiroute.drawConnectionLabel (cognitive 35) d2renderers/d2ascii/asciiroute/labels.go:87— asciiroute.drawConnectionLabel has cognitive complexity 35 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 5 (13 pts) (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.
d2raster.normalizeNodeFilters (cognitive 35) d2renderers/d2raster/filter.go:53— d2raster.normalizeNodeFilters has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (27 pts), loops 3 (5 pts), match/switch 1 (2 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.
d2raster.maskRenderBounds (cognitive 35) d2renderers/d2raster/mask_regions.go:21— d2raster.maskRenderBounds has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (23 pts), boolean chains 9, loops 3 (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.
RenderSession.memoizedCacheKeyWithDigest (cognitive 35) REDACTED:202— RenderSession.memoizedCacheKeyWithDigest has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (34 pts), loops 1 (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.
builder.splitAnimatedConnectionPath (cognitive 35) d2renderers/d2scenebuild/connection.go:218— builder.splitAnimatedConnectionPath has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (28 pts), boolean chains 3, loops 2, match/switch 1 (2 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.
d2svgimport.splitSVGNumberList (cognitive 35) d2renderers/d2svgimport/style.go:744— d2svgimport.splitSVGNumberList has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (30 pts), boolean chains 4, loops 1 (nesting depth added 16). Of this number, 31 points are the body's own statements and 4 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.
pathParser.parse (cognitive 35) d2renderers/d2svgimport/path.go:80— pathParser.parse has cognitive complexity 35 (threshold 15). Drivers by points: if/else 13 (32 pts), boolean chains 2, loops 1 (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.
Diagram.appendCorpus (cognitive 35) d2target/d2target.go:702— Diagram.appendCorpus has cognitive complexity 35 (threshold 15). Drivers by points: loops 8 (19 pts), if/else 9 (16 pts) (nesting depth added 18). 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.
rasterimage.inspectWebP (cognitive 35) internal/rasterimage/firstframe.go:752— rasterimage.inspectWebP has cognitive complexity 35 (threshold 15). Drivers by points: if/else 13 (26 pts), boolean chains 6, match/switch 1 (2 pts), loops 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.
testutil.orderPDFImagesByPage (cognitive 35) internal/testutil/pdf.go:149— testutil.orderPDFImagesByPage has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (27 pts), loops 5 (7 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.
png.exifChunkLocation (cognitive 35) lib/png/png.go:135— png.exifChunkLocation has cognitive complexity 35 (threshold 15). Drivers by points: if/else 16 (33 pts), boolean chains 1, loops 1 (nesting depth added 17). 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.
d2cli.loadFonts (cognitive 34) d2cli/main.go:1103— d2cli.loadFonts has cognitive complexity 34 (threshold 15). Drivers by points: if/else 21 (31 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.
compiler.applyLazyGlobs (cognitive 34) REDACTED:1254— compiler.applyLazyGlobs has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (24 pts), loops 5 (10 pts) (nesting depth added 18). Of this number, 33 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.
gridDiagram.getBestLayout (cognitive 34) d2layouts/d2grid/layout.go:563— gridDiagram.getBestLayout has cognitive complexity 34 (threshold 15). Drivers by points: if/else 21 (27 pts), boolean chains 4, loops 3 (nesting depth added 6). Of this number, 18 points are the body's own statements and 16 belong to 3 function literals 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.
grouping.identifySequences (cognitive 34) REDACTED:18— grouping.identifySequences has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (26 pts), loops 4 (5 pts), boolean chains 3 (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.
hierarchy.alignHierarchy (cognitive 34) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:42— hierarchy.alignHierarchy has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 6 (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.
OVG.addPortAlignedNodes (cognitive 34) d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:302— OVG.addPortAlignedNodes has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 5 (11 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.
Raster.drawOpacityGroup (cognitive 34) d2renderers/d2isometric/d2isometricimg/opacity_groups.go:146— Raster.drawOpacityGroup has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 5 (12 pts), boolean chains 3 (nesting depth added 17). 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.
d2raster.renderBands (cognitive 34) d2renderers/d2raster/bands.go:38— d2raster.renderBands has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (28 pts), boolean chains 4, loops 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.
d2raster.strokeRegionBounds (cognitive 34) d2renderers/d2raster/stroke_regions.go:54— d2raster.strokeRegionBounds has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (25 pts), boolean chains 6, 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.
builder.buildMarkdownPrimitive (cognitive 34) d2renderers/d2scenebuild/markdown.go:239— builder.buildMarkdownPrimitive has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (28 pts), boolean chains 5, match/switch 1 (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Diagram.GetBoard (cognitive 34) d2target/d2target.go:109— Diagram.GetBoard has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (23 pts), loops 6 (9 pts), boolean chains 1, match/switch 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.
testutil.InspectD2PDF (cognitive 34) internal/testutil/pdf.go:66— testutil.InspectD2PDF has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (25 pts), loops 5 (8 pts), boolean chains 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.
imageasset.parseContentEncodings (cognitive 34) lib/imageasset/resolve.go:802— imageasset.parseContentEncodings has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (27 pts), loops 3 (6 pts), boolean chains 1 (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.
Resolver.loadData (cognitive 34) lib/imageasset/resolve.go:507— Resolver.loadData has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (28 pts), boolean chains 3, loops 2 (3 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.
compiler.__import (cognitive 33) d2ir/import.go:86— compiler.__import has cognitive complexity 33 (threshold 15). Drivers by points: if/else 16 (30 pts), boolean chains 3 (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.
Transaction.hasBadPostStateOverlap (cognitive 33) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1103— Transaction.hasBadPostStateOverlap has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (24 pts), boolean chains 6, loops 2 (3 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.
sizelessOptimizer.optimizeGuarded (cognitive 33) REDACTED:161— sizelessOptimizer.optimizeGuarded has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (30 pts), loops 2, boolean chains 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.
sizelessOptimizer.findClosestUnoccupiedDistanceGuarded (cognitive 33) REDACTED:280— sizelessOptimizer.findClosestUnoccupiedDistanceGuarded has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (24 pts), boolean chains 6, loops 2 (3 pts) (nesting depth added 14). Of this number, 31 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.
sizelessOptimizer.placementPointsGuarded (cognitive 33) REDACTED:350— sizelessOptimizer.placementPointsGuarded has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 8, loops 2 (3 pts) (nesting depth added 12). Of this number, 31 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.
placementcost.isMirrored (cognitive 33) d2layouts/d2talalayout/internal/placementcost/symmetry.go:625— placementcost.isMirrored has cognitive complexity 33 (threshold 15). Drivers by points: if/else 15 (29 pts), boolean chains 4 (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.
proximity.CommonUncleSiblings (cognitive 33) d2layouts/d2talalayout/internal/proximity/common_uncle.go:11— proximity.CommonUncleSiblings has cognitive complexity 33 (threshold 15). Drivers by points: if/else 5 (21 pts), loops 5 (11 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.
routing.crosshatchWithWorkLimit (cognitive 33) d2layouts/d2talalayout/internal/routing/coordinator.go:1826— routing.crosshatchWithWorkLimit has cognitive complexity 33 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 5 (9 pts) (nesting depth added 18). None of this is in the body itself: all 33 points belong to one function literal inside it that branches (line 1827). 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.
routing.sortEdges (cognitive 33) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:190— routing.sortEdges has cognitive complexity 33 (threshold 15). Drivers by points: match/switch 8 (17 pts), if/else 9 (14 pts), boolean chains 2 (nesting depth added 14). Most of this is not in the body itself: 1 of the 33 points is its own statement and the rest belongs to 4 function literals inside it that branch (lines 219, 277, 193, …). 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.
trees.placeTrees (cognitive 33) d2layouts/d2talalayout/internal/trees/layout.go:906— trees.placeTrees has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (25 pts), loops 6 (8 pts) (nesting depth added 15). Of this number, 32 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.
d2isometricimg.svgOrderComponents (cognitive 33) d2renderers/d2isometric/d2isometricimg/svg_order.go:394— d2isometricimg.svgOrderComponents has cognitive complexity 33 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 8 (13 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.
richLabelPainter.texture (cognitive 33) d2renderers/d2isometric/d2isometricimg/rich_labels.go:78— richLabelPainter.texture has cognitive complexity 33 (threshold 15). Drivers by points: if/else 19 (25 pts), loops 2 (5 pts), boolean chains 3 (nesting depth added 9). 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.
builder.buildConnectionMask (cognitive 33) d2renderers/d2scenebuild/labels.go:17— builder.buildConnectionMask has cognitive complexity 33 (threshold 15). Drivers by points: if/else 13 (27 pts), boolean chains 4, loops 2 (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.
testutil.parsePDFLiteralString (cognitive 33) internal/testutil/pdf.go:545— testutil.parsePDFLiteralString has cognitive complexity 33 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 2 (6 pts), match/switch 2 (5 pts), boolean chains 4 (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.
d2cli.renderPPTXWithRenderer (cognitive 32) d2cli/paged.go:509— d2cli.renderPPTXWithRenderer has cognitive complexity 32 (threshold 15). Drivers by points: if/else 15 (27 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 13). Most of this is not in the body itself: 6 of the 32 points are its own statements and the rest belongs to one function literal inside it that branches (line 523). 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.
d2format.escapeUnquotedValue (cognitive 32) d2format/escape.go:45— d2format.escapeUnquotedValue has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (24 pts), match/switch 2 (6 pts), boolean chains 1, 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.
d2graph.GetTextDimensionsWithMono (cognitive 32) d2graph/d2graph.go:1454— d2graph.GetTextDimensionsWithMono has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (27 pts), loops 1 (3 pts), boolean chains 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.
d2near.boundingBox (cognitive 32) d2layouts/d2near/layout.go:151— d2near.boundingBox has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 3 (5 pts), boolean chains 4, match/switch 1 (3 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.
Node.overlapsAlongDimension (cognitive 32) d2layouts/d2talalayout/internal/layoutgraph/node.go:1309— Node.overlapsAlongDimension has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (32 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.
proximity.ApplyVirally (cognitive 32) d2layouts/d2talalayout/internal/proximity/herding.go:188— proximity.ApplyVirally has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 4 (10 pts), boolean chains 2 (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.
routing.routeSegmentBounds (cognitive 32) d2layouts/d2talalayout/internal/routing/balance_route_guard.go:91— routing.routeSegmentBounds has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (30 pts), boolean chains 1, loops 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.
Route.isEntireColinear (cognitive 32) d2layouts/d2talalayout/internal/routing/route.go:34— Route.isEntireColinear has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (24 pts), boolean chains 4, loops 2 (4 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.
asciishapes.DrawStoredData (cognitive 32) d2renderers/d2ascii/asciishapes/stored_data.go:7— asciishapes.DrawStoredData has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 6, loops 2 (3 pts), match/switch 1 (3 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.
d2isometricimg.hierarchyTerraces (cognitive 32) d2renderers/d2isometric/d2isometricimg/hierarchy_boards.go:164— d2isometricimg.hierarchyTerraces has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 6, loops 4 (6 pts) (nesting depth added 12). Of this number, 18 points are the body's own statements and 14 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.
routeCaptionPlacer.score (cognitive 32) d2renderers/d2isometric/d2isometricimg/route_labels.go:265— routeCaptionPlacer.score has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 5 (9 pts), boolean chains 2 (nesting depth added 14). Of this number, 22 points are the body's own statements and 10 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.
nativeSurfaceSVGWriter.node (cognitive 32) d2renderers/d2isometric/d2isometricimg/vector_surface_svg.go:154— nativeSurfaceSVGWriter.node has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (21 pts), match/switch 2 (6 pts), loops 2 (3 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.
builder.buildCodeTextRuns (cognitive 32) d2renderers/d2scenebuild/code_shape.go:115— builder.buildCodeTextRuns has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (28 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 17). 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.
builder.buildMarkdownLabel (cognitive 32) d2renderers/d2scenebuild/markdown.go:101— builder.buildMarkdownLabel has cognitive complexity 32 (threshold 15). Drivers by points: if/else 18 (28 pts), boolean chains 3, 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.
transformParser.parse (cognitive 32) d2renderers/d2svgimport/transform.go:49— transformParser.parse has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (27 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.
rasterimage.extractWebPFrame (cognitive 32) internal/rasterimage/firstframe.go:840— rasterimage.extractWebPFrame has cognitive complexity 32 (threshold 15). Drivers by points: if/else 15 (25 pts), boolean chains 4, match/switch 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.
d2ast.RawString (cognitive 31) d2ast/d2ast.go:1563— d2ast.RawString has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 3, match/switch 1 (3 pts), loops 1 (2 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.
compiler.compileClass (cognitive 31) d2compiler/compile.go:1385— compiler.compileClass has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 3 (4 pts), match/switch 1 (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.
compiler.validatePositionsCompatibility (cognitive 31) d2compiler/compile.go:1664— compiler.validatePositionsCompatibility has cognitive complexity 31 (threshold 15). Drivers by points: if/else 7 (27 pts), loops 2 (3 pts), boolean chains 1 (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.
Object.ShiftDescendants (cognitive 31) d2graph/layout.go:103— Object.ShiftDescendants has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (20 pts), loops 4 (8 pts), boolean chains 3 (nesting depth added 12). Most of this is not in the body itself: 7 of the 31 points are its own statements and the rest belongs to one function literal inside it that branches (line 119). 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.
hierarchy.leafNodesContext (cognitive 31) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:289— hierarchy.leafNodesContext has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 4 (7 pts) (nesting depth added 18). Of this number, 23 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.
hierarchy.orderCompoundInterfaces (cognitive 31) REDACTED:240— hierarchy.orderCompoundInterfaces has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (21 pts), loops 5 (8 pts), boolean chains 2 (nesting depth added 15). Of this number, 26 points are the body's own statements and 5 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.
GraphState.captureRuntimeStateContext (cognitive 31) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:707— GraphState.captureRuntimeStateContext has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 9 (10 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.
routing.edgeSegmentsGuarded (cognitive 31) d2layouts/d2talalayout/internal/routing/balance_route_guard.go:54— routing.edgeSegmentsGuarded has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (27 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.
routing.collectRouteFlavorResponses (cognitive 31) d2layouts/d2talalayout/internal/routing/coordinator.go:114— routing.collectRouteFlavorResponses has cognitive complexity 31 (threshold 15). Drivers by points: if/else 6 (20 pts), loops 3 (9 pts), match/switch 1 (2 pts) (nesting depth added 21). Of this number, 30 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.
routing.shortcutWallClearance (cognitive 31) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:419— routing.shortcutWallClearance has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 3 (6 pts), boolean chains 1 (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.
OVG.perimeterPoints (cognitive 31) REDACTED:499— OVG.perimeterPoints has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 5 (9 pts) (nesting depth added 17). 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.
OVG.connectNodes (cognitive 31) REDACTED:1115— OVG.connectNodes has cognitive complexity 31 (threshold 15). Drivers by points: if/else 17 (27 pts), loops 4 (nesting depth added 10). Of this number, 27 points are the body's own statements and 4 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.
parser.parseKey (cognitive 31) d2parser/parse.go:1035— parser.parseKey has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (25 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 14). Of this number, 20 points are the body's own statements and 11 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.
d2isometricimg.preflightPageMetadata (cognitive 31) d2renderers/d2isometric/d2isometricimg/page.go:66— d2isometricimg.preflightPageMetadata has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (22 pts), boolean chains 6, loops 3 (nesting depth added 8). Most of this is not in the body itself: 14 of the 31 points are its own statements and the rest belongs to one function literal inside it that branches (line 71). 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.
d2raster.compositeBlendLayer (cognitive 31) d2renderers/d2raster/effects.go:1461— d2raster.compositeBlendLayer has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 3 (6 pts), boolean chains 1 (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.
d2raster.drawDirectPatternCoverage (cognitive 31) d2renderers/d2raster/gradient.go:723— d2raster.drawDirectPatternCoverage has cognitive complexity 31 (threshold 15). Drivers by points: if/else 13 (27 pts), boolean chains 3, loops 1 (nesting depth added 14). Most of this is not in the body itself: 2 of the 31 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 738, 728). 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.
d2raster.drawPrimitive (cognitive 31) d2renderers/d2raster/raster.go:1559— d2raster.drawPrimitive has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (25 pts), loops 2 (6 pts) (nesting depth added 15). Of this number, 25 points are the body's own statements and 6 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.
d2svg.RenderLegend (cognitive 31) d2renderers/d2svg/d2svg.go:259— d2svg.RenderLegend has cognitive complexity 31 (threshold 15). Drivers by points: if/else 15 (22 pts), loops 5, 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.
svgImporter.validateGradientTree (cognitive 31) d2renderers/d2svgimport/gradient.go:26— svgImporter.validateGradientTree has cognitive complexity 31 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 3 (6 pts), boolean chains 2, match/switch 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.
Resolver.classifySource (cognitive 31) lib/imageasset/resolve.go:183— Resolver.classifySource has cognitive complexity 31 (threshold 15). Drivers by points: if/else 18 (28 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.
d2cli.publishBoardOutputWorkspace (cognitive 30) d2cli/board_output_publish.go:38— d2cli.publishBoardOutputWorkspace has cognitive complexity 30 (threshold 15). Drivers by points: if/else 21 (30 pts) (nesting depth added 9). Of this number, 29 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.
d2exporter.toPrettyLink (cognitive 30) d2exporter/export.go:294— d2exporter.toPrettyLink has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 3 (6 pts), match/switch 1 (4 pts), boolean chains 1, jumps 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.
printer.mapKey (cognitive 30) d2format/format.go:367— printer.mapKey has cognitive complexity 30 (threshold 15). Drivers by points: if/else 16 (25 pts), boolean chains 3, loops 1 (2 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.
d2ir.walkComposite (cognitive 30) REDACTED:753— d2ir.walkComposite has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 4 (10 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 17). 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.
sequenceDiagram.placeGroup (cognitive 30) d2layouts/d2sequence/sequence_diagram.go:246— sequenceDiagram.placeGroup has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 7 (13 pts) (nesting depth added 17). 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.
grouping.isValidRememberedSequence (cognitive 30) REDACTED:128— grouping.isValidRememberedSequence has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (23 pts), boolean chains 5, loops 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.
rankProblem.longestPathLevels (cognitive 30) d2layouts/d2talalayout/internal/hierarchy/rank_graph.go:208— rankProblem.longestPathLevels has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (25 pts), loops 4 (5 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.
placement.optimizerDoesOverlap (cognitive 30) d2layouts/d2talalayout/internal/placement/optimization_guard.go:439— placement.optimizerDoesOverlap has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 5, loops 2 (3 pts) (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.
optimizerSpatialIndex.rebuild (cognitive 30) d2layouts/d2talalayout/internal/placement/optimizer_spatial_index.go:103— optimizerSpatialIndex.rebuild has cognitive complexity 30 (threshold 15). Drivers by points: if/else 16 (23 pts), boolean chains 4, match/switch 1 (2 pts), loops 1 (nesting depth added 8). Of this number, 27 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.
trees.candidateTreeRoots (cognitive 30) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:220— trees.candidateTreeRoots has cognitive complexity 30 (threshold 15). Drivers by points: if/else 15 (24 pts), boolean chains 4, loops 2 (nesting depth added 9). Of this number, 27 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.
d2oracle.filterReserved (cognitive 30) d2oracle/edit.go:2264— d2oracle.filterReserved has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (26 pts), boolean chains 2, loops 1 (2 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.
d2isometricimg.svgPolygonPath (cognitive 30) d2renderers/d2isometric/d2isometricimg/svg.go:119— d2isometricimg.svgPolygonPath has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (7 pts), boolean chains 4 (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.
meshBuilder.arrowOwnerCaps (cognitive 30) d2renderers/d2isometric/d2isometricimg/arrow_visibility.go:94— meshBuilder.arrowOwnerCaps has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (20 pts), loops 4 (7 pts), boolean chains 3 (nesting depth added 10). Of this number, 21 points are the body's own statements and 9 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.
meshBuilder.solidContentSupport (cognitive 30) d2renderers/d2isometric/d2isometricimg/native_solids.go:203— meshBuilder.solidContentSupport has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 6 (12 pts), boolean chains 6 (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.
d2raster.drawAxisLinearGradientMaskPixels (cognitive 30) d2renderers/d2raster/gradient.go:1123— d2raster.drawAxisLinearGradientMaskPixels has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (26 pts), loops 2 (3 pts), match/switch 1 (nesting depth added 17). 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.
svgImporter.resolveEmbeddedRaster (cognitive 30) d2renderers/d2svgimport/image.go:72— svgImporter.resolveEmbeddedRaster has cognitive complexity 30 (threshold 15). Drivers by points: if/else 23 (29 pts), boolean chains 1 (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.
rasterimage.jpegEXIFOrientation (cognitive 30) internal/rasterimage/jpeg_orientation.go:23— rasterimage.jpegEXIFOrientation has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (19 pts), boolean chains 6, loops 2 (3 pts), match/switch 1 (2 pts) (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.
Segment.GetBounds (cognitive 30) lib/geo/segment.go:81— Segment.GetBounds has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (28 pts), boolean chains 1, loops 1 (nesting depth added 17). 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.
markdownPainter.markdownMinContentWidth (cognitive 30) lib/textmeasure/markdown_svg.go:1592— markdownPainter.markdownMinContentWidth has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 3 (5 pts), boolean chains 4 (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.
main.main (cognitive 29) ci/tala-performance/main.go:197— main.main has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (21 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 8). Of this number, 28 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.
d2cli._renderWithPNGEncoder (cognitive 29) d2cli/main.go:965— d2cli._renderWithPNGEncoder has cognitive complexity 29 (threshold 15). Drivers by points: if/else 17 (25 pts), boolean chains 2, match/switch 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.
d2cli.renderPDFWithRenderer (cognitive 29) d2cli/paged.go:428— d2cli.renderPDFWithRenderer has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (24 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 11). Most of this is not in the body itself: 7 of the 29 points are its own statements and the rest belongs to one function literal inside it that branches (line 440). 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.
sequenceDiagram.placeActors (cognitive 29) d2layouts/d2sequence/sequence_diagram.go:363— sequenceDiagram.placeActors has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (27 pts), boolean chains 1, loops 1 (nesting depth added 17). 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.
engine.preserveCompoundInteriors (cognitive 29) d2layouts/d2talalayout/internal/engine/compound_routes.go:38— engine.preserveCompoundInteriors has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 3 (5 pts), boolean chains 3 (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.
hierarchy.placeBlock (cognitive 29) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:627— hierarchy.placeBlock has cognitive complexity 29 (threshold 15). Drivers by points: if/else 13 (28 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.
graphCloneState.copyTrees (cognitive 29) REDACTED:546— graphCloneState.copyTrees has cognitive complexity 29 (threshold 15). Drivers by points: if/else 16 (24 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 9). Most of this is not in the body itself: 10 of the 29 points are its own statements and the rest belongs to one function literal inside it that branches (line 552). 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.
packing.routedContainerRoutesStayInsideShrink (cognitive 29) d2layouts/d2talalayout/internal/packing/routed_container.go:216— packing.routedContainerRoutesStayInsideShrink has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (23 pts), loops 3 (5 pts), boolean chains 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.
placement.chargeOptimizerTranspose (cognitive 29) d2layouts/d2talalayout/internal/placement/optimization_guard.go:549— placement.chargeOptimizerTranspose has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (21 pts), boolean chains 4, loops 4 (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.
placement.withHubSpokesSuppressed (cognitive 29) REDACTED:57— placement.withHubSpokesSuppressed has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 3 (4 pts), boolean chains 3 (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.
sizelessOptimizer.bestSwapCandidateGuarded (cognitive 29) REDACTED:479— sizelessOptimizer.bestSwapCandidateGuarded has cognitive complexity 29 (threshold 15). Drivers by points: if/else 15 (27 pts), boolean chains 1, loops 1 (nesting depth added 12). Of this number, 17 points are the body's own statements and 12 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.
OVG.isMisdirectedPortPair (cognitive 29) REDACTED:1355— OVG.isMisdirectedPortPair has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (22 pts), boolean chains 4, loops 2 (3 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.
d2oracle.RenameIDDeltas (cognitive 29) d2oracle/edit.go:3163— d2oracle.RenameIDDeltas has cognitive complexity 29 (threshold 15). Drivers by points: if/else 17 (26 pts), loops 2, boolean chains 1 (nesting depth added 9). Of this number, 20 points are the body's own statements and 9 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.
parser.parseBlockString (cognitive 29) d2parser/parse.go:1490— parser.parseBlockString has cognitive complexity 29 (threshold 15). Drivers by points: if/else 13 (24 pts), loops 4, 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.
nativeScene.frameRaster (cognitive 29) d2renderers/d2isometric/d2isometricimg/source_panels.go:281— nativeScene.frameRaster has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 5 (12 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.
preflight.animationValueAt (cognitive 29) d2renderers/d2raster/animation_value.go:15— preflight.animationValueAt has cognitive complexity 29 (threshold 15). Drivers by points: if/else 19 (26 pts), boolean chains 2, 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.
RenderSession.getOrLoad (cognitive 29) REDACTED:342— RenderSession.getOrLoad has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (28 pts), loops 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.
utf8FontFile.GenerateCutFont (cognitive 29) lib/font/subsetFont.go:338— utf8FontFile.GenerateCutFont has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (20 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 13). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
geo.cubicRoots (cognitive 29) lib/geo/bezier.go:177— geo.cubicRoots has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 3 (7 pts), boolean chains 3 (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.
compiler.getClassMap (cognitive 28) d2compiler/compile.go:570— compiler.getClassMap has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (22 pts), boolean chains 3, loops 1 (3 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.
compiler.validateConfigs (cognitive 28) REDACTED:359— compiler.validateConfigs has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 2, match/switch 1 (2 pts), loops 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.
Map.DeleteField (cognitive 28) REDACTED:1488— Map.DeleteField has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 3 (9 pts), boolean chains 2 (nesting depth added 17). 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.
d2layouts.ExtractSubgraph (cognitive 28) d2layouts/d2layouts.go:637— d2layouts.ExtractSubgraph has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (19 pts), loops 5 (7 pts), boolean chains 2 (nesting depth added 8). Of this number, 27 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.
hierarchy.sifting (cognitive 28) d2layouts/d2talalayout/internal/hierarchy/sifting.go:94— hierarchy.sifting has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 3 (4 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.
rankSimplex.certify (cognitive 28) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:497— rankSimplex.certify has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (26 pts), loops 2 (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.
graphCloneState.copySequences (cognitive 28) REDACTED:406— graphCloneState.copySequences has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 3 (5 pts), boolean chains 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.
Graph.containerRDFSOrderContext (cognitive 28) d2layouts/d2talalayout/internal/layoutgraph/graph.go:877— Graph.containerRDFSOrderContext has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 17). 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.
packing.binPackReverseDFSWalk (cognitive 28) d2layouts/d2talalayout/internal/packing/guard.go:336— packing.binPackReverseDFSWalk has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (25 pts), match/switch 1 (2 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.
placement.appendOptimizerTreeNears (cognitive 28) d2layouts/d2talalayout/internal/placement/optimization_guard.go:125— placement.appendOptimizerTreeNears has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (25 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.
optimizerSpatialIndex.doesOverlap (cognitive 28) d2layouts/d2talalayout/internal/placement/optimizer_spatial_index.go:281— optimizerSpatialIndex.doesOverlap has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 5, loops 2 (3 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.
quality.inspectWithLimit (cognitive 28) d2layouts/d2talalayout/internal/quality/inspection.go:27— quality.inspectWithLimit has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (21 pts), loops 3 (4 pts), boolean chains 3 (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.
trees.normalizedAspectRatio (cognitive 28) d2layouts/d2talalayout/internal/trees/layout.go:701— trees.normalizedAspectRatio has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 4 (6 pts), boolean chains 2 (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.
d2lsp.GetRefRanges (cognitive 28) d2lsp/d2lsp.go:14— d2lsp.GetRefRanges has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 5 (11 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.
d2isometricimg.sceneOutputDensity (cognitive 28) d2renderers/d2isometric/d2isometricimg/framing.go:208— d2isometricimg.sceneOutputDensity has cognitive complexity 28 (threshold 15). Drivers by points: loops 9 (19 pts), if/else 5 (8 pts), boolean chains 1 (nesting depth added 13). 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.
d2isometricimg.nativeShapeProfiles (cognitive 28) d2renderers/d2isometric/d2isometricimg/native_shapes.go:593— d2isometricimg.nativeShapeProfiles has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 4 (7 pts), boolean chains 3 (nesting depth added 13). Of this number, 21 points are the body's own statements and 7 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.
d2isometricimg.richSourceSize (cognitive 28) d2renderers/d2isometric/d2isometricimg/rich_labels.go:165— d2isometricimg.richSourceSize has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 6 (9 pts), boolean chains 1 (nesting depth added 12). Of this number, 26 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.
d2isometricimg.nativeFallbackTextTexture (cognitive 28) d2renderers/d2isometric/d2isometricimg/surface_fonts.go:206— d2isometricimg.nativeFallbackTextTexture has cognitive complexity 28 (threshold 15). Drivers by points: if/else 17 (21 pts), loops 4 (6 pts), boolean chains 1 (nesting depth added 6). Of this number, 16 points are the body's own statements and 12 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.
d2raster.paintDropShadowIntegerGeneral (cognitive 28) d2renderers/d2raster/filter.go:1079— d2raster.paintDropShadowIntegerGeneral has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 2 (3 pts), boolean chains 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.
d2raster.drawLinearGradientMaskPixels (cognitive 28) d2renderers/d2raster/gradient.go:1184— d2raster.drawLinearGradientMaskPixels has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (25 pts), loops 2 (3 pts) (nesting depth added 17). 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.
preflight.path (cognitive 28) d2renderers/d2raster/raster.go:1277— preflight.path has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 2 (5 pts), boolean chains 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.
d2svg.wrapIsometricSVG (cognitive 28) d2renderers/d2svg/isometric.go:104— d2svg.wrapIsometricSVG has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 8, match/switch 1 (2 pts), loops 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.
d2svg.validateRenderPaints (cognitive 28) d2renderers/d2svg/paint_validation.go:16— d2svg.validateRenderPaints has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 4 (6 pts) (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.
svgImporter.validateIgnoredUnnamespacedAttribute (cognitive 28) d2renderers/d2svgimport/boilerplate.go:243— svgImporter.validateIgnoredUnnamespacedAttribute has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 3, loops 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.
svgImporter.compileLinearGradient (cognitive 28) d2renderers/d2svgimport/gradient.go:90— svgImporter.compileLinearGradient has cognitive complexity 28 (threshold 15). Drivers by points: if/else 19 (26 pts), boolean chains 1, loops 1 (nesting depth added 7). Of this number, 27 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.
compiler.collectVariables (cognitive 27) REDACTED:798— compiler.collectVariables has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 2 (4 pts), boolean chains 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.
Map._tripleGlob (cognitive 27) d2ir/pattern.go:166— Map._tripleGlob has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (23 pts), boolean chains 3, loops 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.
d2talalayout.validateCompletedGraph (cognitive 27) d2layouts/d2talalayout/result_validate.go:421— d2talalayout.validateCompletedGraph has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (25 pts), loops 2 (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.
packing.estimateEdgeSegments (cognitive 27) d2layouts/d2talalayout/internal/packing/binpack.go:1283— packing.estimateEdgeSegments has cognitive complexity 27 (threshold 15). Drivers by points: if/else 14 (22 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). Of this number, 25 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.
packing.routedContainerSegmentBoxInterval (cognitive 27) d2layouts/d2talalayout/internal/packing/routed_container.go:382— packing.routedContainerSegmentBoxInterval has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (25 pts), boolean chains 1, loops 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.
placement.scaleBasedOnEdges (cognitive 27) d2layouts/d2talalayout/internal/placement/stages.go:26— placement.scaleBasedOnEdges has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (23 pts), loops 3, 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.
placementcost.ContainerAlignmentCost (cognitive 27) d2layouts/d2talalayout/internal/placementcost/graph.go:358— placementcost.ContainerAlignmentCost has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 2 (3 pts), boolean chains 2 (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.
proximity.connectedHerds (cognitive 27) d2layouts/d2talalayout/internal/proximity/herding.go:148— proximity.connectedHerds has cognitive complexity 27 (threshold 15). Drivers by points: if/else 4 (14 pts), loops 6 (13 pts) (nesting depth added 17). 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.
routing.sourceAndTargetClusterNodes (cognitive 27) d2layouts/d2talalayout/internal/routing/coordinator.go:1354— routing.sourceAndTargetClusterNodes has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (18 pts), loops 4 (9 pts) (nesting depth added 17). 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.
routing.newOVGEdgeRouterWithWorkLimit (cognitive 27) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:102— routing.newOVGEdgeRouterWithWorkLimit has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (21 pts), loops 4 (5 pts), boolean chains 1 (nesting depth added 9). Of this number, 26 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.
OVG.addTunnels (cognitive 27) REDACTED:1008— OVG.addTunnels has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (20 pts), loops 3 (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.
ovgEdgeRouter.fillPathGuarded (cognitive 27) d2layouts/d2talalayout/internal/routing/slingshot.go:413— ovgEdgeRouter.fillPathGuarded has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 8, loops 2 (3 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.
ovgBuildGuard.containerRDFSOrder (cognitive 27) d2layouts/d2talalayout/internal/routing/ovg_resource.go:539— ovgBuildGuard.containerRDFSOrder has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 2 (4 pts), boolean chains 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.
meshBuilder.structuredNode (cognitive 27) d2renderers/d2isometric/d2isometricimg/native_structured.go:142— meshBuilder.structuredNode has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 4 (6 pts), boolean chains 3 (nesting depth added 9). Of this number, 25 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.
d2raster.countEvenOddPathSamples (cognitive 27) d2renderers/d2raster/effects.go:980— d2raster.countEvenOddPathSamples has cognitive complexity 27 (threshold 15). Drivers by points: if/else 4 (16 pts), loops 3 (6 pts), match/switch 1 (5 pts) (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.
d2raster.render (cognitive 27) d2renderers/d2raster/raster.go:341— d2raster.render has cognitive complexity 27 (threshold 15). Drivers by points: if/else 20 (22 pts), boolean chains 4, loops 1 (nesting depth added 2). Of this number, 26 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.
builder.buildLegend (cognitive 27) d2renderers/d2scenebuild/legend.go:351— builder.buildLegend has cognitive complexity 27 (threshold 15). Drivers by points: if/else 17 (24 pts), loops 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.
d2sketch.CompileScenePaths (cognitive 27) d2renderers/d2sketch/scene.go:34— d2sketch.CompileScenePaths has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (20 pts), match/switch 2 (4 pts), loops 2, boolean chains 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.
d2svg.themeRuleSelector (cognitive 27) d2renderers/d2svg/theme.go:120— d2svg.themeRuleSelector has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 8, loops 4 (6 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.
d2svgimport.parseSVGNumber (cognitive 27) d2renderers/d2svgimport/style.go:648— d2svgimport.parseSVGNumber has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 10, loops 3 (5 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.
clusterFaceResolver.resolveCluster (cognitive 27) d2renderers/internal/fontface/shaping.go:500— clusterFaceResolver.resolveCluster has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 4 (6 pts), boolean chains 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.
GoFPDF.AddPDFPage (cognitive 27) lib/pdf/pdf.go:71— GoFPDF.AddPDFPage has cognitive complexity 27 (threshold 15). Drivers by points: if/else 15 (22 pts), loops 3 (5 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.
textmeasure.fitMarkdownTableColumns (cognitive 27) lib/textmeasure/markdown_svg.go:1668— textmeasure.fitMarkdownTableColumns has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 8 (12 pts), boolean chains 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.
run.compare (cognitive 27) ci/nonlayout-perf/run.py:190— run.compare has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 4 (10 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.
d2cli.renderWithPNGEncoderToPaths (cognitive 26) d2cli/main.go:894— d2cli.renderWithPNGEncoderToPaths has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 8, loops 3 (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.
boardOutputTransaction.prepareBackups (cognitive 26) d2cli/board_output_publish.go:510— boardOutputTransaction.prepareBackups has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (24 pts), boolean chains 1, loops 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.
isometricPagedRenderer.admitPage (cognitive 26) d2cli/isometric_paged.go:135— isometricPagedRenderer.admitPage has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 3 (5 pts), boolean chains 4 (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.
compiler.validateBoardLinks (cognitive 26) d2compiler/compile.go:1726— compiler.validateBoardLinks has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 4, 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.
Map._doubleGlob (cognitive 26) d2ir/pattern.go:134— Map._doubleGlob has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (23 pts), boolean chains 2, loops 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.
engine.compoundEnclosedRoute (cognitive 26) d2layouts/d2talalayout/internal/engine/compound_routes.go:108— engine.compoundEnclosedRoute has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 5, loops 2 (nesting depth added 8). Of this number, 23 points are the body's own statements and 3 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.
graphCloneState.copyClusters (cognitive 26) REDACTED:347— graphCloneState.copyClusters has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 3 (5 pts), boolean chains 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.
OVG.addBoundaryNodesAboveLevelNodes (cognitive 26) d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:233— OVG.addBoundaryNodesAboveLevelNodes has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 4 (5 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.
d2isometricimg.nativeSolidContactRoutes (cognitive 26) d2renderers/d2isometric/d2isometricimg/solid_contacts.go:79— d2isometricimg.nativeSolidContactRoutes has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (21 pts), boolean chains 3, loops 2 (nesting depth added 9). Of this number, 23 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.
meshBuilder.prepareGradientMaterials (cognitive 26) d2renderers/d2isometric/d2isometricimg/gradient_paints.go:58— meshBuilder.prepareGradientMaterials has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 5 (7 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.
budget.check (cognitive 26) d2renderers/d2isometric/scene.go:343— budget.check has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 2 (4 pts), boolean chains 2, match/switch 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.
d2scene.EndpointArcToCenter (cognitive 26) d2renderers/d2scene/path.go:356— d2scene.EndpointArcToCenter has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (17 pts), boolean chains 9 (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.
builder.preflightAppendix (cognitive 26) d2renderers/d2scenebuild/appendix.go:87— builder.preflightAppendix has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 2 (3 pts), boolean chains 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.
builder.sceneTextReferences (cognitive 26) d2renderers/d2scenebuild/font_fallback.go:802— builder.sceneTextReferences has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (20 pts), loops 3, match/switch 1 (2 pts), boolean chains 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.
d2svgimport.validateImportedBounds (cognitive 26) d2renderers/d2svgimport/import.go:199— d2svgimport.validateImportedBounds has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 2 (3 pts), boolean chains 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.
Resolver.Resolve (cognitive 26) lib/imageasset/resolve.go:72— Resolver.Resolve has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (21 pts), match/switch 1 (3 pts), boolean chains 1, loops 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.
textmeasure.markdownListMarker (cognitive 26) lib/textmeasure/markdown_svg.go:1780— textmeasure.markdownListMarker has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2 (5 pts), boolean chains 4, match/switch 1 (3 pts) (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.
compare.main (cognitive 26) ci/tala-performance/compare.py:48— compare.main has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), ternaries 3 (5 pts), boolean chains 4, loops 2 (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.
d2cli.fmtCmd (cognitive 25) d2cli/fmt.go:18— d2cli.fmtCmd has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 1, loops 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.
compiler.compileArrowheads (cognitive 25) d2compiler/compile.go:1327— compiler.compileArrowheads has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (21 pts), boolean chains 2, loops 1 (2 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.
Map.QueryAll (cognitive 25) d2ir/query.go:10— Map.QueryAll has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 3 (5 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.
d2dagrelayout.getRanks (cognitive 25) d2layouts/d2dagrelayout/layout.go:611— d2dagrelayout.getRanks has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 6 (8 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.
d2grid.layoutGrid (cognitive 25) d2layouts/d2grid/layout.go:184— d2grid.layoutGrid has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (21 pts), boolean chains 3, 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.
sequenceDiagram.adjustGroupLabel (cognitive 25) d2layouts/d2sequence/sequence_diagram.go:313— sequenceDiagram.adjustGroupLabel has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 7 (9 pts), boolean chains 2 (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.
quality.chargeEvaluationAreaWork (cognitive 25) d2layouts/d2talalayout/internal/quality/evaluation_guard.go:57— quality.chargeEvaluationAreaWork has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 4 (7 pts), boolean chains 2 (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.
routing.positionedArrowheadLabelCost (cognitive 25) d2layouts/d2talalayout/internal/routing/slingshot.go:518— routing.positionedArrowheadLabelCost has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 5 (7 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.
trees.positionTreeEdgeLabels (cognitive 25) d2layouts/d2talalayout/internal/trees/layout.go:858— trees.positionTreeEdgeLabels has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 4 (6 pts) (nesting depth added 11). Of this number, 24 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.
trees.dominantTreeEdgeDirection (cognitive 25) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:158— trees.dominantTreeEdgeDirection has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 3 (5 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.
trees.disconnectTreeEdge (cognitive 25) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:512— trees.disconnectTreeEdge has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 2 (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.
layoutguard.CheckGraph (cognitive 25) d2layouts/internal/layoutguard/graph.go:31— layoutguard.CheckGraph has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (22 pts), loops 2, boolean chains 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.
d2isometricimg.nativeGIFLoopScene (cognitive 25) d2renderers/d2isometric/d2isometricimg/gif_loop.go:16— d2isometricimg.nativeGIFLoopScene has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 4, loops 3 (nesting depth added 6). Most of this is not in the body itself: 9 of the 25 points are its own statements and the rest belongs to one function literal inside it that branches (line 26). 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.
d2isometricimg.svgNewVisibilityGrid (cognitive 25) REDACTED:157— d2isometricimg.svgNewVisibilityGrid has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 4 (9 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.
nativeScene.Frame (cognitive 25) d2renderers/d2isometric/d2isometricimg/geometry.go:687— nativeScene.Frame has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 5, loops 2 (5 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.
meshBuilder.arrowWithOpacity (cognitive 25) d2renderers/d2isometric/d2isometricimg/geometry_routes.go:171— meshBuilder.arrowWithOpacity has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 5 (6 pts), boolean chains 4, match/switch 1 (nesting depth added 4). Of this number, 16 points are the body's own statements and 9 belong to 4 function literals 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.
nativeSurfaceSVGWriter.primitive (cognitive 25) d2renderers/d2isometric/d2isometricimg/vector_surface_svg.go:371— nativeSurfaceSVGWriter.primitive has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (22 pts), match/switch 2 (3 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.
d2raster.drawLinearYOnlyGradientMaskPixels (cognitive 25) d2renderers/d2raster/gradient.go:1228— d2raster.drawLinearYOnlyGradientMaskPixels has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (21 pts), loops 2 (3 pts), boolean chains 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.
Path.transformedGeometryBounds (cognitive 25) d2renderers/d2scene/path.go:99— Path.transformedGeometryBounds has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (22 pts), match/switch 1 (2 pts), loops 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.
builder.measureAppendix (cognitive 25) d2renderers/d2scenebuild/appendix.go:139— builder.measureAppendix has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (23 pts), boolean chains 1, 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.
d2svgimport.validatePrimitiveBounds (cognitive 25) d2renderers/d2svgimport/import.go:242— d2svgimport.validatePrimitiveBounds has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 3, match/switch 2 (3 pts), loops 1 (nesting depth added 10). Of this number, 22 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.
svgImporter.compileGradientResources (cognitive 25) d2renderers/d2svgimport/gradient.go:243— svgImporter.compileGradientResources has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 3 (6 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.
svgImporter.validateFrozenMathJaxTextElement (cognitive 25) d2renderers/d2svgimport/mathjax_text.go:57— svgImporter.validateFrozenMathJaxTextElement has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (16 pts), boolean chains 7, loops 2 (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.
transformParser.arguments (cognitive 25) d2renderers/d2svgimport/transform.go:103— transformParser.arguments has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 4, 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.
d2target.ValidateRenderTarget (cognitive 25) d2target/render_validation.go:23— d2target.ValidateRenderTarget has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 3 (6 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.
Resolver.validateCached (cognitive 25) lib/imageasset/resolve.go:633— Resolver.validateCached has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (18 pts), boolean chains 6, match/switch 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.
xgif.AnimateCenteredOpaquePalettedImagesWithLimit (cognitive 25) lib/xgif/encode.go:38— xgif.AnimateCenteredOpaquePalettedImagesWithLimit has cognitive complexity 25 (threshold 15). Drivers by points: if/else 14 (22 pts), loops 2, 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.
paletteTree.nearest (cognitive 25) lib/xgif/xgif.go:722— paletteTree.nearest has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 5, 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.
d2graph.ResolveUnderscoreKey (cognitive 24) d2graph/d2graph.go:775— d2graph.ResolveUnderscoreKey has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 2 (4 pts), boolean chains 2 (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.
astCloner.cloneArray (cognitive 24) d2ir/import_cache.go:91— astCloner.cloneArray has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (21 pts), match/switch 1 (2 pts), loops 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.
d2dagrelayout.positionLabelsIcons (cognitive 24) d2layouts/d2dagrelayout/layout.go:577— d2dagrelayout.positionLabelsIcons has cognitive complexity 24 (threshold 15). Drivers by points: if/else 13 (20 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.
d2elklayout.positionLabelsIcons (cognitive 24) d2layouts/d2elklayout/layout.go:1153— d2elklayout.positionLabelsIcons has cognitive complexity 24 (threshold 15). Drivers by points: if/else 13 (20 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.
sequenceDiagram.placeSpans (cognitive 24) d2layouts/d2sequence/sequence_diagram.go:525— sequenceDiagram.placeSpans has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 4, loops 3 (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.
d2talalayout.collectD2ObjectVisits (cognitive 24) d2layouts/d2talalayout/adapter_validate.go:27— d2talalayout.collectD2ObjectVisits has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 2 (3 pts) (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.
hierarchy.verticalAlignment (cognitive 24) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:535— hierarchy.verticalAlignment has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). Of this number, 23 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.
hierarchy.compoundInterfaceScore (cognitive 24) REDACTED:309— hierarchy.compoundInterfaceScore has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 3 (4 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.
hierarchy.Assign (cognitive 24) d2layouts/d2talalayout/internal/hierarchy/discovery.go:38— hierarchy.Assign has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (19 pts), loops 4 (5 pts) (nesting depth added 8). Of this number, 23 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.
routing.changedRouteIsClear (cognitive 24) d2layouts/d2talalayout/internal/routing/port_interior_balance.go:87— routing.changedRouteIsClear has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 5, 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.
routing.shortcutLabelBoxes (cognitive 24) d2layouts/d2talalayout/internal/routing/shortcut_routes.go:518— routing.shortcutLabelBoxes has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 4, loops 2 (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.
d2lsp.getBoardPathAtPosition (cognitive 24) d2lsp/d2lsp.go:107— d2lsp.getBoardPathAtPosition has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (20 pts), boolean chains 3, loops 1 (nesting depth added 11). Of this number, 23 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.
d2oracle.ensureNode (cognitive 24) d2oracle/edit.go:1652— d2oracle.ensureNode has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 3, 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.
parser.parseDoubleQuotedString (cognitive 24) d2parser/parse.go:1357— parser.parseDoubleQuotedString has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (22 pts), boolean chains 1, loops 1 (nesting depth added 12). Of this number, 23 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.
d2isometricimg.renderGIF (cognitive 24) d2renderers/d2isometric/d2isometricimg/gif.go:20— d2isometricimg.renderGIF has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 4 (7 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.
d2isometricimg.hierarchyStrongTerraces (cognitive 24) d2renderers/d2isometric/d2isometricimg/hierarchy_support.go:20— d2isometricimg.hierarchyStrongTerraces has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 5, boolean chains 4 (nesting depth added 6). Of this number, 19 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.
d2isometricimg.nativeSequenceCaptionData (cognitive 24) d2renderers/d2isometric/d2isometricimg/sequence_routes.go:100— d2isometricimg.nativeSequenceCaptionData has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 5, loops 3 (4 pts) (nesting depth added 4). Of this number, 22 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, 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.
meshBuilder.box (cognitive 24) d2renderers/d2isometric/d2isometricimg/geometry.go:163— meshBuilder.box has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (10 pts), boolean chains 1 (nesting depth added 13). Of this number, 18 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.
d2raster.paintDropShadow (cognitive 24) d2renderers/d2raster/filter.go:918— d2raster.paintDropShadow has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (20 pts), loops 2 (3 pts), boolean chains 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.
d2raster.roundedRectSubpaths (cognitive 24) d2renderers/d2raster/geometry.go:176— d2raster.roundedRectSubpaths has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 8). Of this number, 21 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.
d2raster.prepareAnimatedPaintWithPattern (cognitive 24) d2renderers/d2raster/gradient.go:62— d2raster.prepareAnimatedPaintWithPattern has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (23 pts), match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
retainedVectorValidator.stroke (cognitive 24) d2renderers/d2raster/vector_validation.go:756— retainedVectorValidator.stroke has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 5, match/switch 2, loops 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.
d2svg.addAppendixItems (cognitive 24) d2renderers/d2svg/d2svg.go:2268— d2svg.addAppendixItems has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 2, match/switch 1 (2 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.
svgImporter.validateUseGraph (cognitive 24) d2renderers/d2svgimport/compile.go:96— svgImporter.validateUseGraph has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (4 pts), match/switch 1 (2 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.
clusterFaceResolver.supports (cognitive 24) d2renderers/internal/fontface/shaping.go:445— clusterFaceResolver.supports has cognitive complexity 24 (threshold 15). Drivers by points: if/else 15 (23 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.
testutil.inspectPDFImage (cognitive 24) internal/testutil/pdf.go:343— testutil.inspectPDFImage has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 4, loops 2 (3 pts), match/switch 1 (nesting depth added 3). 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.
testutil.ValidatePPTX (cognitive 24) internal/testutil/pptx.go:18— testutil.ValidatePPTX has cognitive complexity 24 (threshold 15). Drivers by points: if/else 16 (22 pts), loops 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.
paletteTree.nearestRGBA (cognitive 24) lib/xgif/xgif.go:796— paletteTree.nearestRGBA has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 5, 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.
d2cli.validateBoardOutputManifest (cognitive 23) d2cli/board_output_publish.go:272— d2cli.validateBoardOutputManifest has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 4 (5 pts), boolean chains 3 (nesting depth added 6). Of this number, 18 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.
compiler.compileBoard (cognitive 23) d2compiler/compile.go:145— compiler.compileBoard has cognitive complexity 23 (threshold 15). Drivers by points: if/else 18 (21 pts), boolean chains 2 (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.
compiler.overlayClasses (cognitive 23) REDACTED:215— compiler.overlayClasses has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 2, 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.
d2ir.canSelectImportNode (cognitive 23) d2ir/import_cache.go:407— d2ir.canSelectImportNode has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (6 pts), boolean chains 3, match/switch 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
containerTopology.longestChainEndpoints (cognitive 23) d2layouts/d2dagrelayout/layout.go:507— containerTopology.longestChainEndpoints has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 5 (8 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.
d2talalayout.validateResultEdge (cognitive 23) d2layouts/d2talalayout/result_validate.go:510— d2talalayout.validateResultEdge has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (20 pts), loops 2, boolean chains 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.
pipeline.runAllStages (cognitive 23) REDACTED:403— pipeline.runAllStages has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 3, 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.
hierarchy.medianNeighborsContext (cognitive 23) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:407— hierarchy.medianNeighborsContext has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 2 (4 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.
rankProblem.makeResult (cognitive 23) d2layouts/d2talalayout/internal/hierarchy/rank.go:100— rankProblem.makeResult has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 3, boolean chains 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.
placement.compaction (cognitive 23) d2layouts/d2talalayout/internal/placement/compaction.go:32— placement.compaction has cognitive complexity 23 (threshold 15). Drivers by points: if/else 15 (19 pts), boolean chains 2, loops 2 (nesting depth added 4). Of this number, 22 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.
placement.newSizelessOptimizer (cognitive 23) REDACTED:29— placement.newSizelessOptimizer has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 2, loops 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.
sizelessOptimizer.moveNodeToBestGuarded (cognitive 23) REDACTED:403— sizelessOptimizer.moveNodeToBestGuarded has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 8). Of this number, 22 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.
ovgEdgeRouter.slingshot (cognitive 23) d2layouts/d2talalayout/internal/routing/slingshot.go:566— ovgEdgeRouter.slingshot has cognitive complexity 23 (threshold 15). Drivers by points: if/else 15 (19 pts), boolean chains 3, loops 1 (nesting depth added 4). Of this number, 14 points are the body's own statements and 9 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.
trees.reconnectTreeGuarded (cognitive 23) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:578— trees.reconnectTreeGuarded has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 2 (3 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.
d2isometricimg.nativeArrowOverlap (cognitive 23) d2renderers/d2isometric/d2isometricimg/arrow_visibility.go:285— d2isometricimg.nativeArrowOverlap has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (16 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 14). Of this number, 20 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.
meshBuilder.classicInkFace (cognitive 23) d2renderers/d2isometric/d2isometricimg/native_edges.go:594— meshBuilder.classicInkFace has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 5 (7 pts), boolean chains 1 (nesting depth added 8). Of this number, 16 points are the body's own statements and 7 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.
d2raster.planBandResources (cognitive 23) d2renderers/d2raster/bands.go:120— d2raster.planBandResources has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 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.
d2raster.renderFilteredEffectNode (cognitive 23) d2renderers/d2raster/effects.go:718— d2raster.renderFilteredEffectNode has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 2, loops 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.
d2raster.regionalFilters (cognitive 23) d2renderers/d2raster/filter.go:318— d2raster.regionalFilters has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 2 (3 pts) (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.
d2raster.drawRadialGradientCoverage (cognitive 23) d2renderers/d2raster/gradient.go:934— d2raster.drawRadialGradientCoverage has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 2, loops 1 (nesting depth added 10). None of this is in the body itself: all 23 points belong to one function literal inside it that branches (line 935). 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.
d2raster.bilinearPremultiplied (cognitive 23) d2renderers/d2raster/image.go:1089— d2raster.bilinearPremultiplied has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (17 pts), loops 3 (5 pts), boolean chains 1 (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, 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.
d2raster.prepareAnimatedStrokeWithPaint (cognitive 23) d2renderers/d2raster/raster.go:1475— d2raster.prepareAnimatedStrokeWithPaint has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 4, match/switch 2, 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.
d2scenebuild.validateShapeEffectIntegerBounds (cognitive 23) d2renderers/d2scenebuild/shape_effects.go:202— d2scenebuild.validateShapeEffectIntegerBounds has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 2, loops 1 (nesting depth added 8). Of this number, 20 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.
d2scenebuild.sketchStreakRoot (cognitive 23) d2renderers/d2scenebuild/sketch_shapes.go:866— d2scenebuild.sketchStreakRoot has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 3, boolean chains 2 (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.
builder.buildSketchTypedShapePaths (cognitive 23) d2renderers/d2scenebuild/sketch_shapes.go:241— builder.buildSketchTypedShapePaths has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 3 (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.
legendLayout.expandViewBox (cognitive 23) d2renderers/d2scenebuild/legend.go:293— legendLayout.expandViewBox has cognitive complexity 23 (threshold 15). Drivers by points: if/else 15 (21 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.
d2sketch.compileRoughOperationSet (cognitive 23) d2renderers/d2sketch/scene.go:117— d2sketch.compileRoughOperationSet has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (20 pts), match/switch 1 (2 pts), loops 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.
d2svgimport.inspectEmbeddedWebP (cognitive 23) d2renderers/d2svgimport/image.go:583— d2svgimport.inspectEmbeddedWebP has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 4, 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.
Resolver.resolveOne (cognitive 23) lib/imageasset/resolve.go:134— Resolver.resolveOne has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 1, match/switch 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.
markdownPainter.flowUnits (cognitive 23) lib/textmeasure/markdown_svg.go:681— markdownPainter.flowUnits has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 5, loops 1 (nesting depth added 9). Of this number, 21 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.
overlay.prepare (cognitive 23) ci/nonlayout-perf/overlay.py:24— overlay.prepare has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 6 (8 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.
d2cli.indexPagedBoards (cognitive 22) d2cli/paged.go:344— d2cli.indexPagedBoards has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (19 pts), loops 2 (3 pts) (nesting depth added 7). Most of this is not in the body itself: 3 of the 22 points are its own statements and the rest belongs to one function literal inside it that branches (line 355). 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.
d2cli.addPPTXLinks (cognitive 22) d2cli/paged.go:631— d2cli.addPPTXLinks has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2, match/switch 1 (2 pts), boolean chains 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.
compiler.compileLegend (cognitive 22) d2compiler/compile.go:256— compiler.compileLegend has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 5, loops 2 (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.
d2graph.addSQLTableColumnIndices (cognitive 22) d2graph/d2graph.go:1348— d2graph.addSQLTableColumnIndices has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (6 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.
d2graph.compareSerializedEdge (cognitive 22) REDACTED:387— d2graph.compareSerializedEdge has cognitive complexity 22 (threshold 15). Drivers by points: if/else 16 (18 pts), boolean chains 4 (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.
compiler.ampersandFilterMap (cognitive 22) REDACTED:934— compiler.ampersandFilterMap has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (19 pts), match/switch 1 (2 pts), loops 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.
sequenceDiagram.routeMessages (cognitive 22) d2layouts/d2sequence/sequence_diagram.go:590— sequenceDiagram.routeMessages has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 4 (7 pts), boolean chains 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.
hierarchy.createAlignmentNodes (cognitive 22) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:223— hierarchy.createAlignmentNodes has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 3 (4 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.
hierarchy.isEligibleContainer (cognitive 22) d2layouts/d2talalayout/internal/hierarchy/eligibility.go:51— hierarchy.isEligibleContainer has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 3, loops 2 (3 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.
graphCloneState.copyAbductions (cognitive 22) REDACTED:486— graphCloneState.copyAbductions has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3, boolean chains 1 (nesting depth added 9). Most of this is not in the body itself: 6 of the 22 points are its own statements and the rest belongs to one function literal inside it that branches (line 487). 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.
Graph.containerPadding (cognitive 22) d2layouts/d2talalayout/internal/layoutgraph/graph.go:1168— Graph.containerPadding has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 3, loops 1 (2 pts), match/switch 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.
placement.visibilityEdges (cognitive 22) d2layouts/d2talalayout/internal/placement/compaction.go:427— placement.visibilityEdges has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 2 (3 pts) (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.
placement.direct (cognitive 22) d2layouts/d2talalayout/internal/placement/direct.go:270— placement.direct has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 4, loops 1 (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.
placement.isBetween (cognitive 22) d2layouts/d2talalayout/internal/placement/gapreduction.go:92— placement.isBetween has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (22 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.
placementcost.GraphEdgeCrossings (cognitive 22) d2layouts/d2talalayout/internal/placementcost/graph.go:301— placementcost.GraphEdgeCrossings has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 2, 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.
placementcost.obstructed (cognitive 22) d2layouts/d2talalayout/internal/placementcost/symmetry.go:514— placementcost.obstructed has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 6, loops 1 (nesting depth added 7). Most of this is not in the body itself: 2 of the 22 points are its own statements and the rest belongs to one function literal inside it that branches (line 516). 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.
quality.evaluateWithAreaLimit (cognitive 22) d2layouts/d2talalayout/internal/quality/scoring.go:21— quality.evaluateWithAreaLimit has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 2 (3 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.
routing.refineEdgeGuarded (cognitive 22) d2layouts/d2talalayout/internal/routing/swap_ports.go:248— routing.refineEdgeGuarded has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (20 pts), boolean chains 1, 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.
OVG.mergePorts (cognitive 22) REDACTED:1705— OVG.mergePorts has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 3 (7 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.
routeWorkGuard.add (cognitive 22) d2layouts/d2talalayout/internal/routing/route_stage_guard.go:61— routeWorkGuard.add has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 4, 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.
trees.validateBottomOrientation (cognitive 22) d2layouts/d2talalayout/internal/trees/geometry.go:251— trees.validateBottomOrientation has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 2 (3 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.
trees.spaceChildrenEvenly (cognitive 22) d2layouts/d2talalayout/internal/trees/geometry.go:409— trees.spaceChildrenEvenly has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 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.
d2oracle.deleteObjField (cognitive 22) d2oracle/edit.go:1476— d2oracle.deleteObjField has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 4, 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.
parser.parseArray (cognitive 22) d2parser/parse.go:1603— parser.parseArray has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 2 (3 pts), match/switch 1 (2 pts), boolean chains 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.
asciishapes.DrawDocument (cognitive 22) d2renderers/d2ascii/asciishapes/document.go:5— asciishapes.DrawDocument has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 5, loops 3 (4 pts) (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, 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.
d2fonts.init (cognitive 22) d2renderers/d2fonts/d2fonts_embed_wasm.go:50— d2fonts.init has cognitive complexity 22 (threshold 15). Drivers by points: if/else 22. 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.
d2isometricimg.nativeUprightContact (cognitive 22) d2renderers/d2isometric/d2isometricimg/solid_contacts.go:151— d2isometricimg.nativeUprightContact has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 4, 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.
Raster.rasterPrepareOpacityGroups (cognitive 22) d2renderers/d2isometric/d2isometricimg/opacity_groups.go:60— Raster.rasterPrepareOpacityGroups has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 4 (5 pts), boolean chains 3 (nesting depth added 6). Of this number, 16 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.
surfaceIconPainter.texture (cognitive 22) d2renderers/d2isometric/d2isometricimg/surface_icons.go:130— surfaceIconPainter.texture has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 5, loops 2 (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.
svgVisibleFragmentSet.changeCells (cognitive 22) d2renderers/d2isometric/d2isometricimg/svg_fragments.go:41— svgVisibleFragmentSet.changeCells has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (19 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.
d2raster.drawPaintMaskPixels (cognitive 22) d2renderers/d2raster/gradient.go:1092— d2raster.drawPaintMaskPixels has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (18 pts), loops 2 (3 pts), boolean chains 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.
Rasterizer.prepareScanEdges (cognitive 22) REDACTED:1095— Rasterizer.prepareScanEdges has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 2, 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.
d2scenebuild.Build (cognitive 22) d2renderers/d2scenebuild/build.go:165— d2scenebuild.Build has cognitive complexity 22 (threshold 15). Drivers by points: if/else 16 (18 pts), boolean chains 3, loops 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.
d2svgimport.containsASCIIEqualFold (cognitive 22) d2renderers/d2svgimport/style.go:222— d2svgimport.containsASCIIEqualFold has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 2 (3 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.
d2svgimport.paintWithOpacity (cognitive 22) d2renderers/d2svgimport/style.go:811— d2svgimport.paintWithOpacity has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 2 (4 pts), match/switch 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.
d2svgimport.transformFunction (cognitive 22) d2renderers/d2svgimport/transform.go:247— d2svgimport.transformFunction has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 3, match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
svgGeometry.primitive (cognitive 22) d2renderers/d2svgimport/compile.go:597— svgGeometry.primitive has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 7, match/switch 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.
svgImporter.pointCommands (cognitive 22) d2renderers/d2svgimport/geometry.go:195— svgImporter.pointCommands has cognitive complexity 22 (threshold 15). Drivers by points: if/else 15 (20 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.
imgbundler.runResolverWorkersWithLimit (cognitive 22) lib/imgbundler/imgbundler.go:298— imgbundler.runResolverWorkersWithLimit has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 4 (5 pts), match/switch 2 (4 pts) (nesting depth added 12). Of this number, 14 points are the body's own statements and 8 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.
textmeasure.normalizeMarkdownWhitespaceTree (cognitive 22) lib/textmeasure/markdown.go:241— textmeasure.normalizeMarkdownWhitespaceTree has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 4 (7 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 9). Most of this is not in the body itself: 1 of the 22 points is its own statement and the rest belongs to 4 function literals inside it that branch (lines 266, 300, 257, …). 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.
upload-draft.upload (cognitive 22) ci/release/upload-draft.py:116— upload-draft.upload has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 3, 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.
init::onmessage (cognitive 22) REDACTED:18— init::onmessage has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (22 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.
dslGenState.edge (cognitive 21) REDACTED:127— dslGenState.edge has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 1, 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.
d2cli.mapPagedLinks (cognitive 21) d2cli/paged.go:273— d2cli.mapPagedLinks has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (17 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.
watcher.replaceWatchList (cognitive 21) REDACTED:396— watcher.replaceWatchList has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 4 (6 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.
d2compiler.foldClassName (cognitive 21) d2compiler/compile.go:612— d2compiler.foldClassName has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (6 pts), boolean chains 2 (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.
compiler.validateEdges (cognitive 21) d2compiler/compile.go:1690— compiler.validateEdges has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 6, 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.
d2exporter.toShape (cognitive 21) d2exporter/export.go:209— d2exporter.toShape has cognitive complexity 21 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 1, match/switch 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.
printer.array (cognitive 21) d2format/format.go:245— printer.array has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 3, 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.
Object.EnsureChild (cognitive 21) d2graph/d2graph.go:878— Object.EnsureChild has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, loops 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.
Object.GetLabelSize (cognitive 21) d2graph/d2graph.go:945— Object.GetLabelSize has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 2, match/switch 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.
compiler._ampersandPropertyFilter (cognitive 21) REDACTED:1608— compiler._ampersandPropertyFilter has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2 (4 pts), boolean chains 2, match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
d2ir.foldString (cognitive 21) REDACTED:200— d2ir.foldString has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (6 pts), boolean chains 2 (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.
spatialIndex.query (cognitive 21) d2layouts/d2elklayout/spatial_index.go:119— spatialIndex.query has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 4 (6 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.
d2talalayout.allocateD2EntityIDs (cognitive 21) d2layouts/d2talalayout/adapter.go:52— d2talalayout.allocateD2EntityIDs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 3, boolean chains 1 (nesting depth added 8). Of this number, 20 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.
d2talalayout.validateD2GraphStructure (cognitive 21) d2layouts/d2talalayout/adapter_validate.go:330— d2talalayout.validateD2GraphStructure has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 4 (5 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.
grouping.abductClusterEdges (cognitive 21) REDACTED:130— grouping.abductClusterEdges has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (7 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.
clusterDiscoveryIndex.sequenceOriginal (cognitive 21) d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:100— clusterDiscoveryIndex.sequenceOriginal has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (15 pts), match/switch 1 (3 pts), loops 1 (2 pts), boolean chains 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.
Edge.isAxisAligned (cognitive 21) d2layouts/d2talalayout/internal/layoutgraph/edge.go:253— Edge.isAxisAligned has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (19 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.
Transaction.Rollback (cognitive 21) d2layouts/d2talalayout/internal/layoutgraph/transaction.go:1352— Transaction.Rollback has cognitive complexity 21 (threshold 15). Drivers by points: loops 12 (20 pts), if/else 1 (nesting depth added 8). 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.
packing.routedContainerRoundedCornersStayInsideShrink (cognitive 21) d2layouts/d2talalayout/internal/packing/routed_container.go:271— packing.routedContainerRoundedCornersStayInsideShrink has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 4, 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.
placement.clusterExternalConnectedNodes (cognitive 21) d2layouts/d2talalayout/internal/placement/cluster_connections.go:9— placement.clusterExternalConnectedNodes has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (14 pts), boolean chains 4, match/switch 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.
placementcost.clusterExactlyTwoExternalConnectedNodes (cognitive 21) d2layouts/d2talalayout/internal/placementcost/cluster.go:5— placementcost.clusterExactlyTwoExternalConnectedNodes has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (12 pts), boolean chains 6, match/switch 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.
proximity.AddHubs (cognitive 21) d2layouts/d2talalayout/internal/proximity/hubs.go:13— proximity.AddHubs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2 (3 pts), boolean chains 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.
routing.estimateRouteCostGuarded (cognitive 21) d2layouts/d2talalayout/internal/routing/cluster_route_guard.go:10— routing.estimateRouteCostGuarded has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 4 (7 pts) (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.
routing.undershot (cognitive 21) d2layouts/d2talalayout/internal/routing/slingshot.go:176— routing.undershot has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 8, match/switch 1 (nesting depth added 4). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
routing.isOnFlightPlan (cognitive 21) d2layouts/d2talalayout/internal/routing/slingshot.go:289— routing.isOnFlightPlan has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 8, match/switch 1 (nesting depth added 4). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ovgEdgeRouter.findOverlappingRoutes (cognitive 21) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:1626— ovgEdgeRouter.findOverlappingRoutes has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (6 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.
d2oracle.getMostNestedRefs (cognitive 21) d2oracle/edit.go:3280— d2oracle.getMostNestedRefs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (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.
d2oracle.replaceBoardNodeInMap (cognitive 21) d2oracle/get.go:56— d2oracle.replaceBoardNodeInMap has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 3 (4 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.
projectedExtent.preparedGroundShadows (cognitive 21) d2renderers/d2isometric/d2isometricimg/framing.go:75— projectedExtent.preparedGroundShadows has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 5, loops 4 (5 pts) (nesting depth added 3). Most of this is not in the body itself: 8 of the 21 points are its own statements and the rest belongs to one function literal inside it that branches (line 90). 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.
meshBuilder.nativeFaceLayer (cognitive 21) d2renderers/d2isometric/d2isometricimg/native_shapes.go:191— meshBuilder.nativeFaceLayer has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (16 pts), boolean chains 4, loops 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.
meshBuilder.solidInkFit (cognitive 21) d2renderers/d2isometric/d2isometricimg/native_solids.go:115— meshBuilder.solidInkFit has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 5 (9 pts) (nesting depth added 10). Of this number, 19 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.
d2latex.ValidateInput (cognitive 21) d2renderers/d2latex/limits.go:21— d2latex.ValidateInput has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (17 pts), match/switch 1 (2 pts), boolean chains 1, 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.
retainedVectorValidator.gradientCommon (cognitive 21) d2renderers/d2raster/vector_validation.go:716— retainedVectorValidator.gradientCommon has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 2, loops 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.
builder.buildAppendix (cognitive 21) d2renderers/d2scenebuild/appendix.go:360— builder.buildAppendix has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 2 (3 pts), 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.
builder.resolveImageAsset (cognitive 21) d2renderers/d2scenebuild/assets.go:103— builder.resolveImageAsset has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 1, match/switch 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.
builder.ensureMissingGlyphFont (cognitive 21) d2renderers/d2scenebuild/font_fallback.go:741— builder.ensureMissingGlyphFont has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 3 (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.
builder.buildClassContents (cognitive 21) d2renderers/d2scenebuild/special_shapes.go:69— builder.buildClassContents has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (16 pts), loops 3 (4 pts), boolean chains 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.
d2sketch.ConnectionWithAttributes (cognitive 21) d2renderers/d2sketch/sketch.go:348— d2sketch.ConnectionWithAttributes has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 3, loops 2 (3 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.
d2svg.singleThemeRulesets (cognitive 21) d2renderers/d2svg/d2svg.go:3322— d2svg.singleThemeRulesets has cognitive complexity 21 (threshold 15). Drivers by points: if/else 20, loops 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.
svgImporter.validateDegenerateStrokeCaps (cognitive 21) d2renderers/d2svgimport/compile.go:193— svgImporter.validateDegenerateStrokeCaps has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 8, match/switch 1 (2 pts), loops 1 (nesting depth added 6). Of this number, 19 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.
svgImporter.simpleClassSelector (cognitive 21) d2renderers/d2svgimport/stylesheet.go:153— svgImporter.simpleClassSelector has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 4, 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.
fontface.splitInputsByAssignedFace (cognitive 21) d2renderers/internal/fontface/shaping.go:554— fontface.splitInputsByAssignedFace has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 3, loops 2 (3 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.
rasterimage.parseEXIFOrientation (cognitive 21) internal/rasterimage/jpeg_orientation.go:69— rasterimage.parseEXIFOrientation has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, loops 1, match/switch 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.
utf8FontFile.generateCharSymbolDictionary (cognitive 21) lib/font/subsetFont.go:572— utf8FontFile.generateCharSymbolDictionary has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 6 (7 pts) (nesting depth added 10). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
imageasset.decodeContentEncodings (cognitive 21) lib/imageasset/resolve.go:857— imageasset.decodeContentEncodings has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (18 pts), match/switch 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.
textmeasure.collectMarkdownTableRows (cognitive 21) lib/textmeasure/markdown_svg.go:1738— textmeasure.collectMarkdownTableRows has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 7). None of this is in the body itself: all 21 points belong to 2 function literals inside it that branch (lines 1753, 1740). 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.
markdownPainter.paintTable (cognitive 21) lib/textmeasure/markdown_svg.go:1469— markdownPainter.paintTable has cognitive complexity 21 (threshold 15). Drivers by points: loops 9 (12 pts), if/else 4 (9 pts) (nesting depth added 8). 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.
main.verifyChecksums (cognitive 20) ci/release/releasetool/main.go:512— main.verifyChecksums has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, loops 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.
d2cli.renderGIFBoardFrames (cognitive 20) d2cli/raster.go:402— d2cli.renderGIFBoardFrames has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 1, loops 1 (nesting depth added 7). Of this number, 16 points are the body's own statements and 4 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.
boardOutputTransaction.rollback (cognitive 20) d2cli/board_output_publish.go:918— boardOutputTransaction.rollback has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 3, loops 3 (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.
watcher.compileLoop (cognitive 20) REDACTED:433— watcher.compileLoop has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (17 pts), match/switch 1 (2 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.
d2compiler.hasBoard (cognitive 20) d2compiler/compile.go:1781— d2compiler.hasBoard has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (6 pts), boolean chains 1, match/switch 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.
d2exporter.Export (cognitive 20) d2exporter/export.go:22— d2exporter.Export has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (11 pts), loops 4 (8 pts), boolean chains 1 (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, 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.
compiler.compileKey (cognitive 20) REDACTED:1161— compiler.compileKey has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 4, loops 2 (4 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.
d2near.place (cognitive 20) d2layouts/d2near/layout.go:95— d2near.place has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 1, match/switch 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.
d2talalayout.coordinateLocalSeeds (cognitive 20) d2layouts/d2talalayout/layout.go:169— d2talalayout.coordinateLocalSeeds has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 4 (5 pts), boolean chains 2 (nesting depth added 5). Of this number, 18 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.
labeling.clusterBoundaryNodePlacement (cognitive 20) d2layouts/d2talalayout/internal/labeling/guard.go:295— labeling.clusterBoundaryNodePlacement has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (16 pts), match/switch 1 (2 pts), boolean chains 1, 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.
layoutgraph.segmentIntersectsBox (cognitive 20) d2layouts/d2talalayout/internal/layoutgraph/node.go:1408— layoutgraph.segmentIntersectsBox has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 11, if/else 9. Of this number, 16 points are the body's own statements and 4 belong to 2 function literals inside it that branch. 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.
graphCloneState.copyContainers (cognitive 20) REDACTED:305— graphCloneState.copyContainers has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 2 (3 pts), boolean chains 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.
Edge.stylesMatchOneWay (cognitive 20) d2layouts/d2talalayout/internal/layoutgraph/edge.go:51— Edge.stylesMatchOneWay has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 5 (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.
placement.gapNormalization (cognitive 20) d2layouts/d2talalayout/internal/placement/gapreduction.go:30— placement.gapNormalization has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 1 (nesting depth added 8). 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.
routing.channelPointProposal (cognitive 20) d2layouts/d2talalayout/internal/routing/nudge_channels.go:558— routing.channelPointProposal has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 3 (6 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.
routing.balancePortInteriorsGuarded (cognitive 20) d2layouts/d2talalayout/internal/routing/port_interior_balance.go:18— routing.balancePortInteriorsGuarded has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 2, loops 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.
OVG.addHierarchyLevelNodes (cognitive 20) d2layouts/d2talalayout/internal/routing/ovg_hierarchy.go:152— OVG.addHierarchyLevelNodes has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 4 (5 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.
d2isometricimg.classicInkPaths (cognitive 20) d2renderers/d2isometric/d2isometricimg/native_edges.go:375— d2isometricimg.classicInkPaths has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 6 (7 pts) (nesting depth added 8). Of this number, 13 points are the body's own statements and 7 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.
d2isometricimg.nativeEmbeddedAssetsOnly (cognitive 20) d2renderers/d2isometric/d2isometricimg/surface_fonts.go:19— d2isometricimg.nativeEmbeddedAssetsOnly has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (6 pts), boolean chains 1 (nesting depth added 8). Of this number, 18 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.
d2isometricimg.nativeSurfaceSVG (cognitive 20) d2renderers/d2isometric/d2isometricimg/vector_surface_svg.go:36— d2isometricimg.nativeSurfaceSVG has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 5, loops 2 (3 pts) (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.
Raster.Frame (cognitive 20) d2renderers/d2isometric/d2isometricimg/raster.go:260— Raster.Frame has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 2 (3 pts), 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.
d2raster.setBandReferenceBounds (cognitive 20) d2renderers/d2raster/bands.go:180— d2raster.setBandReferenceBounds has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 2, 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.
d2raster.planRenderResourcesRegion (cognitive 20) d2renderers/d2raster/effects.go:260— d2raster.planRenderResourcesRegion has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (19 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.
d2raster.effectRenderBounds (cognitive 20) d2renderers/d2raster/stroke_regions.go:15— d2raster.effectRenderBounds has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 3, loops 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.
retainedVectorValidator.animations (cognitive 20) d2renderers/d2raster/vector_validation.go:231— retainedVectorValidator.animations has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 2, match/switch 1 (2 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.
retainedVectorValidator.paint (cognitive 20) d2renderers/d2raster/vector_validation.go:580— retainedVectorValidator.paint has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (19 pts), match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
builder.buildSQLTableContents (cognitive 20) d2renderers/d2scenebuild/special_shapes.go:184— builder.buildSQLTableContents has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (17 pts), loops 2, boolean chains 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.
svgImporter.viewport (cognitive 20) d2renderers/d2svgimport/viewport.go:18— svgImporter.viewport has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 4, match/switch 1 (2 pts) (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.
d2target.validateRenderBoard (cognitive 20) d2target/render_validation.go:84— d2target.validateRenderBoard has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 4 (6 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.
Theme.ApplyOverrides (cognitive 20) d2themes/d2themes.go:33— Theme.ApplyOverrides has cognitive complexity 20 (threshold 15). Drivers by points: if/else 20. 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.
rasterimage.Config (cognitive 20) internal/rasterimage/firstframe.go:28— rasterimage.Config has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 1, match/switch 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.
textmeasure.ReplaceSubstitutionsMarkdownBounded (cognitive 20) lib/textmeasure/substitutions.go:24— textmeasure.ReplaceSubstitutionsMarkdownBounded has cognitive complexity 20 (threshold 15). Drivers by points: if/else 14 (17 pts), loops 2, boolean chains 1 (nesting depth added 3). Of this number, 12 points are the body's own statements and 8 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.
fewOpaqueBucket.split (cognitive 20) lib/xgif/xgif.go:246— fewOpaqueBucket.split has cognitive complexity 20 (threshold 15). Drivers by points: loops 6 (9 pts), if/else 5 (6 pts), boolean chains 4, match/switch 1 (nesting depth added 4). 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, 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.
main.runCase (cognitive 19) ci/tala-performance/main.go:95— main.runCase has cognitive complexity 19 (threshold 15). Drivers by points: if/else 13 (17 pts), loops 1 (2 pts) (nesting depth added 5). 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: 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.
d2cli.planBoardOutput (cognitive 19) d2cli/board_output.go:160— d2cli.planBoardOutput has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 4 (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.
d2cli.installBoardOutputFile (cognitive 19) d2cli/board_output_publish.go:642— d2cli.installBoardOutputFile has cognitive complexity 19 (threshold 15). Drivers by points: if/else 13 (19 pts) (nesting depth added 6). 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 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.
d2cli.renderGIF (cognitive 19) d2cli/raster.go:457— d2cli.renderGIF has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14 (19 pts) (nesting depth added 5). Most of this is not in the body itself: 7 of the 19 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 484, 470). 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.
boardOutputWorkspace.discard (cognitive 19) d2cli/board_output.go:348— boardOutputWorkspace.discard has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 3, loops 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.
printer.blockString (cognitive 19) d2format/format.go:159— printer.blockString has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 3 (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.
compiler.compileLink (cognitive 19) REDACTED:1995— compiler.compileLink has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 5, loops 2 (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.
d2talalayout.buildRoutePatch (cognitive 19) d2layouts/d2talalayout/patch.go:241— d2talalayout.buildRoutePatch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 3 (nesting depth added 7). Of this number, 12 points are the body's own statements and 7 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.
grouping.clusterIncidentEdges (cognitive 19) d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:377— grouping.clusterIncidentEdges has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 5 (7 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.
joinPositionJournal.moveWithChildren (cognitive 19) d2layouts/d2talalayout/internal/grouping/join.go:46— joinPositionJournal.moveWithChildren has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 6, loops 2 (3 pts) (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.
hierarchy.isValid (cognitive 19) d2layouts/d2talalayout/internal/hierarchy/discovery.go:249— hierarchy.isValid has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 4 (5 pts), boolean chains 4 (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.
hierarchy.makeSimpleDAG (cognitive 19) d2layouts/d2talalayout/internal/hierarchy/discovery.go:502— hierarchy.makeSimpleDAG has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 3 (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.
hierarchy.minimumDistanceToNextLevel (cognitive 19) REDACTED:456— hierarchy.minimumDistanceToNextLevel has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (3 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.
hierarchy.newRankSimplex (cognitive 19) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:58— hierarchy.newRankSimplex has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 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.
rankSimplex.computeHeadComponent (cognitive 19) d2layouts/d2talalayout/internal/hierarchy/rank_simplex.go:456— rankSimplex.computeHeadComponent has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 2 (3 pts), boolean chains 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.
layoutgraph.validateNodeParentRelation (cognitive 19) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:61— layoutgraph.validateNodeParentRelation has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (5 pts), boolean chains 2 (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.
Graph.syncNested (cognitive 19) d2layouts/d2talalayout/internal/layoutgraph/graph.go:918— Graph.syncNested has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (9 pts) (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.
Node.dfsWalk (cognitive 19) d2layouts/d2talalayout/internal/layoutgraph/node.go:2294— Node.dfsWalk has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (6 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.
placement.hasFixedDescendant (cognitive 19) d2layouts/d2talalayout/internal/placement/direct.go:140— placement.hasFixedDescendant has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (6 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.
routing.preferLaunchingVertically (cognitive 19) d2layouts/d2talalayout/internal/routing/slingshot.go:340— routing.preferLaunchingVertically has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 2, match/switch 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.
routing.makeStraightLineGuarded (cognitive 19) d2layouts/d2talalayout/internal/routing/swap_ports.go:357— routing.makeStraightLineGuarded has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (3 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.
ovgEdgeRouter.findLaunchings (cognitive 19) d2layouts/d2talalayout/internal/routing/slingshot.go:80— ovgEdgeRouter.findLaunchings has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 1, match/switch 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. This shape REPEATS in the file: one other method here (ovgEdgeRouter.findLandings) 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.
ovgEdgeRouter.findLandings (cognitive 19) d2layouts/d2talalayout/internal/routing/slingshot.go:128— ovgEdgeRouter.findLandings has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 1, match/switch 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. This shape REPEATS in the file: one other method here (ovgEdgeRouter.findLaunchings) 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.
d2Patch.apply (cognitive 19) d2layouts/d2talalayout/patch.go:119— d2Patch.apply has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 3 (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.
d2oracle.Rename (cognitive 19) d2oracle/edit.go:1699— d2oracle.Rename has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (18 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.
d2oracle.GetBoardGraph (cognitive 19) d2oracle/get.go:12— d2oracle.GetBoardGraph has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 3 (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.
parser.parseEdgeIndex (cognitive 19) d2parser/parse.go:888— parser.parseEdgeIndex has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 3, loops 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.
parser.parseEdges (cognitive 19) d2parser/parse.go:945— parser.parseEdges has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 1, 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.
parser.parseSingleQuotedString (cognitive 19) d2parser/parse.go:1428— parser.parseSingleQuotedString has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (16 pts), match/switch 1 (2 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.
asciiroute.adjustRouteStartPoint (cognitive 19) d2renderers/d2ascii/asciiroute/routing.go:180— asciiroute.adjustRouteStartPoint has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 1 (3 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. This shape REPEATS in the file: one other method here (asciiroute.adjustRouteEndPoint) 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.
asciiroute.adjustRouteEndPoint (cognitive 19) d2renderers/d2ascii/asciiroute/routing.go:248— asciiroute.adjustRouteEndPoint has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 1 (3 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. This shape REPEATS in the file: one other method here (asciiroute.adjustRouteStartPoint) 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.
asciishapes.DrawQueue (cognitive 19) d2renderers/d2ascii/asciishapes/queue.go:3— asciishapes.DrawQueue has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 13, loops 2 (3 pts), match/switch 1 (3 pts) (nesting depth added 3). 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.
asciishapes.DrawRect (cognitive 19) d2renderers/d2ascii/asciishapes/rectangle.go:11— asciishapes.DrawRect has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 5, loops 2 (3 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.
asciishapes.DrawStep (cognitive 19) d2renderers/d2ascii/asciishapes/step.go:3— asciishapes.DrawStep has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 8, if/else 6 (8 pts), loops 2 (3 pts) (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.
d2isometricimg.nativeConnectionCaptionSurface (cognitive 19) d2renderers/d2isometric/d2isometricimg/route_caption_style.go:57— d2isometricimg.nativeConnectionCaptionSurface has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 5, match/switch 2, 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.
d2isometricimg.nativeEdgeRoutes (cognitive 19) d2renderers/d2isometric/d2isometricimg/sequence_routes.go:33— d2isometricimg.nativeEdgeRoutes has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 4 (5 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.
svgVisibleFragmentSet.query (cognitive 19) d2renderers/d2isometric/d2isometricimg/svg_fragments.go:103— svgVisibleFragmentSet.query has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (6 pts) (nesting depth added 9). 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 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.
d2raster.renderEffectNode (cognitive 19) d2renderers/d2raster/effects.go:675— d2raster.renderEffectNode has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (17 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.
d2raster.spreadParameter (cognitive 19) d2renderers/d2raster/gradient.go:439— d2raster.spreadParameter has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 2, match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
d2raster.drawAxisLinearGradientCoverage (cognitive 19) d2renderers/d2raster/gradient.go:789— d2raster.drawAxisLinearGradientCoverage has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 1, loops 1, match/switch 1 (nesting depth added 7). 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 807). 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.
d2raster.validateRasterAsset (cognitive 19) d2renderers/d2raster/image.go:64— d2raster.validateRasterAsset has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 2 (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.
d2raster.drawNativeSizeAlpha (cognitive 19) d2renderers/d2raster/image.go:713— d2raster.drawNativeSizeAlpha has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 3 (6 pts) (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.
d2raster.drawNativeSizeGeneric (cognitive 19) d2renderers/d2raster/image.go:993— d2raster.drawNativeSizeGeneric has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (3 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.
preflight.preparePatternPaint (cognitive 19) d2renderers/d2raster/pattern.go:50— preflight.preparePatternPaint has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 4 (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.
retainedVectorValidator.pattern (cognitive 19) d2renderers/d2raster/vector_validation.go:633— retainedVectorValidator.pattern has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 5 (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.
d2scenebuild.markdownFontAdvance (cognitive 19) d2renderers/d2scenebuild/markdown.go:388— d2scenebuild.markdownFontAdvance has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (17 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.
codeFontMetrics.advance (cognitive 19) d2renderers/d2scenebuild/code_shape.go:360— codeFontMetrics.advance has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (17 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.
d2svgimport.validateEnableBackground (cognitive 19) d2renderers/d2svgimport/boilerplate.go:313— d2svgimport.validateEnableBackground has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 3, loops 2 (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.
d2svgimport.splitEnableBackgroundFields (cognitive 19) d2renderers/d2svgimport/boilerplate.go:353— d2svgimport.splitEnableBackgroundFields has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (17 pts), boolean chains 1, 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.
svgImporter.validateRootBoilerplate (cognitive 19) d2renderers/d2svgimport/boilerplate.go:284— svgImporter.validateRootBoilerplate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 2, 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.
svgImporter.validateStylesheetRules (cognitive 19) d2renderers/d2svgimport/gradient.go:295— svgImporter.validateStylesheetRules has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (3 pts), boolean chains 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.
ParsedFace.GlyphRenderBounds (cognitive 19) d2renderers/internal/fontface/face.go:552— ParsedFace.GlyphRenderBounds has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (17 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.
testutil.InspectGIF (cognitive 19) internal/testutil/gif.go:88— testutil.InspectGIF has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 3, match/switch 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.
testutil.undoPNGPredictor (cognitive 19) internal/testutil/pdf.go:453— testutil.undoPNGPredictor has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (3 pts), match/switch 1 (3 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.
Presentation.writeTo (cognitive 19) lib/pptx/pptx.go:203— Presentation.writeTo has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (16 pts), loops 3 (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.
textmeasure.isColorEmojiGrapheme (cognitive 19) lib/textmeasure/textmeasure.go:402— textmeasure.isColorEmojiGrapheme has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 7). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
Ruler.scaleUnicode (cognitive 19) lib/textmeasure/textmeasure.go:277— Ruler.scaleUnicode has cognitive complexity 19 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 3 (9 pts) (nesting depth added 13). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
xgif.sortPaletteNodes (cognitive 19) lib/xgif/xgif.go:681— xgif.sortPaletteNodes has cognitive complexity 19 (threshold 15). Drivers by points: loops 6 (12 pts), if/else 3 (6 pts), boolean chains 1 (nesting depth added 9). 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.
xgif.encodePalettedImages (cognitive 19) lib/xgif/xgif.go:1296— xgif.encodePalettedImages has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 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.
d2cli.pdfLinkShapes (cognitive 18) d2cli/paged.go:587— d2cli.pdfLinkShapes has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 1, 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.
boardOutputTransaction.staleFileChanges (cognitive 18) d2cli/board_output_publish.go:474— boardOutputTransaction.staleFileChanges has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 2, 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.
pagedRenderer.render (cognitive 18) d2cli/paged.go:124— pagedRenderer.render has cognitive complexity 18 (threshold 15). Drivers by points: if/else 17 (18 pts) (nesting depth added 1). Of this number, 12 points are the body's own statements and 6 belong to one function literal inside it that branches. 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.
d2exporter.applyStyles (cognitive 18) d2exporter/export.go:152— d2exporter.applyStyles has cognitive complexity 18 (threshold 15). Drivers by points: if/else 18. 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.
Object.GetMargin (cognitive 18) d2graph/layout.go:289— Object.GetMargin has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 4 (10 pts), if/else 4 (6 pts), boolean chains 2 (nesting depth added 8). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
d2ir.matchPattern (cognitive 18) d2ir/pattern.go:198— d2ir.matchPattern has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (17 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.
Map.deleteEdgesForFieldReferences (cognitive 18) REDACTED:504— Map.deleteEdgesForFieldReferences has cognitive complexity 18 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 2 (8 pts) (nesting depth added 12). 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.
astCloner.cloneMap (cognitive 18) d2ir/import_cache.go:46— astCloner.cloneMap has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 1 (2 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.
descendantShifter.shift (cognitive 18) d2layouts/d2elklayout/descendant_shifter.go:53— descendantShifter.shift has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 3 (5 pts), boolean chains 4 (nesting depth added 5). Of this number, 15 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.
d2elklayout.deconflictSelfLoopLabels (cognitive 18) d2layouts/d2elklayout/layout.go:697— d2elklayout.deconflictSelfLoopLabels has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (4 pts), boolean chains 2 (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.
engine.CompoundCandidate (cognitive 18) REDACTED:16— engine.CompoundCandidate has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11, boolean chains 6, loops 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.
grouping.hasNodeID (cognitive 18) REDACTED:464— grouping.hasNodeID has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 8, if/else 4 (7 pts), loops 3 (nesting depth added 3). Of this number, 15 points are the body's own statements and 3 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.
hierarchy.placeNodesInHierarchy (cognitive 18) REDACTED:192— hierarchy.placeNodesInHierarchy has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 2 (3 pts), match/switch 1 (nesting depth added 5). Of this number, 17 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.
packing.binPackPositionContainerChildren (cognitive 18) d2layouts/d2talalayout/internal/packing/guard.go:274— packing.binPackPositionContainerChildren has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 4, loops 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.
placement.NormalizeGaps (cognitive 18) d2layouts/d2talalayout/internal/placement/stages.go:175— placement.NormalizeGaps has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 3 (4 pts), boolean chains 3 (nesting depth added 4). Of this number, 15 points are the body's own statements and 3 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.
ovgEdgeRouter.centerSymmetricalPorts (cognitive 18) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:428— ovgEdgeRouter.centerSymmetricalPorts has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 2 (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.
ovgEdgeSet.addGuarded (cognitive 18) d2layouts/d2talalayout/internal/routing/ovg_edge_set.go:94— ovgEdgeSet.addGuarded has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (18 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.
d2oracle.bumpChildrenUnderscores (cognitive 18) d2oracle/edit.go:1107— d2oracle.bumpChildrenUnderscores has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 2 (3 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.
parser.parseArrayNode (cognitive 18) d2parser/parse.go:1663— parser.parseArrayNode has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 2, match/switch 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.
asciiroute.shouldDrawTJunction (cognitive 18) d2renderers/d2ascii/asciiroute/drawing.go:223— asciiroute.shouldDrawTJunction has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 8 (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.
d2isometricimg.normalize (cognitive 18) d2renderers/d2isometric/d2isometricimg/render.go:56— d2isometricimg.normalize has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 7 (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.
d2isometricimg.nativeQueueContact (cognitive 18) d2renderers/d2isometric/d2isometricimg/solid_contacts.go:218— d2isometricimg.nativeQueueContact has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 5, loops 1 (nesting depth added 1). Of this number, 15 points are the body's own statements and 3 belong to one function literal inside it that branches. 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.
meshBuilder.node (cognitive 18) d2renderers/d2isometric/d2isometricimg/geometry.go:630— meshBuilder.node has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10, loops 2 (5 pts), boolean chains 3 (nesting depth added 3). 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.
d2raster.rasterizeEvenOddMask (cognitive 18) d2renderers/d2raster/effects.go:934— d2raster.rasterizeEvenOddMask has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 2 (3 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.
d2raster.prepareLinearGradient (cognitive 18) d2renderers/d2raster/gradient.go:121— d2raster.prepareLinearGradient has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 4 (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.
preparedGradient.radialParameter (cognitive 18) d2renderers/d2raster/gradient.go:383— preparedGradient.radialParameter has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 2 (3 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.
retainedVectorValidator.image (cognitive 18) d2renderers/d2raster/vector_validation.go:479— retainedVectorValidator.image has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 3 (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.
d2scenebuild.admitSceneWork (cognitive 18) d2renderers/d2scenebuild/build.go:245— d2scenebuild.admitSceneWork has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (3 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.
builder.buildOrdinaryShapeOutline (cognitive 18) d2renderers/d2scenebuild/shape_effects.go:278— builder.buildOrdinaryShapeOutline has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 1 (2 pts), boolean chains 1, match/switch 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.
builder.buildSketchDoubleBorderShape (cognitive 18) d2renderers/d2scenebuild/sketch_shapes.go:498— builder.buildSketchDoubleBorderShape has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 3 (nesting depth added 5). Of this number, 17 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.
appendix.Append (cognitive 18) d2renderers/d2svg/appendix/appendix.go:66— appendix.Append has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (15 pts), loops 3 (nesting depth added 3). Of this number, 17 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.
d2svg.pruneThemeRules (cognitive 18) d2renderers/d2svg/theme.go:78— d2svg.pruneThemeRules has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (3 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.
d2svgimport.parseDashArray (cognitive 18) d2renderers/d2svgimport/style.go:699— d2svgimport.parseDashArray has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 4, loops 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.
svgImporter.clipCommands (cognitive 18) d2renderers/d2svgimport/clip.go:214— svgImporter.clipCommands has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (12 pts), boolean chains 3, loops 1 (2 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
d2target.calculateTooltipBounds (cognitive 18) d2target/d2target.go:620— d2target.calculateTooltipBounds has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (16 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.
testutil.ExtractPPTXImages (cognitive 18) internal/testutil/pptx.go:104— testutil.ExtractPPTXImages has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 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.
svg.parseSupportedExternalDoctype (cognitive 18) lib/svg/doctype.go:67— svg.parseSupportedExternalDoctype has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 8 (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.
markdownPainter.collectInlineTokens (cognitive 18) lib/textmeasure/markdown_svg.go:1312— markdownPainter.collectInlineTokens has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 6, loops 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.
xgif.quantizeRasterImageWithWorkspace (cognitive 18) lib/xgif/xgif.go:170— xgif.quantizeRasterImageWithWorkspace has cognitive complexity 18 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 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.
d2cli.collectGIFBoards (cognitive 17) d2cli/raster.go:905— d2cli.collectGIFBoards has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 2 (3 pts) (nesting depth added 4). Most of this is not in the body itself: 3 of the 17 points are its own statements and the rest belongs to one function literal inside it that branches (line 916). 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.
boardOutputWorkspace.preflightMerge (cognitive 17) d2cli/board_output.go:433— boardOutputWorkspace.preflightMerge has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 4 (nesting depth added 2). Most of this is not in the body itself: 1 of the 17 points is its own statement and the rest belongs to one function literal inside it that branches (line 435). 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.
boardOutputTransaction.apply (cognitive 17) d2cli/board_output_publish.go:426— boardOutputTransaction.apply has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 4, boolean chains 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.
d2compiler._findFieldAST (cognitive 17) d2compiler/compile.go:379— d2compiler._findFieldAST has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (15 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.
compiler.compileBoardsField (cognitive 17) d2compiler/compile.go:319— compiler.compileBoardsField has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 1 (2 pts), 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.
compiler.compileLabel (cognitive 17) d2compiler/compile.go:761— compiler.compileLabel has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), match/switch 3 (7 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
compiler.compileSQLTable (cognitive 17) d2compiler/compile.go:1457— compiler.compileSQLTable has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (4 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.
d2graph.DeserializeGraph (cognitive 17) REDACTED:24— d2graph.DeserializeGraph has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 4 (6 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.
Object.Text (cognitive 17) d2graph/d2graph.go:659— Object.Text has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 7 (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.
compiler._ampersandFilter (cognitive 17) REDACTED:1671— compiler._ampersandFilter has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 1 (2 pts), 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.
d2ir.Compile (cognitive 17) REDACTED:109— d2ir.Compile has cognitive complexity 17 (threshold 15). Drivers by points: if/else 17. 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.
Map.removeSuspendedFields (cognitive 17) REDACTED:2375— Map.removeSuspendedFields has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (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.
Map.ensureFieldMode (cognitive 17) REDACTED:1179— Map.ensureFieldMode has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 4, 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.
RefContext.Equal (cognitive 17) REDACTED:974— RefContext.Equal has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 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.
sequenceDiagram.placeNotes (cognitive 17) d2layouts/d2sequence/sequence_diagram.go:481— sequenceDiagram.placeNotes has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 4 (6 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.
d2talalayout.buildEdgePatch (cognitive 17) d2layouts/d2talalayout/patch.go:372— d2talalayout.buildEdgePatch has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 2, loops 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.
placement.tryMove (cognitive 17) d2layouts/d2talalayout/internal/placement/alignment.go:234— placement.tryMove has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 1 (nesting depth added 8). Of this number, 15 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.
placement.canOptimizeNodeGuarded (cognitive 17) REDACTED:598— placement.canOptimizeNodeGuarded has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 1 (2 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.
placementcost.placementEdgeLengthState (cognitive 17) d2layouts/d2talalayout/internal/placementcost/graph.go:19— placementcost.placementEdgeLengthState has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 3 (4 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.
placementcost.ColumnCrossingCost (cognitive 17) d2layouts/d2talalayout/internal/placementcost/symmetry.go:575— placementcost.ColumnCrossingCost has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, loops 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.
routing.solveChannelGap (cognitive 17) d2layouts/d2talalayout/internal/routing/nudge_channels.go:386— routing.solveChannelGap has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (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.
trees.swapDimensions (cognitive 17) d2layouts/d2talalayout/internal/trees/geometry.go:720— trees.swapDimensions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 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.
parser.parseMapKey (cognitive 17) d2parser/parse.go:711— parser.parseMapKey has cognitive complexity 17 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 1, match/switch 1 (nesting depth added 2). Of this number, 15 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, 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.
asciiroute.drawSegmentBetweenPoints (cognitive 17) d2renderers/d2ascii/asciiroute/drawing.go:14— asciiroute.drawSegmentBetweenPoints has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, loops 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.
asciishapes.DrawCallout (cognitive 17) d2renderers/d2ascii/asciishapes/callout.go:5— asciishapes.DrawCallout has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 6, loops 2 (3 pts) (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.
asciishapes.DrawDiamond (cognitive 17) d2renderers/d2ascii/asciishapes/diamond.go:5— asciishapes.DrawDiamond has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (7 pts), loops 4 (6 pts), boolean chains 4 (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.
d2isometricimg.hierarchyHeaderStrip (cognitive 17) d2renderers/d2isometric/d2isometricimg/hierarchy_headers.go:197— d2isometricimg.hierarchyHeaderStrip has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 2, loops 2 (nesting depth added 3). Of this number, 14 points are the body's own statements and 3 belong to 2 function literals 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.
d2isometricimg.captionHullOverlap (cognitive 17) d2renderers/d2isometric/d2isometricimg/projection_clearance.go:143— d2isometricimg.captionHullOverlap has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 9). 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.
d2isometricimg.writeSVGPaintCover (cognitive 17) REDACTED:57— d2isometricimg.writeSVGPaintCover has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 4 (6 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.
meshBuilder.printStyle (cognitive 17) d2renderers/d2isometric/d2isometricimg/geometry.go:302— meshBuilder.printStyle has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 2, loops 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.
routeCaptionPlacer.AvoidMesh (cognitive 17) d2renderers/d2isometric/d2isometricimg/projection_clearance.go:24— routeCaptionPlacer.AvoidMesh has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (4 pts), 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.
d2isometric.hierarchyRoute (cognitive 17) REDACTED:139— d2isometric.hierarchyRoute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 4). Of this number, 12 points are the body's own statements and 5 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.
d2raster.drawStroke (cognitive 17) d2renderers/d2raster/geometry.go:445— d2raster.drawStroke has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2 (3 pts) (nesting depth added 8). Of this number, 11 points are the body's own statements and 6 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.
d2raster.drawLinearGradientCoverage (cognitive 17) d2renderers/d2raster/gradient.go:850— d2raster.drawLinearGradientCoverage has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, loops 1 (nesting depth added 7). None of this is in the body itself: all 17 points belong to one function literal inside it that branches (line 851). 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.
patternCollector.node (cognitive 17) d2renderers/d2raster/pattern.go:346— patternCollector.node has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 3, loops 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.
d2scenebuild.connectionPath (cognitive 17) d2renderers/d2scenebuild/connection.go:349— d2scenebuild.connectionPath has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (3 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.
builder.preflight (cognitive 17) d2renderers/d2scenebuild/build.go:282— builder.preflight has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 2, loops 2 (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.
d2svgimport.ImportNodeWithOptions (cognitive 17) d2renderers/d2svgimport/import.go:117— d2svgimport.ImportNodeWithOptions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 15 (16 pts), boolean chains 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.
svgImporter.validateMetadataCardinality (cognitive 17) d2renderers/d2svgimport/boilerplate.go:143— svgImporter.validateMetadataCardinality has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 2 (4 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
svgImporter.validateStyleTree (cognitive 17) d2renderers/d2svgimport/compile.go:159— svgImporter.validateStyleTree has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 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.
svgImporter.validLocalPaintID (cognitive 17) d2renderers/d2svgimport/gradient.go:365— svgImporter.validLocalPaintID has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 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.
svgImporter.classTokens (cognitive 17) d2renderers/d2svgimport/stylesheet.go:264— svgImporter.classTokens has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 1, 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.
fontface.registeredBundledFaceEntry (cognitive 17) d2renderers/internal/fontface/bundled_faces.go:142— fontface.registeredBundledFaceEntry has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 5, loops 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.
BundledFaceSource.SupportsRenderableRune (cognitive 17) d2renderers/internal/fontface/face.go:191— BundledFaceSource.SupportsRenderableRune has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 3). 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.
font.Sfnt2Woff (cognitive 17) lib/font/font.go:82— font.Sfnt2Woff has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (nesting depth added 6). 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.
Resolver.loadHTTP (cognitive 17) lib/imageasset/resolve.go:415— Resolver.loadHTTP has cognitive complexity 17 (threshold 15). Drivers by points: if/else 13 (16 pts), boolean chains 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.
svg.ParseAttributes (cognitive 17) lib/svg/markup.go:81— svg.ParseAttributes has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 2, 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.
Ruler.scaleUnicodeLegacy (cognitive 17) lib/textmeasure/textmeasure.go:450— Ruler.scaleUnicodeLegacy has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (6 pts) (nesting depth added 9). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
xgif.ditherOpaqueRasterWithWorkspace (cognitive 17) lib/xgif/xgif.go:887— xgif.ditherOpaqueRasterWithWorkspace has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (12 pts), loops 3 (4 pts), boolean chains 1 (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.
d2cli.prepareBoardOutputFile (cognitive 16) d2cli/board_output_publish.go:723— d2cli.prepareBoardOutputFile has cognitive complexity 16 (threshold 15). Drivers by points: if/else 14 (16 pts) (nesting depth added 2). Of this number, 9 points are the body's own statements and 7 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.
d2cli.resolveLinks (cognitive 16) d2cli/main.go:778— d2cli.resolveLinks has cognitive complexity 16 (threshold 15). Drivers by points: loops 6 (9 pts), if/else 4 (7 pts) (nesting depth added 6). 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.
printer.interpolationBoxes (cognitive 16) d2format/format.go:129— printer.interpolationBoxes has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 1, 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.
Object.SpacingOpt (cognitive 16) d2graph/d2graph.go:1898— Object.SpacingOpt has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 2 (4 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.
Map.CopyBase (cognitive 16) REDACTED:458— Map.CopyBase has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), boolean chains 3, loops 3, match/switch 1 (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.
EdgeID.resolve (cognitive 16) REDACTED:736— EdgeID.resolve has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 4, loops 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.
gridDiagram.fastLayout (cognitive 16) d2layouts/d2grid/layout.go:735— gridDiagram.fastLayout has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (15 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.
d2talalayout.Layout (cognitive 16) d2layouts/d2talalayout/layout.go:241— d2talalayout.Layout has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 1 (nesting depth added 2). Of this number, 12 points are the body's own statements and 4 belong to 2 function literals 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.
d2talalayout.sameDirectionMetadata (cognitive 16) d2layouts/d2talalayout/result_validate.go:377— d2talalayout.sameDirectionMetadata has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 2, boolean chains 1 (nesting depth added 5). Of this number, 9 points are the body's own statements and 7 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.
graphbounds.fixedOrigin (cognitive 16) d2layouts/d2talalayout/internal/graphbounds/bounds.go:175— graphbounds.fixedOrigin has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 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.
graphjson.serializeTree (cognitive 16) REDACTED:704— graphjson.serializeTree has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (15 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.
grouping.clusterHasLeakyEdgeGuarded (cognitive 16) d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:236— grouping.clusterHasLeakyEdgeGuarded has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 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.
hierarchy.sortAlignmentNodes (cognitive 16) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:375— hierarchy.sortAlignmentNodes has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 4 (nesting depth added 4). Of this number, 8 points are the body's own statements and 8 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.
loops.findLoopPortsForEdge (cognitive 16) d2layouts/d2talalayout/internal/loops/loops.go:187— loops.findLoopPortsForEdge has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (9 pts), boolean chains 4, loops 3 (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.
placement.alignmentDeltas (cognitive 16) d2layouts/d2talalayout/internal/placement/alignment.go:182— placement.alignmentDeltas has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 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.
placement.optimizerMoveNodeAbs (cognitive 16) d2layouts/d2talalayout/internal/placement/optimization_guard.go:684— placement.optimizerMoveNodeAbs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 3, loops 2 (nesting depth added 3). 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 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.
placement.Normalize (cognitive 16) d2layouts/d2talalayout/internal/placement/stages.go:301— placement.Normalize has cognitive complexity 16 (threshold 15). Drivers by points: loops 6 (11 pts), if/else 3 (5 pts) (nesting depth added 7). 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.
placementcost.countEdgeCrossingsExcludingSharedNodes (cognitive 16) d2layouts/d2talalayout/internal/placementcost/graph.go:232— placementcost.countEdgeCrossingsExcludingSharedNodes has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 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.
routing.groupEdgesByClusterPortGuarded (cognitive 16) d2layouts/d2talalayout/internal/routing/coordinator.go:1899— routing.groupEdgesByClusterPortGuarded has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 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.
routing.channelInventoryIsClosed (cognitive 16) d2layouts/d2talalayout/internal/routing/nudge_channels.go:119— routing.channelInventoryIsClosed has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (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.
routing.swapEdgePortsGuarded (cognitive 16) d2layouts/d2talalayout/internal/routing/swap_ports.go:33— routing.swapEdgePortsGuarded has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, 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.
routing.doesNotPassThroughNodesGuarded (cognitive 16) d2layouts/d2talalayout/internal/routing/swap_ports.go:159— routing.doesNotPassThroughNodesGuarded has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 2 (3 pts), boolean chains 2, jumps 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.
routing.alignedPortNodeForBuild (cognitive 16) d2layouts/d2talalayout/internal/routing/tree_routes.go:133— routing.alignedPortNodeForBuild has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 4 (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.
OVG.addCornerNodes (cognitive 16) REDACTED:977— OVG.addCornerNodes has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (13 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.
ovgEdgeRouter.routeLine (cognitive 16) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:303— ovgEdgeRouter.routeLine has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (16 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.
ovgBuildGuard.passesThroughAllowingPorts (cognitive 16) d2layouts/d2talalayout/internal/routing/ovg_resource.go:429— ovgBuildGuard.passesThroughAllowingPorts has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 5, loops 1 (2 pts), match/switch 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.
trees.treeFringeNodes (cognitive 16) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:107— trees.treeFringeNodes has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 2, loops 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.
trees.isIsolatedTreeGuarded (cognitive 16) d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:623— trees.isIsolatedTreeGuarded has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (3 pts), 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.
parser.parseBlockComment (cognitive 16) d2parser/parse.go:635— parser.parseBlockComment has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 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.
d2fonts.AddFontFamily (cognitive 16) d2renderers/d2fonts/d2fonts_common.go:129— d2fonts.AddFontFamily has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (16 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.
d2isometricimg.hierarchyShadowReceivers (cognitive 16) d2renderers/d2isometric/d2isometricimg/ground_receivers.go:71— d2isometricimg.hierarchyShadowReceivers has cognitive complexity 16 (threshold 15). Drivers by points: loops 6 (10 pts), if/else 3 (6 pts) (nesting depth added 7). 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.
d2isometricimg.CaptureFrames (cognitive 16) d2renderers/d2isometric/d2isometricimg/render.go:117— d2isometricimg.CaptureFrames has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 2, loops 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.
d2isometricimg.svgSplitPolygon (cognitive 16) REDACTED:209— d2isometricimg.svgSplitPolygon has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 5, loops 2 (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.
d2isometricimg.svgValidFragment (cognitive 16) REDACTED:249— d2isometricimg.svgValidFragment has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 5). 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 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.
meshBuilder.classicInkRibbon (cognitive 16) d2renderers/d2isometric/d2isometricimg/native_edges.go:543— meshBuilder.classicInkRibbon has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 3, loops 3 (nesting depth added 4). Of this number, 14 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.
meshBuilder.solidPaint (cognitive 16) d2renderers/d2isometric/d2isometricimg/native_solids.go:45— meshBuilder.solidPaint has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 4 (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.
meshBuilder.addDocumentLinks (cognitive 16) d2renderers/d2isometric/d2isometricimg/page.go:246— meshBuilder.addDocumentLinks has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 4, 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.
Raster.paintGround (cognitive 16) d2renderers/d2isometric/d2isometricimg/raster.go:811— Raster.paintGround has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 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.
surfaceIconPainter.resolve (cognitive 16) d2renderers/d2isometric/d2isometricimg/surface_icons.go:213— surfaceIconPainter.resolve has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 2, match/switch 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.
nativeSurfaceSVGWriter.paint (cognitive 16) d2renderers/d2isometric/d2isometricimg/vector_surface_svg.go:280— nativeSurfaceSVGWriter.paint has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (13 pts), match/switch 2, loops 1 (nesting depth added 4). Of this number, 12 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.
retainedVectorValidator.text (cognitive 16) d2renderers/d2raster/vector_validation.go:392— retainedVectorValidator.text has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 2 (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.
d2scenebuild.validateConnectionNumbers (cognitive 16) d2renderers/d2scenebuild/build.go:1162— d2scenebuild.validateConnectionNumbers has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 3 (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.
builder.sketchArrowhead (cognitive 16) d2renderers/d2scenebuild/sketch_connection.go:36— builder.sketchArrowhead has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), 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.
d2sketch.Paths (cognitive 16) d2renderers/d2sketch/sketch.go:293— d2sketch.Paths has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (5 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.
d2svgimport.inspectEmbeddedPNG (cognitive 16) d2renderers/d2svgimport/image.go:464— d2svgimport.inspectEmbeddedPNG has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 2, 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.
svgImporter.ignoredNamespacedAttribute (cognitive 16) d2renderers/d2svgimport/boilerplate.go:203— svgImporter.ignoredNamespacedAttribute has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
d2target.ToArrowhead (cognitive 16) d2target/d2target.go:1133— d2target.ToArrowhead has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 5, match/switch 1 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
d2target.validateRenderConnectionNumbers (cognitive 16) d2target/render_validation.go:308— d2target.validateRenderConnectionNumbers has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 3 (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.
main.main (cognitive 16) e2etests/report/main.go:208— main.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 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.
utf8FontFile.getSymbols (cognitive 16) lib/font/subsetFont.go:474— utf8FontFile.getSymbols has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 1 (2 pts) (nesting depth added 7). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
imageasset.New (cognitive 16) lib/imageasset/imageasset.go:347— imageasset.New has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 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.
imageasset.readBounded (cognitive 16) lib/imageasset/resolve.go:748— imageasset.readBounded 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.
imgbundler.findImageElementsForOptions (cognitive 16) lib/imgbundler/imgbundler.go:254— imgbundler.findImageElementsForOptions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, loops 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.
xgif.animateImages (cognitive 16) lib/xgif/xgif.go:1246— xgif.animateImages has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 2 (nesting depth added 6). Of this number, 10 points are the body's own statements and 6 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.
gifAssembler.appendCenteredFrame (cognitive 16) lib/xgif/encode.go:350— gifAssembler.appendCenteredFrame has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 4, loops 3 (nesting depth added 2). Of this number, 12 points are the body's own statements and 4 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.
D4 · Code Duplication· Near-duplicate member family (3 members, 7 shared lines) · ×1
Near-duplicate member family (3 members, 7 shared lines) d2renderers/d2raster/image.go:182— d2renderers/d2raster/image.go:182-195 | d2renderers/d2svgimport/image.go:325-338 | lib/imageasset/probe.go:379-392 — These 3 members are variants of one another: a block of 7 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
Near-duplicate member pair (315 shared lines) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:129— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:129-504 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:510-1282 — These two members are variants of one another: 315 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (214 shared lines) d2layouts/d2elklayout/layout.go:257— d2layouts/d2elklayout/layout.go:257-682 | d2layouts/d2elklayout/wasm.go:23-252 — These two members are variants of one another: 214 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (172 shared lines) d2layouts/d2talalayout/internal/labeling/placement.go:28— d2layouts/d2talalayout/internal/labeling/placement.go:28-454 | d2layouts/d2talalayout/internal/labeling/placement.go:462-685 — These two members are variants of one another: 172 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (98 shared lines) d2layouts/d2talalayout/internal/routing/slingshot.go:676— d2layouts/d2talalayout/internal/routing/slingshot.go:676-889 | d2layouts/d2talalayout/internal/routing/slingshot.go:900-1189 — These two members are variants of one another: 98 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (70 shared lines) d2oracle/edit.go:2778— d2oracle/edit.go:2778-2970 | d2oracle/edit.go:2972-3161 — These two members are variants of one another: 70 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (62 shared lines) d2oracle/edit.go:124— d2oracle/edit.go:124-284 | d2oracle/edit.go:2500-2642 — These two members are variants of one another: 62 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (55 shared lines) d2renderers/d2svg/d2svg.go:1445— d2renderers/d2svg/d2svg.go:1445-1550 | d2renderers/d2svg/d2svg.go:1552-1686 — These two members are variants of one another: 55 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (39 shared lines) d2renderers/d2svg/class.go:92— d2renderers/d2svg/class.go:92-163 | d2renderers/d2svg/table.go:115-186 — These two members are variants of one another: 39 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (33 shared lines) REDACTED:1593— REDACTED:1593-1683 | REDACTED:1717-1844 — These two members are variants of one another: 33 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (30 shared lines) REDACTED:491— REDACTED:491-709 | REDACTED:724-799 — These two members are variants of one another: 30 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (28 shared lines) d2renderers/d2raster/filter.go:560— d2renderers/d2raster/filter.go:560-651 | d2renderers/d2raster/filter.go:653-761 — These two members are variants of one another: 28 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (23 shared lines) d2renderers/d2raster/gradient.go:723— d2renderers/d2raster/gradient.go:723-787 | d2renderers/d2raster/gradient.go:1022-1090 — These two members are variants of one another: 23 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (21 shared lines) d2renderers/d2raster/filter.go:918— d2renderers/d2raster/filter.go:918-953 | d2renderers/d2raster/filter.go:1079-1119 — These two members are variants of one another: 21 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Edited copy of a member (17 corresponding lines) · ×1
Edited copy of a member (17 corresponding lines) d2renderers/d2raster/gradient.go:581— d2renderers/d2raster/gradient.go:581-618 | d2renderers/d2raster/gradient.go:620-644 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (45 corresponding lines) · ×1
Edited copy of a member (45 corresponding lines) d2parser/parse.go:527— d2parser/parse.go:527-576 | d2parser/parse.go:1663-1726 — These two members are one piece of code written twice and then edited apart: 45 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (15 corresponding lines) · ×1
Edited copy of a member (15 corresponding lines) d2layouts/d2talalayout/internal/placement/compaction.go:113— d2layouts/d2talalayout/internal/placement/compaction.go:113-131 | d2layouts/d2talalayout/internal/placement/compaction.go:145-327 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Members sharing a duplicated core (18 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (18 members, 50+ identical tokens) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:13— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:13-50 | d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:13-50 | d2layouts/d2talalayout/internal/nodeshape/shape_circle.go:11-48 | d2layouts/d2talalayout/internal/nodeshape/shape_cloud.go:13-50 | d2layouts/d2talalayout/internal/nodeshape/shape_cylinder.go:12-48 | d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go:13-50 | d2layouts/d2talalayout/internal/nodeshape/shape_document.go:12-49 | d2layouts/d2talalayout/internal/nodeshape/shape_hexagon.go:12-49 | d2layouts/d2talalayout/internal/nodeshape/shape_image.go:11-38 | d2layouts/d2talalayout/internal/nodeshape/shape_oval.go:12-49 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:15-52 | d2layouts/d2talalayout/internal/nodeshape/shape_page.go:11-48 | d2layouts/d2talalayout/internal/nodeshape/shape_parallelogram.go:12-49 | d2layouts/d2talalayout/internal/nodeshape/shape_person.go:13-50 | d2layouts/d2talalayout/internal/nodeshape/shape_queue.go:12-49 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:13-49 | d2layouts/d2talalayout/internal/nodeshape/shape_step.go:13-50 | d2layouts/d2talalayout/internal/nodeshape/shape_stored_data.go:12-49 — These 18 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 18 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 18 times.
D4 · Code Duplication· Members sharing a duplicated core (12 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (12 members, 50+ identical tokens) d2renderers/d2raster/image.go:585— d2renderers/d2raster/image.go:585-604 | d2renderers/d2raster/image.go:606-625 | d2renderers/d2raster/image.go:627-657 | d2renderers/d2raster/image.go:659-684 | d2renderers/d2raster/image.go:686-711 | d2renderers/d2raster/image.go:713-745 | d2renderers/d2raster/image.go:747-779 | d2renderers/d2raster/image.go:781-814 | d2renderers/d2raster/image.go:816-842 | d2renderers/d2raster/image.go:844-870 | d2renderers/d2raster/image.go:876-904 | d2renderers/d2raster/image.go:906-938 — These 12 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 12 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 12 times.
D4 · Code Duplication· Members sharing a duplicated core (7 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (7 members, 50+ identical tokens) d2layouts/d2talalayout/internal/trees/geometry.go:251— d2layouts/d2talalayout/internal/trees/geometry.go:251-283 | d2layouts/d2talalayout/internal/trees/geometry.go:285-387 | d2layouts/d2talalayout/internal/trees/geometry.go:679-706 | d2layouts/d2talalayout/internal/trees/geometry.go:720-751 | d2layouts/d2talalayout/internal/trees/geometry.go:774-806 | d2layouts/d2talalayout/internal/trees/geometry.go:808-836 | d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:578-621 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (5 members, 50+ identical tokens) d2renderers/d2svgimport/boilerplate.go:63— d2renderers/d2svgimport/boilerplate.go:63-141 | d2renderers/d2svgimport/clip.go:91-111 | d2renderers/d2svgimport/compile.go:54-94 | d2renderers/d2svgimport/gradient.go:243-278 | d2renderers/d2svgimport/stylesheet.go:16-40 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Duplicated block (138 lines × 2) d2layouts/d2elklayout/layout.go:353— d2layouts/d2elklayout/layout.go:353-490 | d2layouts/d2elklayout/wasm.go:113-250 — before extracting anything, compare `d2layouts/d2elklayout/layout.go` and `d2layouts/d2elklayout/wasm.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 214 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2elklayout/layout.go:353` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (72–77 lines × 2) d2layouts/d2talalayout/internal/placementcost/edge_length.go:973— d2layouts/d2talalayout/internal/placementcost/edge_length.go:973-1049 | d2layouts/d2talalayout/internal/placementcost/edge_length.go:1050-1121 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/placementcost/edge_length.go:971` calls `TurnCost` and `d2layouts/d2talalayout/internal/placementcost/edge_length.go:1049` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (71 lines × 2) d2layouts/d2dagrelayout/layout.go:1523— d2layouts/d2dagrelayout/layout.go:1523-1593 | d2layouts/d2dagrelayout/layout.go:1594-1664 — 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 (65 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:383— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:383-447 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:864-928 — 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 (55–63 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:441— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:441-495 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:943-1005 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:441` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (54 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:245— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:245-298 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:639-692 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:245` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (52 lines × 2) d2ast/d2ast.go:839— d2ast/d2ast.go:839-890 | d2ast/d2ast.go:931-982 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2ast/d2ast.go:839` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2ast/d2ast.go:984` calls `Unbox` and `d2ast/d2ast.go:892` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (51 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:330— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:330-380 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:811-861 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:330` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (45–46 lines × 2) d2layouts/d2talalayout/internal/routing/slingshot.go:797— d2layouts/d2talalayout/internal/routing/slingshot.go:797-841 | d2layouts/d2talalayout/internal/routing/slingshot.go:1112-1157 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/slingshot.go:797` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (35–42 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:260— d2layouts/d2talalayout/internal/labeling/placement.go:260-301 | d2layouts/d2talalayout/internal/labeling/placement.go:327-361 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:260` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (38–39 lines × 2) d2renderers/d2svgimport/style.go:102— d2renderers/d2svgimport/style.go:102-139 | d2renderers/d2svgimport/stylesheet.go:187-225 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svgimport/style.go:102` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (37 lines × 2) d2compiler/compile.go:613— d2compiler/compile.go:613-649 | REDACTED:201-237 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (26–36 lines × 14) d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:14— d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:14-49 | d2layouts/d2talalayout/internal/nodeshape/shape_circle.go:12-47 | d2layouts/d2talalayout/internal/nodeshape/shape_cloud.go:14-49 | d2layouts/d2talalayout/internal/nodeshape/shape_cylinder.go:13-47 | d2layouts/d2talalayout/internal/nodeshape/shape_document.go:13-48 | d2layouts/d2talalayout/internal/nodeshape/shape_hexagon.go:13-48 | d2layouts/d2talalayout/internal/nodeshape/shape_image.go:12-37 | d2layouts/d2talalayout/internal/nodeshape/shape_oval.go:13-48 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:16-51 | d2layouts/d2talalayout/internal/nodeshape/shape_page.go:12-47 | d2layouts/d2talalayout/internal/nodeshape/shape_parallelogram.go:13-48 | d2layouts/d2talalayout/internal/nodeshape/shape_queue.go:13-48 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:14-48 | d2layouts/d2talalayout/internal/nodeshape/shape_stored_data.go:13-48 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_callout.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_cloud.go` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (26–36 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:1125— d2layouts/d2talalayout/internal/labeling/placement.go:1125-1160 | d2layouts/d2talalayout/internal/quality/labels.go:485-510 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:1125` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (35 lines × 3) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:14— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:14-48 | d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go:14-48 | d2layouts/d2talalayout/internal/nodeshape/shape_step.go:14-48 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 117 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (31–35 lines × 3) d2renderers/d2svg/d2svg.go:192— d2renderers/d2svg/d2svg.go:192-222 | d2renderers/d2svg/d2svg.go:281-315 | d2renderers/d2svg/d2svg.go:3043-3073 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2renderers/d2svg/d2svg.go:190` calls `NewRuler` and `d2renderers/d2svg/d2svg.go:279` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (35 lines × 2) d2compiler/compile.go:454— d2compiler/compile.go:454-488 | d2compiler/compile.go:1248-1282 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2compiler/compile.go:454` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (28–35 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/node.go:1433— d2layouts/d2talalayout/internal/layoutgraph/node.go:1433-1467 | d2layouts/d2talalayout/internal/routing/geometry.go:19-46 — before extracting anything, compare `d2layouts/d2talalayout/internal/layoutgraph/node.go` and `d2layouts/d2talalayout/internal/routing/geometry.go` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/node.go:1433` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (31–34 lines × 2) d2renderers/d2svg/d2svg.go:1520— d2renderers/d2svg/d2svg.go:1520-1550 | d2renderers/d2svg/d2svg.go:1653-1686 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/d2svg.go:1520` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (29–32 lines × 2) d2renderers/d2raster/gradient.go:478— d2renderers/d2raster/gradient.go:478-509 | d2renderers/d2raster/gradient.go:529-557 — 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 (32 lines × 2) d2renderers/d2svg/d2svg.go:1250— d2renderers/d2svg/d2svg.go:1250-1281 | d2renderers/d2svg/d2svg.go:2129-2160 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/d2svg.go:1250` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (31 lines × 4) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:19— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:19-49 | d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go:19-49 | d2layouts/d2talalayout/internal/nodeshape/shape_person.go:19-49 | d2layouts/d2talalayout/internal/nodeshape/shape_step.go:19-49 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 117 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:19` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (31 lines × 2) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:220— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:220-250 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:598-628 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:220` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (25–30 lines × 2) d2layouts/d2talalayout/internal/routing/coordinator.go:976— d2layouts/d2talalayout/internal/routing/coordinator.go:976-1005 | d2layouts/d2talalayout/internal/routing/coordinator.go:1030-1054 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/coordinator.go:976` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2layouts/d2talalayout/internal/routing/coordinator.go:972` calls `Inf` and `d2layouts/d2talalayout/internal/routing/coordinator.go:1028` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15–28 lines × 2) d2layouts/d2talalayout/internal/placementcost/edge_length.go:630— d2layouts/d2talalayout/internal/placementcost/edge_length.go:630-657 | d2layouts/d2talalayout/internal/placementcost/edge_length.go:705-719 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placementcost/edge_length.go:630` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21–28 lines × 2) d2parser/parse.go:483— d2parser/parse.go:483-510 | d2parser/parse.go:1634-1654 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2parser/parse.go:483` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24–27 lines × 2) d2layouts/d2grid/layout.go:384— d2layouts/d2grid/layout.go:384-410 | d2layouts/d2grid/layout.go:477-500 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2grid/layout.go:384` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (26–27 lines × 2) d2oracle/edit.go:156— d2oracle/edit.go:156-182 | d2oracle/edit.go:2537-2562 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2oracle/edit.go:156` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (25–26 lines × 2) d2renderers/d2svg/d2svg.go:230— d2renderers/d2svg/d2svg.go:230-254 | d2renderers/d2svg/d2svg.go:3077-3102 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svg/d2svg.go:230` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24–25 lines × 2) d2layouts/d2talalayout/internal/packing/binpack.go:344— d2layouts/d2talalayout/internal/packing/binpack.go:344-368 | d2layouts/d2talalayout/internal/packing/binpack.go:788-811 — 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 (23–25 lines × 2) lib/textmeasure/textmeasure.go:284— lib/textmeasure/textmeasure.go:284-308 | lib/textmeasure/textmeasure.go:467-489 — 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 (12–24 lines × 2) d2layouts/d2talalayout/internal/placementcost/edge_length.go:671— d2layouts/d2talalayout/internal/placementcost/edge_length.go:671-694 | d2layouts/d2talalayout/internal/placementcost/edge_length.go:721-732 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placementcost/edge_length.go:671` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–24 lines × 2) d2layouts/d2talalayout/internal/placementcost/edge_length.go:752— d2layouts/d2talalayout/internal/placementcost/edge_length.go:752-775 | d2layouts/d2talalayout/internal/placementcost/edge_length.go:818-832 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placementcost/edge_length.go:752` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20–23 lines × 2) d2ir/merge.go:35— d2ir/merge.go:35-54 | d2ir/merge.go:83-105 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2ir/merge.go:35` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21–22 lines × 2) REDACTED:1530— REDACTED:1530-1550 | REDACTED:1566-1587 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1530` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (21 lines × 18) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:19— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:19-50 | d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:27-50 | d2layouts/d2talalayout/internal/nodeshape/shape_circle.go:19-48 | d2layouts/d2talalayout/internal/nodeshape/shape_cloud.go:22-50 | d2layouts/d2talalayout/internal/nodeshape/shape_cylinder.go:20-48 | d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go:19-50 | d2layouts/d2talalayout/internal/nodeshape/shape_document.go:21-49 | d2layouts/d2talalayout/internal/nodeshape/shape_hexagon.go:20-49 | d2layouts/d2talalayout/internal/nodeshape/shape_image.go:18-38 | d2layouts/d2talalayout/internal/nodeshape/shape_oval.go:20-49 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:29-52 | d2layouts/d2talalayout/internal/nodeshape/shape_page.go:19-48 | d2layouts/d2talalayout/internal/nodeshape/shape_parallelogram.go:22-49 | d2layouts/d2talalayout/internal/nodeshape/shape_person.go:19-50 | d2layouts/d2talalayout/internal/nodeshape/shape_queue.go:22-49 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:27-49 | d2layouts/d2talalayout/internal/nodeshape/shape_step.go:19-50 | d2layouts/d2talalayout/internal/nodeshape/shape_stored_data.go:22-49 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 117 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:19` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (21 lines × 3) d2layouts/d2talalayout/internal/routing/ovg_resource.go:462— d2layouts/d2talalayout/internal/routing/ovg_resource.go:462-482 | d2layouts/d2talalayout/internal/routing/route_search_guard.go:267-287 | d2layouts/d2talalayout/internal/routing/tunnel.go:71-91 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/ovg_resource.go:462` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–21 lines × 2) d2layouts/d2talalayout/internal/placementcost/edge_length.go:786— d2layouts/d2talalayout/internal/placementcost/edge_length.go:786-806 | d2layouts/d2talalayout/internal/placementcost/edge_length.go:834-845 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placementcost/edge_length.go:786` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18–20 lines × 2) d2layouts/d2talalayout/internal/hierarchy/discovery.go:656— d2layouts/d2talalayout/internal/hierarchy/discovery.go:656-675 | d2layouts/d2talalayout/internal/hierarchy/discovery.go:680-697 — 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 (19–20 lines × 2) d2oracle/edit.go:2834— d2oracle/edit.go:2834-2853 | d2oracle/edit.go:3041-3059 — 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–19 lines × 2) d2renderers/d2raster/effects.go:1399— d2renderers/d2raster/effects.go:1399-1417 | d2renderers/d2raster/effects.go:1520-1537 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1399` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–18 lines × 3) d2renderers/d2svg/d2svg.go:1522— d2renderers/d2svg/d2svg.go:1522-1537 | d2renderers/d2svg/d2svg.go:1604-1618 | d2renderers/d2svg/d2svg.go:1655-1672 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (17–18 lines × 2) d2layouts/d2talalayout/internal/routing/swap_ports.go:593— d2layouts/d2talalayout/internal/routing/swap_ports.go:593-610 | d2layouts/d2talalayout/internal/routing/swap_ports.go:613-629 — 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–17 lines × 2) d2layouts/d2talalayout/internal/packing/combine.go:73— d2layouts/d2talalayout/internal/packing/combine.go:73-88 | d2layouts/d2talalayout/internal/routing/snapshot.go:58-74 — before extracting anything, compare `d2layouts/d2talalayout/internal/packing/combine.go` and `d2layouts/d2talalayout/internal/routing/snapshot.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/packing/combine.go:73` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–17 lines × 2) d2layouts/d2talalayout/result_validate.go:103— d2layouts/d2talalayout/result_validate.go:103-119 | d2layouts/d2talalayout/result_validate.go:265-278 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/result_validate.go:103` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 4) d2layouts/d2talalayout/internal/proximity/nears.go:206— d2layouts/d2talalayout/internal/proximity/nears.go:206-221 | d2layouts/d2talalayout/internal/routing/ovg_resource.go:463-478 | d2layouts/d2talalayout/internal/routing/route_search_guard.go:268-283 | d2layouts/d2talalayout/internal/routing/tunnel.go:72-87 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/proximity/nears.go:206` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 3) d2layouts/d2talalayout/internal/labeling/placement.go:89— d2layouts/d2talalayout/internal/labeling/placement.go:89-104 | d2layouts/d2talalayout/internal/labeling/placement.go:533-548 | d2layouts/d2talalayout/internal/labeling/placement.go:555-570 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/placement.go:89` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–16 lines × 2) d2renderers/d2isometric/d2isometricimg/solid_contacts.go:160— d2renderers/d2isometric/d2isometricimg/solid_contacts.go:160-172 | d2renderers/d2isometric/d2isometricimg/solid_contacts.go:226-241 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2isometric/d2isometricimg/solid_contacts.go:160` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 11) d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:225— d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:225-239 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:241-255 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:257-271 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:273-287 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:289-303 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:603-617 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:619-633 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:635-649 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:651-665 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:667-681 | d2layouts/d2talalayout/internal/layoutgraph/topology_preflight.go:683-697 — all 11 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (15 lines × 4) d2oracle/edit.go:93— d2oracle/edit.go:93-107 | d2oracle/edit.go:140-154 | d2oracle/edit.go:953-967 | d2oracle/edit.go:1770-1784 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12–15 lines × 4) d2renderers/d2sketch/sketch.go:69— d2renderers/d2sketch/sketch.go:69-80 | d2renderers/d2sketch/sketch.go:116-130 | d2renderers/d2sketch/sketch.go:179-190 | d2renderers/d2sketch/sketch.go:232-246 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2sketch/sketch.go:69` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–15 lines × 3) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:236— d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:236-250 | d2layouts/d2talalayout/internal/packing/combine.go:70-80 | d2layouts/d2talalayout/internal/routing/snapshot.go:55-66 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (15 lines × 3) d2layouts/d2talalayout/internal/routing/slingshot.go:728— d2layouts/d2talalayout/internal/routing/slingshot.go:728-742 | d2layouts/d2talalayout/internal/routing/slingshot.go:958-972 | d2layouts/d2talalayout/internal/routing/slingshot.go:999-1013 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/slingshot.go:728` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–15 lines × 2) d2renderers/d2scenebuild/appendix.go:289— d2renderers/d2scenebuild/appendix.go:289-301 | d2renderers/d2svg/d2svg.go:2279-2293 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (14 lines × 3) d2layouts/d2talalayout/internal/placement/transpose.go:98— d2layouts/d2talalayout/internal/placement/transpose.go:98-111 | d2layouts/d2talalayout/internal/placement/transpose.go:154-167 | d2layouts/d2talalayout/internal/placement/transpose.go:173-186 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/placement/transpose.go:98` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 3) d2oracle/edit.go:2829— d2oracle/edit.go:2829-2841 | d2oracle/edit.go:3021-3032 | d2oracle/edit.go:3036-3047 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (4–13 lines × 4) d2layouts/d2talalayout/internal/labeling/guard.go:508— d2layouts/d2talalayout/internal/labeling/guard.go:508-511 | d2layouts/d2talalayout/internal/labeling/guard.go:558-570 | d2layouts/d2talalayout/internal/quality/labels.go:513-525 | d2layouts/d2talalayout/internal/routing/route_stage_guard.go:559-562 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/labeling/guard.go:508` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `d2layouts/d2talalayout/internal/labeling/guard.go:571` calls `min` and `d2layouts/d2talalayout/internal/labeling/guard.go:511` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12–13 lines × 2) d2layouts/d2talalayout/internal/routing/coordinator.go:1699— d2layouts/d2talalayout/internal/routing/coordinator.go:1699-1711 | d2layouts/d2talalayout/internal/routing/standalone_route_guard.go:368-379 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/routing/coordinator.go:1699` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–13 lines × 2) d2renderers/d2svgimport/boilerplate.go:174— d2renderers/d2svgimport/boilerplate.go:174-183 | d2renderers/d2svgimport/import.go:583-595 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svgimport/boilerplate.go:174` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–12 lines × 2) d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:435— d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:435-446 | d2layouts/d2talalayout/internal/routing/ovg_edge_router.go:448-457 — 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 (11 lines × 7) d2renderers/d2sketch/sketch.go:77— d2renderers/d2sketch/sketch.go:77-87 | d2renderers/d2sketch/sketch.go:127-137 | d2renderers/d2sketch/sketch.go:144-154 | d2renderers/d2sketch/sketch.go:187-197 | d2renderers/d2sketch/sketch.go:243-253 | d2renderers/d2sketch/sketch.go:260-270 | d2renderers/d2sketch/sketch.go:304-314 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11 lines × 4) d2renderers/d2raster/gradient.go:1102— d2renderers/d2raster/gradient.go:1102-1112 | d2renderers/d2raster/gradient.go:1151-1161 | d2renderers/d2raster/gradient.go:1195-1205 | d2renderers/d2raster/gradient.go:1279-1289 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:1102` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 3) d2renderers/d2scenebuild/labels.go:136— d2renderers/d2scenebuild/labels.go:136-145 | d2renderers/d2scenebuild/markdown.go:79-88 | d2renderers/d2svg/d2svg.go:2054-2064 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/labels.go:136` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2renderers/d2scenebuild/markdown.go:78` calls `targetGeometry` and `d2renderers/d2svg/d2svg.go:2053` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (4–11 lines × 3) d2renderers/d2ascii/asciishapes/helpers.go:30— d2renderers/d2ascii/asciishapes/helpers.go:30-40 | d2renderers/d2ascii/asciishapes/page.go:28-38 | d2renderers/d2ascii/asciishapes/rectangle.go:45-48 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2ascii/asciishapes/helpers.go:30` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–11 lines × 2) d2renderers/d2isometric/d2isometricimg/native_edges.go:571— d2renderers/d2isometric/d2isometricimg/native_edges.go:571-581 | d2renderers/d2isometric/d2isometricimg/native_ink_joins.go:75-81 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (9–11 lines × 2) d2renderers/d2scenebuild/build.go:1097— d2renderers/d2scenebuild/build.go:1097-1105 | d2renderers/d2scenebuild/markdown.go:373-383 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2scenebuild/markdown.go:373` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 3) REDACTED:2419— REDACTED:2419-2428 | REDACTED:2430-2439 | REDACTED:2440-2448 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:2419` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:2419` calls `ScalarString` and `REDACTED:2440` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–10 lines × 2) d2layouts/d2talalayout/internal/labeling/placement.go:1209— d2layouts/d2talalayout/internal/labeling/placement.go:1209-1218 | d2layouts/d2talalayout/internal/labeling/placement.go:1238-1245 — 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 (9 lines × 5) d2renderers/d2raster/gradient.go:699— d2renderers/d2raster/gradient.go:699-707 | d2renderers/d2raster/gradient.go:814-822 | d2renderers/d2raster/gradient.go:858-866 | d2renderers/d2raster/gradient.go:915-923 | d2renderers/d2raster/gradient.go:942-950 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:699` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 4) REDACTED:512— REDACTED:512-520 | REDACTED:522-530 | REDACTED:531-539 | REDACTED:541-549 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:531` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:539` calls `NewPoint` and `REDACTED:520` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 6) d2layouts/d2talalayout/internal/trees/geometry.go:252— d2layouts/d2talalayout/internal/trees/geometry.go:252-259 | d2layouts/d2talalayout/internal/trees/geometry.go:680-687 | d2layouts/d2talalayout/internal/trees/geometry.go:721-728 | d2layouts/d2talalayout/internal/trees/geometry.go:775-782 | d2layouts/d2talalayout/internal/trees/geometry.go:809-816 | d2layouts/d2talalayout/internal/trees/preprocess_helpers.go:582-589 — there are 6 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/trees/geometry.go:252` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (2–8 lines × 3) d2renderers/d2raster/gradient.go:771— d2renderers/d2raster/gradient.go:771-778 | d2renderers/d2raster/gradient.go:1071-1078 | d2renderers/d2raster/pattern.go:286-287 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/gradient.go:771` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (2–8 lines × 4) REDACTED:521— REDACTED:521-528 | REDACTED:593-600 | REDACTED:631-632 | REDACTED:700-701 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:521` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–8 lines × 2) lib/xgif/xgif.go:953— lib/xgif/xgif.go:953-959 | lib/xgif/xgif.go:1019-1026 — 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 (7 lines × 10) d2renderers/d2raster/image.go:636— d2renderers/d2raster/image.go:636-642 | d2renderers/d2raster/image.go:667-673 | d2renderers/d2raster/image.go:694-700 | d2renderers/d2raster/image.go:721-727 | d2renderers/d2raster/image.go:756-762 | d2renderers/d2raster/image.go:790-796 | d2renderers/d2raster/image.go:825-831 | d2renderers/d2raster/image.go:853-859 | d2renderers/d2raster/image.go:885-891 | d2renderers/d2raster/image.go:915-921 — all 10 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:636` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 9) d2renderers/d2raster/effects.go:1397— d2renderers/d2raster/effects.go:1397-1403 | d2renderers/d2raster/effects.go:1468-1474 | d2renderers/d2raster/effects.go:1518-1524 | d2renderers/d2raster/effects.go:1692-1698 | d2renderers/d2raster/effects.go:1772-1778 | d2renderers/d2raster/effects.go:1850-1856 | lib/xgif/xgif.go:1380-1386 | lib/xgif/xgif.go:1404-1410 | lib/xgif/xgif.go:1433-1439 — there are 9 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 9 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/effects.go:1397` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2renderers/d2raster/effects.go:1516` calls `compositeBlendLayerOpaquePrefix`, `Bounds`, `Intersect` and `d2renderers/d2raster/effects.go:1849` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 5) d2renderers/d2svgimport/boilerplate.go:128— d2renderers/d2svgimport/boilerplate.go:128-134 | d2renderers/d2svgimport/clip.go:92-98 | d2renderers/d2svgimport/compile.go:67-73 | d2renderers/d2svgimport/gradient.go:244-250 | d2renderers/d2svgimport/stylesheet.go:17-23 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2svgimport/boilerplate.go:128` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2renderers/d2svgimport/clip.go:91` calls `compileClipPathResources` and `d2renderers/d2svgimport/boilerplate.go:127` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–7 lines × 4) d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:377— d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:377-382 | d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:384-389 | d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:391-396 | d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:398-404 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/hierarchy/brandes_kopf.go:398` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (3–7 lines × 4) d2renderers/d2ascii/asciishapes/helpers.go:25— d2renderers/d2ascii/asciishapes/helpers.go:25-31 | d2renderers/d2ascii/asciishapes/package.go:16-22 | d2renderers/d2ascii/asciishapes/page.go:23-29 | d2renderers/d2ascii/asciishapes/rectangle.go:31-33 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2ascii/asciishapes/helpers.go:25` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `d2renderers/d2ascii/asciishapes/package.go:14` calls `Sprintf`, `TopRightCorner`, `BottomLeftCorner` and `d2renderers/d2ascii/asciishapes/helpers.go:24` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–7 lines × 2) d2renderers/d2svg/d2svg.go:1082— d2renderers/d2svg/d2svg.go:1082-1088 | d2renderers/d2svg/d2svg.go:1712-1717 — 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 (3–6 lines × 4) d2renderers/d2raster/filter.go:593— d2renderers/d2raster/filter.go:593-598 | d2renderers/d2raster/filter.go:636-641 | d2renderers/d2raster/filter.go:693-695 | d2renderers/d2raster/filter.go:746-748 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:593` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 10) d2renderers/d2raster/image.go:586— d2renderers/d2raster/image.go:586-590 | d2renderers/d2raster/image.go:607-611 | d2renderers/d2raster/image.go:660-664 | d2renderers/d2raster/image.go:687-691 | d2renderers/d2raster/image.go:714-718 | d2renderers/d2raster/image.go:748-752 | d2renderers/d2raster/image.go:782-786 | d2renderers/d2raster/image.go:817-821 | d2renderers/d2raster/image.go:845-849 | d2renderers/d2raster/image.go:877-881 — all 10 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/image.go:586` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 6) d2renderers/d2raster/filter.go:601— d2renderers/d2raster/filter.go:601-605 | d2renderers/d2raster/filter.go:644-648 | d2renderers/d2raster/filter.go:673-677 | d2renderers/d2raster/filter.go:701-705 | d2renderers/d2raster/filter.go:726-730 | d2renderers/d2raster/filter.go:754-758 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/filter.go:601` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (3–5 lines × 3) d2renderers/d2raster/geometry.go:520— d2renderers/d2raster/geometry.go:520-524 | d2renderers/d2raster/gradient.go:1372-1376 | d2renderers/d2raster/image.go:497-499 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `d2renderers/d2raster/geometry.go:520` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29 lines × 2) d2renderers/d2scenebuild/build.go:1132— d2renderers/d2scenebuild/build.go:1132-1160 | d2target/render_validation.go:278-306 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (34 lines × 2) d2renderers/d2scenebuild/build.go:1162— d2renderers/d2scenebuild/build.go:1162-1195 | d2target/render_validation.go:308-341 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (18 lines × 8) d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:117— d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go:117-134 | d2layouts/d2talalayout/internal/nodeshape/shape_callout.go:130-147 | d2layouts/d2talalayout/internal/nodeshape/shape_cloud.go:114-131 | d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go:111-128 | d2layouts/d2talalayout/internal/nodeshape/shape_package.go:148-166 | d2layouts/d2talalayout/internal/nodeshape/shape_person.go:117-134 | d2layouts/d2talalayout/internal/nodeshape/shape_square.go:118-135 | d2layouts/d2talalayout/internal/nodeshape/shape_step.go:123-140 — before extracting anything, compare `d2layouts/d2talalayout/internal/nodeshape/shape_c4person.go` and `d2layouts/d2talalayout/internal/nodeshape/shape_diamond.go` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 117 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 18) lib/shape/shape_c4_person.go:23— lib/shape/shape_c4_person.go:23-32 | lib/shape/shape_callout.go:20-29 | lib/shape/shape_circle.go:14-23 | lib/shape/shape_cylinder.go:19-28 | lib/shape/shape_diamond.go:15-24 | lib/shape/shape_document.go:22-31 | lib/shape/shape_hexagon.go:15-24 | lib/shape/shape_image.go:12-21 | lib/shape/shape_oval.go:16-25 | lib/shape/shape_package.go:24-33 | lib/shape/shape_page.go:21-30 | lib/shape/shape_parallelogram.go:17-26 | lib/shape/shape_person.go:15-24 | lib/shape/shape_queue.go:15-24 | lib/shape/shape_real_square.go:14-23 | lib/shape/shape_square.go:12-21 | lib/shape/shape_step.go:15-24 | lib/shape/shape_stored_data.go:17-26 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 18 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lib/shape/shape_real_square.go:25` calls `AspectRatio1` and `lib/shape/shape_image.go:23` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 5) d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:427— d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:427-440 | d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:447-460 | d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:467-480 | d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:507-520 | d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:527-540 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go:427` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Coverage not measured — JavaScript/TypeScript suite — Coverage NOT MEASURED: the JavaScript/TypeScript half could not be measured — the bun:test suite in d2js/js/ ran and not one test passed (bun test v1.3.14 (0d9b296a)), so the coverage would describe 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.
Swallowed exception (empty catch) d2js/d2wasm/api.go:32— 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.
Duplicated predicate d2renderers/d2isometric/d2isometricimg/route_bridges.go:88— `!bridgeFinite(p.X) || !bridgeFinite(p.Y) || !bridgeFinite(p.Z)` appears character-identically in 2 files — d2renderers/d2isometric/d2isometricimg/route_bridges.go, d2renderers/d2isometric/d2isometricimg/route_lanes.go. 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 d2renderers/d2isometric/d2isometricimg/native_edges.go:482— `!captionFinite(dash, gap) || dash <= 0 || gap <= 0` appears character-identically in 2 files — d2renderers/d2isometric/d2isometricimg/native_edges.go, d2renderers/d2isometric/d2isometricimg/sequence_routes.go. 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 d2renderers/d2raster/raster.go:1633— `!finite(box.X) || !finite(box.Y) || !finite(box.Width) || !finite(box.Height)` appears character-identically in 2 files — d2renderers/d2raster/raster.go, d2renderers/d2scene/primitive.go. 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 d2renderers/d2raster/pattern.go:60— `!finite(pattern.Tile.X+pattern.Tile.Width) || !finite(pattern.Tile.Y+pattern.Tile.Height)` appears character-identically in 2 files — d2renderers/d2raster/pattern.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2raster/raster.go:1235— `!finite(rect.RadiusX) || !finite(rect.RadiusY) || rect.RadiusX < 0 || rect.RadiusY < 0` appears character-identically in 2 files — d2renderers/d2raster/raster.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2raster/raster.go:1482— `!finite(stroke.Width) || stroke.Width < 0 || !finite(stroke.MiterLimit) || !finite(stroke.DashOffset)` appears character-identically in 2 files — d2renderers/d2raster/raster.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2raster/raster.go:1255— `!finitePoint(ellipse.Center) || !finite(ellipse.RadiusX) || !finite(ellipse.RadiusY) || ellipse.RadiusX < 0 || ellipse.RadiusY < 0` appears character-identically in 3 files — d2renderers/d2raster/raster.go, d2renderers/d2raster/vector_validation.go, d2renderers/d2scene/primitive.go. 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 d2renderers/d2raster/text.go:482— `!finitePoint(glyph.Position) || !finite(glyph.Advance) || !glyph.Ink.IsFinite()` appears character-identically in 2 files — d2renderers/d2raster/text.go, d2renderers/d2scene/primitive.go. 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 d2renderers/d2raster/gradient.go:201— `!finitePoint(gradient.Center) || !finitePoint(gradient.Focal) || !finite(gradient.Radius) || !finite(gradient.FocalRadius)` appears character-identically in 2 files — d2renderers/d2raster/gradient.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2raster/gradient.go:122— `!finitePoint(gradient.Start) || !finitePoint(gradient.End)` appears character-identically in 2 files — d2renderers/d2raster/gradient.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2raster/text.go:184— `!finitePoint(text.Origin) || !finite(text.Font.Size) || text.Font.Size <= 0 || text.Font.Size > float64(math.MaxInt32)/64` appears character-identically in 2 files — d2renderers/d2raster/text.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2svgimport/gradient.go:377— `!isASCIIAlpha(character) && character != '_'` appears character-identically in 2 files — d2renderers/d2svgimport/gradient.go, d2renderers/d2svgimport/stylesheet.go. 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 d2layouts/d2talalayout/internal/placement/moves.go:70— `!math.IsInf(leastDistance, 1) && geo.PrecisionCompare(edgeLength-symmetryCost, leastDistance, geo.PRECISION) == 1` appears character-identically in 2 files — d2layouts/d2talalayout/internal/placement/moves.go, REDACTED. 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 d2layouts/d2talalayout/internal/layoutgraph/transaction.go:489— `!math.IsNaN(value) && !math.IsInf(value, 0)` appears character-identically in 9 files — d2layouts/d2talalayout/internal/layoutgraph/transaction.go, d2layouts/d2talalayout/internal/packing/routed_container.go, d2layouts/d2talalayout/internal/placement/optimizer_spatial_index.go, d2layouts/d2talalayout/internal/quality/score.go. 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 d2renderers/d2raster/raster.go:1082— `!node.Mask.Transform.IsFinite() || node.Mask.Type > d2scene.MaskLuminance || node.Mask.Root == nil` appears character-identically in 2 files — d2renderers/d2raster/raster.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2raster/raster.go:993— `!node.Transform.IsFinite() || !finite(node.Opacity) || node.Opacity < 0 || node.Opacity > 1` appears character-identically in 2 files — d2renderers/d2raster/raster.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2svgimport/gradient.go:328— `!strings.HasPrefix(value, "url(#") || !strings.HasSuffix(value, ")")` appears character-identically in 2 files — d2renderers/d2svgimport/gradient.go, lib/svg/markup.go. 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 d2renderers/d2svgimport/style.go:154— `!validCSSPropertyName(property) || value == ""` appears character-identically in 2 files — d2renderers/d2svgimport/style.go, d2renderers/d2svgimport/stylesheet.go. 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 d2layouts/d2talalayout/internal/placementcost/edge_length.go:224— `(edgeAbduction.CurrentFrom == adjacentNode) && (edgeAbduction.CurrentTo == node)` appears character-identically in 2 files — d2layouts/d2talalayout/internal/placementcost/edge_length.go, d2layouts/d2talalayout/internal/placementcost/symmetry.go. 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 d2layouts/d2talalayout/internal/placementcost/edge_length.go:214— `(edgeAbduction.CurrentFrom == node) && (edgeAbduction.CurrentTo == adjacentNode)` appears character-identically in 2 files — d2layouts/d2talalayout/internal/placementcost/edge_length.go, d2layouts/d2talalayout/internal/placementcost/symmetry.go. 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 REDACTED:1024— `(node.TopLeft.X != currentNodeX) || (node.TopLeft.Y != currentNodeY)` appears character-identically in 2 files — REDACTED, REDACTED. 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 d2renderers/d2raster/text.go:345— `(text.Underline || text.Strike) && advance > 0` appears character-identically in 2 files — d2renderers/d2raster/text.go, d2renderers/d2raster/vector_validation.go. 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 d2layouts/d2talalayout/internal/grouping/cluster_discovery.go:112— `abduction == nil || abduction.Edge == nil` appears character-identically in 2 files — d2layouts/d2talalayout/internal/grouping/cluster_discovery.go, d2layouts/d2talalayout/internal/grouping/lifecycle.go. 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 d2renderers/d2raster/image.go:220— `animation.fillColor != nil || animation.strokeColor != nil || animation.dashOffset != nil` appears character-identically in 2 files — d2renderers/d2raster/image.go, d2renderers/d2raster/vector_validation.go. 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 d2renderers/d2scenebuild/connection.go:624— `arrowhead == d2target.CfMany || arrowhead == d2target.CfManyRequired` appears character-identically in 2 files — d2renderers/d2scenebuild/connection.go, d2renderers/d2svg/d2svg.go. 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.
README/code drift README.md:12— README.md links to `./CHANGELOG.md`, but `CHANGELOG.md` does not exist. 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 d2renderers/d2fonts/README.md:7— d2renderers/d2fonts/README.md names `./ttf/Helvetica-Bold.ttf`, but no file or folder `ttf/Helvetica-Bold.ttf` exists. 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 d2renderers/d2fonts/README.md:8— d2renderers/d2fonts/README.md names `./ttf/Helvetica-Italic.ttf`, but no file or folder `ttf/Helvetica-Italic.ttf` exists. 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 d2renderers/d2fonts/README.md:9— d2renderers/d2fonts/README.md names `./ttf/Helvetica-Regular.ttf`, but no file or folder `ttf/Helvetica-Regular.ttf` exists. 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 d2renderers/d2fonts/README.md:12— d2renderers/d2fonts/README.md names `./ttf/Helvetica-Bold.txt`, but no file or folder `ttf/Helvetica-Bold.txt` exists. 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 d2renderers/d2fonts/README.md:13— d2renderers/d2fonts/README.md names `./ttf/Helvetica-Italic.txt`, but no file or folder `ttf/Helvetica-Italic.txt` exists. 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 d2renderers/d2fonts/README.md:14— d2renderers/d2fonts/README.md names `./ttf/Helvetica-Regular.txt`, but no file or folder `ttf/Helvetica-Regular.txt` exists. 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.
Silent fallback default on error d2oracle/get.go:221— `GetID` turns a non-nil `err` into `return ""` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or return it. 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 `if` or in the doc comment, and the row stops firing.
Silent fallback default on error d2renderers/d2isometric/d2isometricimg/native_structured.go:84— `nativeStructuredTextRow` turns a non-nil `err` into `return -1` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or return it. 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 `if` or in the doc comment, and the row stops firing.
Silent fallback default on error internal/testutil/pptx.go:370— `getExpectedPptxFileCount` turns a non-nil `err` into `return -1` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or return it. 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 `if` or in the doc comment, and the row stops firing.
Silent fallback default on error lib/version/version.go:10— `OnlyNumbers` turns a non-nil `err` into `return ""` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or return it. 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 `if` or in the doc comment, and the row stops firing.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 70 significant file(s) lose their only recent owner: d2oracle/edit.go, lib/textmeasure/markdown_svg.go, REDACTED, d2renderers/d2raster/effects.go, d2renderers/d2raster/raster.go, REDACTED, lib/xgif/xgif.go, d2renderers/d2raster/gradient.go (+62 more). Pair on, review, or document these before any departure.
No ADRs found — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`.
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)` (175533 LoC, 554 module-visible types across 111 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.
D28 · Secrets (history)· Rotate the exposed credentials · ×1
D34 · Knowledge Freshness· Orphaned files with no living knowledge · ×1
Orphaned files with no living knowledge — 1 of 394 analysed file(s) have no living knowledge left — their last meaningful change has decayed away, so if one breaks, no one currently understands it (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; 394 of the 596 production source files in this repository met that bar). None is large enough to earn a read-through of its own, so this row stands in for the per-file rows rather than raising one each — most significant first: d2graph/layout.go. Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
Orphaned file d2graph/layout.go:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
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.
No SAST — No static application security testing detected. For this repository's stack, add gosec / govulncheck (or golangci-lint) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 35793 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
Hand-rolled JSON/XML parsing via regex d2renderers/d2svg/d2svg.go:2842— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Go code already uses a real parser in the same package; use it here too.
Outdated: github.com/PuerkitoBio/goquery — `github.com/PuerkitoBio/goquery` is required at v1.12.0 in REDACTED, but v1.13.0 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get github.com/PuerkitoBio/goquery@v1.13.0 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: github.com/andybalholm/brotli — `github.com/andybalholm/brotli` is required at v1.2.2 in REDACTED, but v1.2.7 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get github.com/andybalholm/brotli@v1.2.7 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: github.com/go-text/typesetting — `github.com/go-text/typesetting` is required at v0.3.4 in REDACTED, but v0.3.5 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get github.com/go-text/typesetting@v0.3.5 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: github.com/mazznoer/csscolorparser — `github.com/mazznoer/csscolorparser` is required at v0.1.8 in REDACTED, but v0.2.0 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get github.com/mazznoer/csscolorparser@v0.2.0 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: github.com/stretchr/testify — `github.com/stretchr/testify` is required at v1.11.1 in REDACTED, but v1.12.1 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get github.com/stretchr/testify@v1.12.1 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: github.com/yuin/goldmark — `github.com/yuin/goldmark` is required at v1.8.5 in REDACTED, but v1.8.6 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get github.com/yuin/goldmark@v1.8.6 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: golang.org/x/image — `golang.org/x/image` is required at v0.45.0 in REDACTED, but v0.47.0 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get golang.org/x/image@v0.47.0 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: golang.org/x/net — `golang.org/x/net` is required at v0.57.0 in REDACTED, but v0.61.0 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get golang.org/x/net@v0.61.0 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: golang.org/x/sync — `golang.org/x/sync` is required at v0.22.0 in REDACTED, but v0.24.0 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get golang.org/x/sync@v0.24.0 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: golang.org/x/text — `golang.org/x/text` is required at v0.41.0 in REDACTED, but v0.43.0 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get golang.org/x/text@v0.43.0 && go mod tidy` and commit the updated REDACTED and go.sum.
Outdated: golang.org/x/tools — `golang.org/x/tools` is required at v0.48.0 in REDACTED, but v0.52.0 is the module's current release — so this build is missing every fix published since, including any security fix. Run `go get golang.org/x/tools@v0.52.0 && go mod tidy` and commit the updated REDACTED and go.sum.
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.
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 6 file(s) — `d2js/js/src/platform.browser.js`, `d2layouts/d2talalayout/adapter.go`, `d2layouts/d2talalayout/internal/layoutgraph/transaction_snapshot.go`, `d2layouts/d2talalayout/internal/packing/combine.go`, `d2layouts/d2talalayout/internal/routing/snapshot.go`, … (+1 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
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 01a16bde-c6a3-7634-9a01-2b3d489463c0 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 2 · Warnings: 2884 · Recommendations: 54 · Info: 11 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 24-10-2026 @ 03:05 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.