Public report of xai-org/grok-build, published 26 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 report Measured 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, 26 October 2026, 03:37 UTC · Survey ID cd_e516132bff6944b3bc17dd14267e32b8

xai-org/grok-build

Measured 26 October 2026, 03:30 UTC, at code version 2bdd1d6

No regression since the last survey Knowledge freshness: not measured

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.

Knowledge freshness is not measured: History too condensed to judge knowledge freshness.

CAI score 55out of 100 Adequate
CriticalWeakAdequateStrongExemplary
No change 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 very large codebase: 1,359,257 lines of product code in 107 projects, tests not counted · Estimated rebuild effort: about 17.1 person-years · Weakest lens: Production Readiness, 40

Findings by how serious they are

5 critical 3108 serious 216 minor

13 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
26 October 2026, 03:30 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 ▸

71of 71 dimensions measured by tools.
3207of 3329 findings point to an exact file and line, so you can open each one in the code. The other 122 concern the repository as a whole, such as missing documentation.
71dimensions across 9 lenses, read from 1,359,257 lines of product code in 107 projects.
Chapters

Executive summary

xai-org/grok-build falls short of our standard for production, in part because we found no working pipeline that builds or tests changes to the code. It scores 55 out of 100 and is rated Adequate, and four of its five critical findings are security problems.

Production Readiness, at 40, is the weakest lens and counts most in the score. The best first step is adding an automated build and test pipeline, worth about 7 points. Moving the keys out of the code comes next, worth about 5 points. Raising Production Readiness to 70 would lift the score to about 66.

Two weaknesses in the code could be used by an attacker. One known security hole in a package the code depends on can be used by attackers. Fixing the weaknesses the scanner points to and updating the vulnerable packages would close both risks. Saving the change and the message together would take care of the place where data is saved and a message sent separately.

The product code is 1,359,257 lines, about €2,500,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 for The 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.
Production Readiness 40 · counts for 45%Security and Compliance 57 · counts for 25%Code Health 73 · counts for 14%Performance 75 · counts for 8%Maturity 76 · counts for 4%Event-Driven 80 · counts for 2%Architecture 97 · counts for 1%Domain Modelling 100 · counts for 1%Event Sourcing 100 · counts for 0%

If Production Readiness rose from 40 to 70, the lowest score rated Strong, the score would rise from 55 to about 66.

Code composition: what the lines of code are
Product code 74%Tests 26%
New since the last survey: 15 findings

These 15 critical or serious findings weren't in the previous survey, on 12 October 2026.

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: 1 finding

This critical or serious finding was in the previous survey, on 12 October 2026, and is gone from this one.

  • Outbound HTTP resilience · Outbound HTTP without resilience crates/codegen/xai-grok-extra-ca/src/lib.rs
Rebuild cost: about €2,500,000 · Estimate
Cost to rebuild€830,000 to €4,200,000, for 13,804 to 43,794 hours of work, about 17.1 person-years for 10 to 33 engineers
Difficulty of the problemHigh, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor×0.8 at a score of 55. 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.
SizeVery large: 1,359,257 lines of product code
What it is notNot a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.

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
Add a CI workflow that builds and runs the test suite on every push/PR.
Raises the score by about 7 points · Medium effort · CI/CD gates
2
Load cryptographic key and salt material from configuration, an environment variable or a secrets manager rather than fixing it in the source, and fail fast at startup when it is absent — a default that silently works is the one that reaches production.
Rotate anything already committed: it must be treated as disclosed. Salts should be generated per password and stored with the hash, never shared across installations.
Raises the score by about 5 points · Medium effort · Web-Security Posture
3
Give every client a whole-request bound: `reqwest::Client::builder().timeout(Duration::from_secs(10))` (never `reqwest::get` or `Client::new()`, which have none), ureq's `timeout_global`, or wrap the call in `tokio::time::timeout`; add retry with back-off (`reqwest-retry`'s `RetryTransientMiddleware`, `backoff`) around dependencies that fail.
Raises the score by about 4 points · Medium effort · Outbound HTTP resilience

Diagnosis: what the measurements show together

Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.

Where the investment is most exposed · Value at risk
This code would cost about €2,500,000 to build again, about 17.1 person-years of work. Its weakest lens is Production Readiness, at 40 (Weak). Production Readiness is about whether the product is ready to run in production and to change without breaking. Because the weakest lens counts most in the score, work on Production Readiness also moves the score most.
Based on: the rebuild estimate · the Production Readiness grade · how much each lens counts
What to do: Start with the Production Readiness actions in Top priorities.
If you do one thing first · First action
Add a CI workflow that builds and runs the test suite on every push/PR. Of all the actions in this report, it raises the score most for the work it takes: about 7 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 6.4 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 4% to 9% on every change. The history of the code shows how much it changes: about 3,144,553 lines over the last 90 days, which is about 12,752,909 lines a year. At that pace, the extra work comes to an estimated 1240.2 to 7441.1 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, never less than 2% to 5% and never more than 40% to 60% in all; 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 — module dependency graph

Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways, which only happens where the projects form a dependency cycle. A graph without cycles has none.

arch dagre_rust dagre_rust graphlib_rust graphlib_rust dagre_rust->graphlib_rust prod-mc-cli-chat-proxy-types prod-mc-cli-chat-proxy-types xai-chat-state xai-chat-state xai-grok-compaction xai-grok-compaction xai-chat-state->xai-grok-compaction xai-grok-sampling-types xai-grok-sampling-types xai-chat-state->xai-grok-sampling-types xai-codebase-graph xai-codebase-graph xai-grok-paths xai-grok-paths xai-codebase-graph->xai-grok-paths xai-fast-worktree xai-fast-worktree xai-file-utils xai-file-utils xai-file-utils->prod-mc-cli-chat-proxy-types xai-grok-agent xai-grok-agent xai-grok-hooks xai-grok-hooks xai-grok-agent->xai-grok-hooks xai-grok-agent->xai-grok-sampling-types xai-grok-tools xai-grok-tools xai-grok-agent->xai-grok-tools xai-grok-sandbox xai-grok-sandbox xai-grok-hooks->xai-grok-sandbox xai-grok-pager xai-grok-pager xai-grok-pager->xai-chat-state xai-grok-pager->xai-fast-worktree xai-grok-pager->xai-file-utils xai-grok-pager->xai-grok-hooks xai-grok-pager->xai-grok-sampling-types xai-grok-pager->xai-grok-sandbox xai-grok-shell xai-grok-shell xai-grok-pager->xai-grok-shell xai-grok-pager-bin xai-grok-pager-bin xai-grok-pager-bin->xai-grok-pager xai-grok-pager-minimal xai-grok-pager-minimal xai-grok-pager-bin->xai-grok-pager-minimal xai-grok-pager-bin->xai-grok-sandbox xai-grok-pager-bin->xai-grok-shell xai-grok-pager-minimal->xai-grok-pager xai-grok-pager-minimal->xai-grok-shell xai-grok-sampling-types->xai-grok-compaction xai-grok-shell->prod-mc-cli-chat-proxy-types xai-grok-shell->xai-chat-state xai-grok-shell->xai-codebase-graph xai-grok-shell->xai-fast-worktree xai-grok-shell->xai-file-utils xai-grok-shell->xai-grok-agent xai-grok-shell->xai-grok-compaction xai-grok-shell->xai-grok-hooks xai-grok-shell->xai-grok-paths xai-grok-shell->xai-grok-sampling-types xai-grok-shell->xai-grok-sandbox xai-grok-subagent-resolution xai-grok-subagent-resolution xai-grok-shell->xai-grok-subagent-resolution xai-grok-shell->xai-grok-tools xai-grok-subagent-resolution->xai-grok-agent xai-grok-subagent-resolution->xai-grok-sampling-types xai-grok-subagent-resolution->xai-grok-tools xai-grok-tools->xai-file-utils xai-grok-tools->xai-grok-sandbox xai-grok-workspace xai-grok-workspace xai-grok-workspace->xai-codebase-graph xai-grok-workspace->xai-fast-worktree xai-grok-workspace->xai-file-utils xai-grok-workspace->xai-grok-agent xai-grok-workspace->xai-grok-hooks xai-grok-workspace->xai-grok-paths xai-grok-workspace->xai-grok-sandbox xai-grok-workspace->xai-grok-tools __more__ +87 more projects

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.

2753 modules, with 6568 dependencies between them. 7 loops run through 637 of the modules, marked above the diagonal.

The table shows the 40 modules with the most connections; 2713 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.
uses →1 xai_grok_dashboard_store.types2 xai_grok_gboom.game3 xai_grok_login.model4 xai_grok_pager_render.theme.tokyonight5 xai_grok_shell.session.tool_index6 xai_mixpanel7 xai_tool_protocol.capabilities8 xai_tool_protocol.ids9 xai_tool_runtime.context10 xai_grok_config.managed_text.format11 xai_grok_config.remote_settings12 xai_grok_login.manager13 xai_grok_pager.slash.command14 xai_grok_sampling_types.types15 xai_grok_tools.types.output16 xai_grok_tools.types.requirements17 xai_tool_types.types18 xai_grok_markdown.mermaid19 xai_grok_sampling_types.conversation20 xai_grok_shell.agent.config21 xai_grok_tools.types.tool22 dagre_rust.layout.util23 xai_codebase_graph.types.range24 xai_grok_pager_render.appearance.config25 xai_grok_shell.extensions.notification26 xai_grok_pager.app.agent27 xai_grok_pager.headless.reducer28 xai_grok_pager.scrollback.types29 xai_grok_mcp.servers30 xai_grok_pager.app.actions31 xai_grok_pager.scrollback.block32 xai_grok_shell.session.persistence33 xai_grok_tools.registry.types34 xai_grok_pager.app.app_view35 xai_grok_shell.session.acp_session36 xai_grok_workspace.handle37 xai_grok_pager.app.agent_view38 xai_grok_shell.session.acp_session_impl.spawn39 xai_grok_shell.agent.subagent40 xai_grok_shell.agent.mvp_agent
1 xai_grok_dashboard_store.types
2 xai_grok_gboom.game
3 xai_grok_login.model
4 xai_grok_pager_render.theme.tokyonight
5 xai_grok_shell.session.tool_index
6 xai_mixpanel
7 xai_tool_protocol.capabilities
8 xai_tool_protocol.ids
9 xai_tool_runtime.context
10 xai_grok_config.managed_text.format1
11 xai_grok_config.remote_settings1
12 xai_grok_login.manager2
13 xai_grok_pager.slash.command1
14 xai_grok_sampling_types.types11
15 xai_grok_tools.types.output2
16 xai_grok_tools.types.requirements1
17 xai_tool_types.types2
18 xai_grok_markdown.mermaid1
19 xai_grok_sampling_types.conversation7
20 xai_grok_shell.agent.config1218128
21 xai_grok_tools.types.tool11
22 dagre_rust.layout.util1
23 xai_codebase_graph.types.range1
24 xai_grok_pager_render.appearance.config1
25 xai_grok_shell.extensions.notification16
26 xai_grok_pager.app.agent111311
27 xai_grok_pager.headless.reducer111
28 xai_grok_pager.scrollback.types1231
29 xai_grok_mcp.servers11112124
30 xai_grok_pager.app.actions211
31 xai_grok_pager.scrollback.block14116
32 xai_grok_shell.session.persistence333141
33 xai_grok_tools.registry.types11162631
34 xai_grok_pager.app.app_view12132421
35 xai_grok_shell.session.acp_session1111252646171
36 xai_grok_workspace.handle231113
37 xai_grok_pager.app.agent_view135126113
38 xai_grok_shell.session.acp_session_impl.spawn1111112121
39 xai_grok_shell.agent.subagent111223111211
40 xai_grok_shell.agent.mvp_agent3124233322114113
Uses a module listed above itPart of a loopThe module itself
1 xai_grok_dashboard_store.types2 xai_grok_gboom.game3 xai_grok_login.model4 xai_grok_pager_render.theme.tokyonight5 xai_grok_shell.session.tool_index6 xai_mixpanel7 xai_tool_protocol.capabilities8 xai_tool_protocol.ids9 xai_tool_runtime.context10 xai_grok_config.managed_text.format11 xai_grok_config.remote_settings12 xai_grok_login.manager13 xai_grok_pager.slash.command14 xai_grok_sampling_types.types15 xai_grok_tools.types.output16 xai_grok_tools.types.requirements17 xai_tool_types.types18 xai_grok_markdown.mermaid19 xai_grok_sampling_types.conversation20 xai_grok_shell.agent.config21 xai_grok_tools.types.tool22 dagre_rust.layout.util23 xai_codebase_graph.types.range24 xai_grok_pager_render.appearance.config25 xai_grok_shell.extensions.notification26 xai_grok_pager.app.agent27 xai_grok_pager.headless.reducer28 xai_grok_pager.scrollback.types29 xai_grok_mcp.servers30 xai_grok_pager.app.actions31 xai_grok_pager.scrollback.block32 xai_grok_shell.session.persistence33 xai_grok_tools.registry.types34 xai_grok_pager.app.app_view35 xai_grok_shell.session.acp_session36 xai_grok_workspace.handle37 xai_grok_pager.app.agent_view38 xai_grok_shell.session.acp_session_impl.spawn39 xai_grok_shell.agent.subagent40 xai_grok_shell.agent.mvp_agentxai_grok_dashboard_store.types1xai_grok_gboom.game2xai_grok_login.model3xai_grok_pager_render.theme.tokyonight4xai_grok_shell.session.tool_index5xai_mixpanel6xai_tool_protocol.capabilities7xai_tool_protocol.ids8xai_tool_runtime.context9xai_grok_config.managed_text.format10xai_grok_config.remote_settings11xai_grok_login.manager12xai_grok_pager.slash.command13xai_grok_sampling_types.types14xai_grok_tools.types.output15xai_grok_tools.types.requirements16xai_tool_types.types17xai_grok_markdown.mermaid18xai_grok_sampling_types.conversation19xai_grok_shell.agent.config20xai_grok_tools.types.tool21dagre_rust.layout.util22xai_codebase_graph.types.range23xai_grok_pager_render.appearance.config24xai_grok_shell.extensions.notification25xai_grok_pager.app.agent26xai_grok_pager.headless.reducer27xai_grok_pager.scrollback.types28xai_grok_mcp.servers29xai_grok_pager.app.actions30xai_grok_pager.scrollback.block31xai_grok_shell.session.persistence32xai_grok_tools.registry.types33xai_grok_pager.app.app_view34xai_grok_shell.session.acp_session35xai_grok_workspace.handle36xai_grok_pager.app.agent_view37xai_grok_shell.session.acp_session_impl.spawn38xai_grok_shell.agent.subagent39xai_grok_shell.agent.mvp_agent401121112121712181281111116111311111123111112124211141163331411116263112132421111125264617123111313512611311111121211112231112113124233322114113+2713 more modules (most-connected shown)

At a glance — Code Health · 73% · Adequate · gated by D2 ·

At a glance — Architecture · 97% · Exemplary ·

At a glance — Maturity · 76% · Strong ·

At a glance — Readiness · 40% · Weak · gated by P1, P7 ·

At a glance — Security · 57% · Adequate · gated by D30, S1 ·

At a glance — Domain Modelling · 100% · Exemplary ·

At a glance — Event-Driven · 80% · Strong ·

At a glance — Event Sourcing · 100% · Exemplary ·

At a glance — Performance · 75% · Strong ·

Security & Compliance — OWASP Top-10 mapping

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 categoryFindingsSeverity
A03:2025 — Software Supply Chain Failures41High / Critical
A05:2025 — Injection4High / Critical

Roadmap

Establish a CI workflow that builds and tests every push to ensure immediate feedback, while integrating static analysis tools as a required gate to prevent regressions. Strengthen security by moving cryptographic keys to configuration or secrets managers, generating per-password salts, and enforcing timeouts with retries on all outbound HTTP calls. Finally, stamp a version in the build manifest to ensure all releases are traceable and auditable.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Add a CI workflow that builds and runs the test suite on every push/PR.+7.3 ptsMediumCI/CD gates
Load cryptographic key and salt material from configuration, an environment variable or a secrets manager rather than fixing it in the source, and fail fast at startup when it is absent — a default that silently works is the one that reaches production. Rotate anything already committed: it must be treated as disclosed. Salts should be generated per password and stored with the hash, never shared across installations.+4.6 ptsMediumWeb-Security Posture
Give every client a whole-request bound: `reqwest::Client::builder().timeout(Duration::from_secs(10))` (never `reqwest::get` or `Client::new()`, which have none), ureq's `timeout_global`, or wrap the call in `tokio::time::timeout`; add retry with back-off (`reqwest-retry`'s `RetryTransientMiddleware`, `backoff`) around dependencies that fail.+3.6 ptsMediumOutbound HTTP resilience
Resolve the 1 End-of-life runtime finding(s) in Platform End-of-Life — start with rust-toolchain.toml.+1.7 ptsLowPlatform End-of-Life
Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED.+0.8 ptsLowStatic Analysis (SAST)
Your ecosystem's static analyzer is declared as a dependency but is not wired into CI — run it as a required step on push/PR (e.g. `composer phpstan` / `mix sobelow` / `bundle exec brakeman` / the spotbugs Gradle task / `sbt scalafixAll --check` / `golangci-lint run` / `rebar3 lint`) so a regression fails the build instead of relying on someone running it locally.+1.8 ptsMediumSecurity & performance tooling
Stamp a version in your build/package manifest (e.g. csproj <Version>, package.json, pyproject.toml, Cargo.toml, or a VERSION file) or tag releases with semver so builds and releases are traceable.+1.8 ptsMediumRelease Hygiene
Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2).+0.8 ptsLowStatic Analysis (SAST)

File quality

Per-file score 0–10 — a quality signature. Of 787 files carrying findings, judged against the Production bar: 0% slop · 65% mixed · 35% near-clean.

FileScoreBandWorst signal
REDACTED1.7SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED4.9MixedStatic Analysis (SAST): Medium: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): Medium: REDACTED
crates/codegen/xai-grok-pager/src/app/app_view.rs5.5MixedCode Duplication: Duplicated block (12 lines × 2)
REDACTED5.8MixedStatic Analysis (SAST): High: REDACTED
crates/codegen/xai-grok-shell/src/session/signals.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-pager/src/app/mod.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-shell/src/session/acp_session_impl/sampler_turn.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-shell/src/session/acp_conversion.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-pager/src/app/agent_view/panes.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-shell/src/inspect/mod.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-pager/src/app/acp_handler/settings.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-hunk-tracker/src/actor/mod.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-pager/src/app/acp_handler/queue.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-shell/src/extensions/mcp.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-tools/src/registry/types.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-workspace/src/permission/prompter.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs6.0MixedExplicit Debt: TodoComment
crates/codegen/xai-grok-login/src/manager/refresh_chain.rs6.0MixedExplicit Debt: TodoComment

How the grades work

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 — 5

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 — 3108

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 — 216

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 13

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. 71 of 71 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); none rely on LLM judgement. Overall confidence is 0.8 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.

Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.

What we checked — 71 dimensions across the health lenses
D1D2D3D4D5D6D9D12D13D14D15D17D19D20D23D26D28D29D30D35D37D43D44AX10AX3AX4AX5AX8AX9C2DM1DM2DM4DM5ED4ES1ES2M1M2M3M4P1P10P2P3P6P7PF1PF3S1X1X12X13X14X15X16X17X18X19X21X22X23X24X25X26X27X28X29X3X30X4

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
  1. 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, 3207 of 3329 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.)
  2. 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.
  3. 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.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Watchdog duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivySecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3✓ deterministic
LLM (sampled · advisory)Documentation quality, ADR conformance, naming — sampled over a bounded sample; advisory, never a deterministic measurement—◐ LLM · sampled · advisory

Every finding is locatable in findings.md. Run 01a17642-5a8d-75e2-84ea-5a68e8c28c22.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

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.

  • D8 Code Coverage — 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. Coverage NOT MEASURED: test source is present (.rs) but the built-in coverage collector has no runner for this repository's ecosystem — so this suite was never executed by it. Not scored — this is a gap in the analyzer's language coverage, not a defect in the repo. To have real coverage read, produce a coverage report in a standard format (lcov — `cargo install cargo-llvm-cov`, then `cargo llvm-cov --lcov --output-path lcov.info`) 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. You can widen what we reach: optional: produce a coverage report in a standard format (lcov — `cargo install cargo-llvm-cov`, then `cargo llvm-cov --lcov --output-path lcov.info`) 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 — then the real number is read on the next scan.
  • 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 source is present (.rs) and this repository declares a Cargo test suite (repository root, 2285 test files), but it was not re-run: no test result was produced. Not scored — this is a gap in the analyzer's language coverage, not a finding about this repository.
  • D15 Churn × Complexity Hotspots — 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. A hotspot's complexity is meant to be the worst body its churn actually touched. For crates/common/xai-tool-protocol/src/methods.rs that could not be established — the complexity reader for the file reports no body extents, or the history carries no per-line attribution — so the row quotes the file's worst body, which the counted changes may never have touched. The churn count is unaffected.
  • D16 Bus Factor — 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. Single-contributor repository — bus factor is not applicable (0 contributor(s) across 51 commit(s) sampled, automation and bot accounts excluded). Concentration needs a team to concentrate: with one contributor there is nobody to spread the knowledge to, so there is nothing here for the owner to act on.
  • D19 Documentation 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. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
  • D21 Naming 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. D21's deterministic naming rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
  • 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's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
  • D24 Comment Value — 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's reader does not cover the language this repository's product is written in, so it had nothing of the product to read. That is a gap in this analyzer's language reach — not a finding about this repository.
  • 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.
  • D34 Knowledge Freshness — git history too condensed for a reliable signal — The history looks squashed or freshly imported, so per-file ownership reflects those commits rather than real maintenance. This dimension is reported as a low-confidence advisory and is not scored.
  • AX6 Interface segregation — 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 is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing 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.
  • 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 ToolchainServer (crates/codegen/xai-grok-shell). the service did not build — `cargo build --locked --bin 'chat-history-downgrade'` exited 1: info: syncing channel updates for 1.94.0-x86_64-unknown-linux-gnu error: could not download file from 'https://static.rust-lang.org/dist/channel-rust-1.94.0.toml.sha256' to '/usr/local/rustup/tmp/s0uw…; runtime evidence skipped (launch chosen because 'axum' dependency in crates/codegen/xai-grok-shell/Cargo.toml, binary 'chat-history-downgrade').
  • 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 Python, Rust 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 Python, Rust 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.
  • M4 Documentation accuracy — 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. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9). Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
  • X4 Structured logging — 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. 540 further occurrence(s) are not listed individually; the score already reflects all 580.
  • 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, Rust 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.
  • X7 Silent fallback defaults — 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. 12 further occurrence(s) are not listed individually; the score already reflects all 52.

Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.

Limitations & what we did not check

Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.

Per-dimension blind spots

For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.

  • D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
  • D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
  • D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
  • 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.
  • D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
  • 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.
  • 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 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
  • 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.
  • 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 publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
  • 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.
  • D23 Boundary Type-Coupling: Boundary leakage is detected from type references across detected contexts — leaks that flow through primitives, serialization or shared infrastructure may not surface as a typed reference.
  • 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.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
  • D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a Dockerfile (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
  • 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.
  • AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
  • DM4 Rich vs anemic domain model: Behaviour is detected as state mutation inside a method body — a method that enforces an invariant by validating-and-throwing without mutating reads as a query, and mutation delegated through an interface the scan can't resolve isn't credited; entities with zero public properties still drop out of the population. It detects that state changes, not whether the rule is correct.
  • 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.
  • 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.

Dimensions

D1 · Cyclomatic Complexity4.3 / 10Weak✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 4.3 / 10 · rule-coverage 100% · ceiling Prevented

588 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was AgentView::draw at 511. A further 71 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 xai_grok_markdown::latex::symbols::symbol at 249 — they are counted neither in the figure above nor in this dimension's score. 37 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: crates/codegen/xai-grok-markdown/src/latex/symbols.rs (xai_grok_markdown::latex::symbols::symbol at 249), crates/common/xai-tool-protocol/src/methods.rs (Method::from_wire_str at 49), crates/codegen/xai-grok-workspace-types/src/error.rs (IoKind::from at 39), crates/codegen/xai-grok-tools/src/tool_taxonomy.rs (ToolKind::presentation_name at 37), crates/codegen/xai-grok-pager/src/views/settings_modal/state.rs (xai_grok_pager::views::settings_modal::state::action_for_bool at 32), and 32 more not listed here. 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.

xai_grok_pager::app::dispatch::router::dispatch_inner (cyclomatic 458) · ×153crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:165
xai_grok_shell::session::acp_session_impl::run_loop::run_session (cyclomatic 250) · ×53crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:354
AgentView::draw (cyclomatic 511) · ×39crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:562
SessionActor::handle_turn_input_inner (cyclomatic 124) · ×35crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:503
xai_grok_workspace::permission::manager::spawn_permission_manager_with_pin (cyclomatic 140) · ×21crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs:438

+ 129 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 6 bodies over 240 down to 240 or less in Cyclomatic Complexity — start with AgentView::draw (cyclomatic 511), xai_grok_pager::app::dispatch::router::dispatch_inner (cyclomatic 458), xai_grok_pager::app::effects::execute (cyclomatic 342). — 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 6 together lifts Cyclomatic Complexity from 4.3 to about 5.1/10, projected with the scoring formula itself and assuming each lands exactly at 240; a cleaner split scores higher.
  2. Stand up a CI pipeline, then gate Cyclomatic Complexity in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. 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.

D2 · Cognitive Complexity2.0 / 10Critical✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 2.0 / 10 · rule-coverage 100% · ceiling Prevented

1115 method(s) exceeded the cognitive complexity threshold of 15; the worst was AgentView::draw at 1121.

xai_grok_pager::app::event_loop::run (cognitive 556) · ×254crates/codegen/xai-grok-pager/src/app/event_loop.rs:1034
xai_grok_shell::session::acp_session_impl::run_loop::run_session (cognitive 519) · ×100crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:354
AgentView::draw (cognitive 1121) · ×55crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:562
xai_grok_tools::mcp_elicitation::validate::validate_field (cognitive 56) · ×47crates/codegen/xai-grok-tools/src/mcp_elicitation/validate.rs:62
SessionActor::process_conversation_turn_inner (cognitive 219) · ×45crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:2615

+ 214 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 16 bodies over 240 down to 240 or less in Cognitive Complexity — start with AgentView::draw (cognitive 1121), xai_grok_pager::app::event_loop::run (cognitive 556), AgentView::handle_mouse (cognitive 526). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 16 together lifts Cognitive Complexity from 2.0 to about 3.7/10, projected with the scoring formula itself and assuming each lands exactly at 240; a cleaner split scores higher.
  2. Stand up a CI pipeline, then gate Cognitive Complexity in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. 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.

D3 · God Classes10.0 / 10Stronggated by 27 serious findings✓ 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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

27 god class(es) detected.

FileTooLong: src/connection.rs · ×7crates/common/xai-computer-hub-sdk/src/connection.rs
FunctionTooLong: xai_computer_hub_sdk::connection::run_writer · ×6crates/common/xai-computer-hub-sdk/src/connection.rs:1533
TooManyFields: SessionSignalsUpdate · ×5prod/mc/cli-chat-proxy-types/src/feedback_types.rs:833
MethodTooLong: ToolServer.run · ×3crates/common/xai-computer-hub-sdk/src/server.rs:1532
TooManyMethods: ToolHarness · ×3crates/common/xai-computer-hub-sdk/src/harness.rs:601

+ 2 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 7 FileTooLong finding(s) in God Classes — start with connection.rs, server.rs, harness.rs. — One of this dimension's main actionable groups (7 warning-level).
  2. Resolve the 6 FunctionTooLong finding(s) in God Classes — start with connection.rs (2), bot_tools.rs, fit.rs. — One of this dimension's main actionable groups (6 warning-level).
  3. Resolve the 5 TooManyFields finding(s) in God Classes — start with feedback_types.rs (4), connection.rs. — One of this dimension's main actionable groups (5 warning-level).
  4. Stand up a CI pipeline, then gate God Classes in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. 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.

D4 · Code Duplication9.7 / 10Stronggated by 886 serious findings✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 9.7 / 10 · rule-coverage 100% · ceiling Verified

853 duplicated block group(s) detected. A further 33 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 22 of the 886 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.

Duplicated block (9 lines × 2) · ×72crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:67
Duplicated block (8 lines × 2) · ×67crates/codegen/xai-codebase-graph/src/navigation.rs:223
Duplicated block (6 lines × 2) · ×58crates/codegen/xai-acp-lib/src/gateway.rs:171
Duplicated block (11 lines × 2) · ×51crates/codegen/xai-crash-handler/src/handler.rs:462
Duplicated block (5 lines × 2) · ×48crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:16

+ 155 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 72 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with mod.rs (11), client.rs (7), graph.rs (3). — One of this dimension's main actionable groups (72 warning-level).
  2. Resolve the 67 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with mod.rs (7), render.rs (3), fork.rs (3). — One of this dimension's main actionable groups (67 warning-level).
  3. Resolve the 58 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with mod.rs (7), state.rs (3), graph.rs (2). — One of this dimension's main actionable groups (58 warning-level).
  4. Stand up a CI pipeline, then gate Code Duplication in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. 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.

D5 · Coupling8.2 / 10Strong✓ Tool-verified

What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.

Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.

Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 8.2 / 10 · rule-coverage 100% · ceiling Prevented

107 production modules (Cargo+npm), 0 dependency cycle(s), 2 unstable depended-on module(s). Read from the build's own module declarations; 22 module(s) off the main sequence, with abstractness counted on 94 of the 107 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).

Off the main sequence: prod-mc-cli-chat-proxy-types · ×22
Unstable project xai-grok-pager
Unstable project xai-grok-shell

What to do

  1. Resolve the 22 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (22 warning-level).
  2. Resolve the 1 Unstable project xai-grok-pager finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
  3. Resolve the 1 Unstable project xai-grok-shell finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
  4. Stand up a CI pipeline, then gate Coupling in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.

D6 · Cohesion (LCOM4)9.8 / 10Stronggated by 1 serious finding✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Verified

1 of 57 classes have LCOM4 above 3.

Low cohesion: ToolDescription (LCOM4 4)crates/common/xai-tool-types/src/types.rs:10

What to do

  1. Resolve the 1 Low cohesion finding(s) in Cohesion (LCOM4) — start with types.rs. — One of this dimension's main actionable groups (1 warning-level).
  2. Stand up a CI pipeline, then gate Cohesion (LCOM4) in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. 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.

D9 · Test Distribution9.8 / 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.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Documented

35757 test methods: 34255 unit, 1086 integration, 0 BDD, 416 e2e. The Rust suite contributes 35757 `#[test]` function(s) across 2285 file(s) declaring at least one; its unit/integration split is Cargo's own — 357 of those file(s) are integration-test targets under a crate's tests/ directory, and the rest are #[test] functions compiled into the crate they test.

✓ On the Gold path — maintain.

Detailed fixes: d9_recommendation.md.

D12 · Dependency Hygiene8.0 8.0 / 10Strong✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 8.0 / 10 · rule-coverage 100% · ceiling Verified

90 outdated, 0 yanked direct Cargo dependencies. 228 of 229 direct crates were graded against crates.io (0 not published there, 1 not resolved by a committed REDACTED). Only DIRECT edges are graded: a transitive crate cannot be moved past what its parent's requirement admits, so reporting one would be advice its owner cannot take. A newer release is reported only where this repository's OWN requirement already admits it, so the remedy is `cargo update` and never a manifest edit — which means a release outside the declared range is deliberately NOT charged, because a written-down constraint is a decision rather than a defect. Note that a bare requirement is a CARET, and for a 0.x crate its ceiling is the minor. Whether any crate is UNMAINTAINED is not graded — crates.io publishes no maintenance status, and release age does not stand in for one. Known CVEs in this dependency graph are D30's question, read from REDACTED there.

Outdated: anstyle · ×90

What to do

  1. Stand up a CI pipeline, then gate Dependency Hygiene in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. 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.

D13 · Secret Scanning10.0 / 10Exemplary○ Nothing flagged

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

Secret scan ran and found no leaked secrets.

✓ On the Gold path — maintain.

Detailed fixes: d13_recommendation.md.

D14 · License Compliance10.0 / 10Exemplary○ Nothing flagged

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 of 1186 shipped crate(s) use a banned license. Licences were resolved from crates.io over the crates a consumer compiles — this repository's REDACTED closed over its manifests' `[dependencies]` and `[build-dependencies]`. Crates it asks for ONLY under `[dev-dependencies]` are excluded: they are not compiled by anything that depends on this repository. A further 4 crate(s) in the closure resolve from git, a path or a private registry and publish no licence this pass can read; they are outside this verdict. This repository publishes itself under Apache-2.0, which is its own choice and is not judged here.

✓ On the Gold path — maintain.

Detailed fixes: d14_recommendation.md.

D15 · Churn × Complexity Hotspots9.1 / 10Stronggated by 311 serious findings✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 9.1 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: crates/codegen/xai-grok-pager/src/app/agent_view/render.rs (34×511=17374); crates/codegen/xai-grok-pager/src/app/dispatch/router.rs (27×458=12366); crates/codegen/xai-grok-pager/src/app/effects/mod.rs (36×342=12312)

Hotspot: crates/codegen/xai-grok-pager/src/app/agent_view/render.rs · ×311crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:562

What to do

  1. Resolve the 311 Hotspot finding(s) in Churn × Complexity Hotspots — start with mod.rs (34), render.rs (6), queue.rs (4). — One of this dimension's main actionable groups (311 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt10.0 / 10Stronggated by 98 serious findings✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

98 deducted task-comment markers across 1359257 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×95crates/common/xai-tracing/src/fastrace.rs:54
HackComment · ×3crates/codegen/xai-ratatui-inline/src/terminal.rs:314

What to do

  1. Resolve the 95 TodoComment finding(s) in Explicit Debt — start with mod.rs (5), config.rs (5), git.rs (4). — One of this dimension's main actionable groups (95 warning-level).
  2. Resolve the 3 HackComment finding(s) in Explicit Debt — start with terminal.rs (3). — One of this dimension's main actionable groups (3 warning-level).
  3. Stand up a CI pipeline, then gate Explicit Debt in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. 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.

D19 · Documentation Quality10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the project's documentation is clear, complete, and useful.

Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

1 of 1 documentation facets pass in full. 56 document(s) read across 1 unit(s).

✓ On the Gold path — maintain.

Detailed fixes: d19_recommendation.md.

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.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

No architecture decision records were found.

No ADRs found

What to do

  1. Resolve the 1 No ADRs found finding(s) in ADR Quality. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d20_recommendation.md · top locations in Appendix A, every location in findings.md.

D23 · Boundary Type-Coupling10.0 / 10Stronggated by 1 serious finding✓ Tool-verified

What it measures: Whether domain types (IDs, enums, value objects) leak across bounded-context boundaries.

Method: Cross-context domain-type leakage via Roslyn structural classification (strongly-typed IDs / value objects) over every public surface. Exhaustive, deterministic, type-level aggregate-boundary check.

Coverage: Bounded contexts derived from NAMESPACE prefix (or graph-inferred where available); cross-boundary domain-type leakage then checked exhaustively over every public member of every type.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

1 domain type(s) cross context boundaries across 4 contexts.

Cross-context type CursorState (xai-grok-pager-render → xai-grok-pager)crates/codegen/xai-grok-pager/src/app/app_view.rs:530

What to do

  1. Resolve the 1 Cross-context type CursorState (xai-grok-pager-render → xai-grok-pager) finding(s) in Boundary Type-Coupling — start with app_view.rs. — One of this dimension's main actionable groups (1 warning-level).
  2. Stand up a CI pipeline, then gate Boundary Type-Coupling in it to reach Verified (currently Documented). — This repository has no CI pipeline, so there is nothing to add a gate to yet — the pipeline comes first. Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d23_recommendation.md · top locations in Appendix A, every location in findings.md.

D26 · Project Cohesion7.9 / 10Strong✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by log magnitude. Exhaustive across projects, deterministic, LLM-independent.

Maturity: Documented → Verified → Prevented · effective 7.9 / 10 · rule-coverage 100% · ceiling Documented

11 of 106 build units (Cargo, npm) flagged as possibly oversized/incoherent.

Projects may be oversized for their cohesion

What to do

  1. 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.

D28 · Secrets (history)10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.

Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

gitleaks scanned the full history AND the current working tree and found no secrets.

✓ On the Gold path — maintain.

Detailed fixes: d28_recommendation.md.

D29 · Static Analysis (SAST)6.4 / 10Adequate✓ Tool-verified

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).

Maturity: Documented → Verified → Prevented · effective 6.4 / 10 · rule-coverage 100% · ceiling Documented

4 finding(s): 0 critical, 2 high, 2 medium, 0 low. semgrep hit a parse error in 17 file(s) — `crates/codegen/xai-fast-worktree/src/api/gc/process_scan.rs` (line 137), `crates/codegen/xai-grok-config/src/fs_atomic.rs` (line 555, line 560, line 769, …), `crates/codegen/xai-grok-config/src/fs_atomic_tests.rs` (line 538, lines 582–583, line 988, …), `crates/codegen/xai-grok-pager-bin/src/main.rs` (line 1943), `crates/codegen/xai-grok-pager-render/src/syntax.rs` (line 79, line 80, line 81, …), … (+12 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.

REDACTED
REDACTED

What to do

  1. Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).
  2. Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 warning-level).

Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.

D30 · Dependency Vulnerabilities2.4 / 10Critical✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 2.4 / 10 · rule-coverage 100% · ceiling Documented

41 finding(s): 0 critical, 1 high, 36 medium, 4 low.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 1 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 14 Medium advisory (unmaintained) finding(s) in Dependency Vulnerabilities — start with REDACTED (14). — One of this dimension's main actionable groups (14 warning-level).
  2. Resolve the 12 Medium advisory (unsound) finding(s) in Dependency Vulnerabilities — start with REDACTED (12). — One of this dimension's main actionable groups (12 warning-level).
  3. Resolve the 1 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).

Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.

D35 · Change Coupling10.0 / 10Exemplary✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No strong hidden change-coupling between production files.

✓ On the Gold path — maintain.

Detailed fixes: d35_recommendation.md.

D37 · Vulnerability-disclosure Policy10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the repository publishes a coordinated-vulnerability-disclosure policy (SECURITY.md or security.txt) with a reporting contact, so finders know how to report a vulnerability. Presence of a policy file with a contact, not whether the policy is adequate or honoured.

Method: Vulnerability-disclosure policy read deterministically from the repo: a SECURITY.md (root/.github/docs) or .well-known/security.txt / security.txt, regex-checked for a reporting contact (email / URL / mailto). Present + contact → 10; present without a contact → 4; NotApplicable when no policy file exists (it may live off-repo). Detects the policy file's presence + contact, not its adequacy.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

A vulnerability-disclosure policy (SECURITY.md) is published with a reporting contact.

✓ On the Gold path — maintain.

Detailed fixes: d37_recommendation.md.

D43 · Malicious Dependencies10.0 / 10Exemplary✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No dependency in any ecosystem this repository declares is published as malicious.

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

D44 · Platform End-of-Life6.0 / 10Adequate✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 6.0 / 10 · rule-coverage 100% · ceiling Documented

1 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.

End-of-life runtime: Rust 1.94rust-toolchain.toml:1

What to do

  1. Resolve the 1 End-of-life runtime finding(s) in Platform End-of-Life — start with rust-toolchain.toml. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d44_recommendation.md · top locations in Appendix A, every location in findings.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AX10 · Code composition9.9 / 10Exemplary✓ Tool-verified

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.
AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

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.

AX4 · Dependency direction10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.

Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.

AX5 · Architecture & structure10.0 / 10Exemplary✓ Tool-verified

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.

AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.

Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.

AX9 · CQS / query purity10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.

Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.

Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.

C2 · Access Controls10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether access is authorized by default — a framework authorization attribute/decorator or policy, or imperative guard methods (throw-on-violation) called from handlers.

Method: Roslyn scan: [Authorize] usage and authorization policies, plus imperative throw-on-violation guard methods detected via syntax. Deterministic.

DM1 · Aggregate boundaries10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether an aggregate references another aggregate by identity rather than embedding it by object reference.

Method: Roslyn (DDD-gated): aggregate roots identified by convention; each aggregate field checked for direct references to other aggregates versus id-only. Deterministic, DDD-native.

Coverage: Population: aggregate roots identified by AggregateRoot/IAggregateRoot base/interface NAME convention; reference-by-identity then checked exhaustively within that set — a root not using those names is invisible.

DM2 · Strongly-typed ids10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether domain identifiers are strongly typed (a newtype wrapper) rather than raw primitives — consistency once an idiom exists.

Method: Roslyn (DDD-gated): strongly-typed id adoption on domain entities/events; raw Guid/int/string ids counted versus wrapped types. An id wrapper is recognised by VALUE SEMANTICS, not by being a struct — a record struct, a record class (`record ApartmentId(Guid Value)`) or a class declared by a typed-id base (`class MemberId : TypedIdValueBase`) all count, while a plain mutable class (reference equality) and a verb-phrase query record (`GetCustomerById`) do not. Deterministic, adoption percentage.

Coverage: Population: id-like members by *Id/*Key NAME suffix; strongly-typed-ID shape then checked semantically — non-suffixed identifiers are not seen.

DM4 · Rich vs anemic domain model10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether domain entities own their behaviour (invariant-enforcing commands) rather than being data-only structs driven by a foreign service.

Method: Roslyn (DDD-gated): entity method BODIES classified mutator-vs-query — only methods that mutate the entity's own declared state count as invariant-protecting behaviour, so a getter/passthrough doesn't rescue an anemic class. Deterministic, exhaustive over domain-layer entities.

Coverage: Population: entities by name/base convention; rich-vs-anemic judged by classifying each method body mutator-vs-query — logic-bearing domain types outside the convention are invisible.

DM5 · Encapsulated state10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether a domain type's identity-bearing field stays immutable — a `pub` mutable field under a hand-rolled Hash/PartialEq breaks the value-identity invariant.

Method: Roslyn (DDD-gated): entities scanned for publicly writable state — public setters, and (C#/VB) own mutable collections handed out through an auto-property, a public field or a bare-field expression getter, where a computed/copying getter is never charged. One finding per entity; score softened when Marten/EF rehydration frameworks present. Deterministic, framework-aware.

Coverage: Population: entities by convention; encapsulation (setter shape) checked exhaustively within the set.

ED4 · Outbox / dual-write8.0 / 10Strong✓ Tool-verified

Other · Event-Driven — Whether state changes and message publishes are atomic (a transactional outbox) rather than a crash-unsafe dual write.

Method: Roslyn semantic scan (event-driven gated): event-handler methods scanned for DB-save plus bus-publish without a transactional outbox reference. Deterministic, semantic-resolved.

  • `HostService.dispatch` performs two independent DURABLE writes — a durable state write (`store.persist_now`, :220) and an independent publish to an event bus (`notify.emit`, :285) — in one command path with no shared transaction or outbox. A crash between the two leaves the stores diverged (one write committed, the other lost) or emits a phantom record. Wrap both in one transaction, or record the second write in the same store and dispatch it afterwards (a transactional outbox). — crates/codegen/xai-grok-shell/src/session/workflow/host_service.rs:210

What to do

  • Adopt the transactional outbox pattern so DB writes and message publishes commit atomically — no lost or phantom events on a crash.
ES1 · Fold determinism10.0 / 10Exemplary✓ Tool-verified

Other · Event Sourcing — Whether the recovery-replay fold is deterministic — state derived purely from each event's own fields, no clock/random/IO on the replay path.

Method: Roslyn syntax scan (event-sourcing gated): Apply/When folds checked for forbidden tokens (DateTime.Now, Guid.NewGuid, Random, IO), stripped of comments/strings. Deterministic, hard fact per fold.

ES2 · Immutable events10.0 / 10Exemplary✓ Tool-verified

Other · Event Sourcing — Whether domain events stay immutable (private fields, set once) rather than carrying mutable state.

Method: Roslyn scan (event-sourcing gated): persisted events checked for public setters; immutability verified per property/field. Deterministic, hard fact.

M1 · Documentation (README)7.6 / 10Strong✓ Tool-verified

Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.

Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.

What to do

  • Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
  • Add a README to the 96 of 110 project(s) that lack one — worth up to 1.7 pts.
M2 · Architecture documentation5.0 / 10Adequate✓ Tool-verified

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.
M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repo is organised deliberately — src/test separation and consistent project naming.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

M4 · Documentation accuracy10.0 / 10Exemplary○ Nothing flagged

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.

P1 · CI/CD gates0.0 / 10Critical✓ Tool-verified

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.

  • No CI workflow found (.github/workflows, azure-pipelines.yml, .gitlab-ci.yml, …) — changes aren't gated by an automated build/test.

What to do

  • Add a CI workflow that builds and runs the test suite on every push/PR.
P10 · Library API & versioning6.0 / 10Adequate✓ Tool-verified

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.

  • No explicit version was found for the crates.io library declared by `Cargo.toml`. This check read a `version` in Cargo.toml (or `version.workspace = true`), and a CHANGELOG/CHANGES/HISTORY/NEWS/RELEASES file with a semver heading, or release tooling (changesets, release-please, semantic-release, goreleaser, cargo-release, bump2version, standard-version, git-cliff) in the library's directory or at the repository root, or a semver release tag (or a Drupal `8.x-1.2` release tag) in the repository. A version computed where none of those can see is invisible here. A published library needs explicit semantic versioning so consumers can reason about breaking changes. — crates/codegen/xai-grok-shared/Cargo.toml

What to do

  • Declare the version where the ecosystem expects it, or keep a CHANGELOG with semver release headings, and follow semver for breaking changes.
P2 · Observability8.8 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

  • Only 70/75 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `.`, `crates/codegen/xai-grok-egress-proxy`, `crates/codegen/xai-grok-markdown`, `crates/codegen/xai-grok-pager/npm/grok`, `crates/codegen/xai-mixpanel`.

What to do

  • Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
  • Add a health-check endpoint (a /health route on your axum/actix router) so orchestrators and load balancers can probe liveness/readiness.
P3 · Security & performance tooling5.0 / 10Adequate✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

What to do

  • Your ecosystem's static analyzer is declared as a dependency but is not wired into CI — run it as a required step on push/PR (e.g. `composer phpstan` / `mix sobelow` / `bundle exec brakeman` / the spotbugs Gradle task / `sbt scalafixAll --check` / `golangci-lint run` / `rebar3 lint`) so a regression fails the build instead of relying on someone running it locally.
  • Enable Dependabot/Renovate or a dependency-review gate.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P6 · Release Hygiene5.0 / 10Adequate✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

What to do

  • Stamp a version in your build/package manifest (e.g. csproj <Version>, package.json, pyproject.toml, Cargo.toml, or a VERSION file) or tag releases with semver so builds and releases are traceable.
P7 · Outbound HTTP resilience3.0 / 10Weak✓ Tool-verified

Readiness · Readiness — Whether outbound HTTP calls are wrapped in resilience (retry/timeout/circuit-breaker) so a failing dependency doesn't cascade.

Method: Source scan: outbound HTTP clients and what bounds them — resilience handlers (Polly, AddStandardResilienceHandler) on .NET; on Go, the JVM, Python, JavaScript/TypeScript, Ruby, PHP, Rust, Elixir, Swift, Dart and Erlang, a timeout, deadline, retry or breaker beside each call, or a process-wide client default (a framework-wide deadline such as Drupal core's, Laravel's or actix's awc counts). Exhaustive, deterministic.

  • `reqwest::Client::builder(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — crates/codegen/xai-grok-extra-ca/src/lib.rs:59
  • `reqwest::blocking::Client::builder(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — crates/codegen/xai-grok-extra-ca/src/lib.rs:75
  • `AgentBuilder::new(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — crates/codegen/xai-grok-shell/src/session/agent_rebuild.rs:303
  • `reqwest::Client::new(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — crates/common/xai-tracing/src/http_client.rs:24

What to do

  • Give every client a whole-request bound: `reqwest::Client::builder().timeout(Duration::from_secs(10))` (never `reqwest::get` or `Client::new()`, which have none), ureq's `timeout_global`, or wrap the call in `tokio::time::timeout`; add retry with back-off (`reqwest-retry`'s `RetryTransientMiddleware`, `backoff`) around dependencies that fail.
PF1 · Benchmark discipline9.5 / 10Exemplary✓ Tool-verified

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.

PF3 · Async & latency hygiene6.0 / 10Adequate✓ Tool-verified

Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.

Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from the language model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.

  • `spawn_agent_thread_direct` is async and calls block_on — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs. — crates/codegen/xai-grok-pager/src/acp/spawn.rs:365
  • `spawn_watcher` is async and calls block_on — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs. — crates/codegen/xai-grok-pager/src/headless/signals.rs:114
  • `run_cell_inner` is async and calls thread::sleep — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs. — crates/codegen/xai-grok-pager-pty-harness/src/scroll_matrix/runner.rs:138
  • `spawn_session_on_thread` is async and calls block_on — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs. — crates/codegen/xai-grok-shell/src/session/acp_session_impl/spawn.rs:2549

What to do

  • Rust: `.await` the future instead of `block_on` (on a Tokio runtime thread it panics outright) and use `tokio::time::sleep(..).await` instead of `std::thread::sleep`; where synchronous code must run, move it to `tokio::task::spawn_blocking` or `block_in_place`.
S1 · Web-Security Posture2.0 / 10Critical✓ Tool-verified

Other · Security — Read from this repository's Rust source: cryptographic hygiene (weak hash or cipher, key material fixed in the source) and outbound TLS (certificate validation, protocol version) — facts about code that hold whether or not it serves anything itself. This repository serves HTTP itself (`axum::serve(` (crates/codegen/xai-grok-shell/src/agent/server.rs:633)), so its Rust source was also read for the server controls: TLS served or HSTS set, security response headers, cookie flags and inbound validation — each credited where its Rust spelling appears in production source, not proven on every route. A Rocket 0.5 application is credited the headers Rocket's default `Shield` sends unless it attaches its own, and its cookie jar's SameSite=Strict default; a session middleware its default cookie flags.

Method: Roslyn plus filesystem scan: HSTS/security headers, secure cookies, input validation, middleware order, weak crypto (MD5/SHA1/DES); HTTPS-metadata context-aware. On a repository with no .NET source it reads JavaScript/TypeScript, Dart, Ruby, Scala, Rust or Elixir source itself (test, vendored, generated and minified paths not) for the arms that hold whether or not the code serves HTTP: a weak hash or cipher, key material fixed in the source, a TLS client that accepts any certificate, and (JavaScript/TypeScript, Ruby, Scala, Rust and Elixir) an obsolete TLS version; the server controls are not assessed there, and a Dart, Ruby, Scala, Rust or Elixir repository that serves no HTTP of its own is N/A on them. Deterministic.

  • `SETTINGS_CACHE_WRITE_HMAC_KEY` is the secret key and is a compile-time constant, so the secret this operation depends on is published with the source. A key that ships with the source is not secret: every contributor, fork, mirror and released binary carries it, so anyone holding the repository can decrypt what any installation encrypted, and there is no way to invalidate what was already protected because every deployment built from this source shares the value. Where the constant is a password salt the consequence differs but is no smaller — one global salt means precomputation amortises across every installation, which is the property salting exists to destroy. Read the value from configuration, an environment variable or a secrets manager at startup and FAIL FAST when it is absent, so a missing key stops the process instead of silently falling back to a shared default; treat the committed value as disclosed and rotate it rather than only deleting the line. For a salt, generate a fresh random one per password and store it alongside the hash. — crates/codegen/xai-grok-cloud-config/src/settings_cache.rs:332
  • This repository starts an HTTP server and nothing in its Rust source or committed `Rocket.toml` secures the transport: no TLS served (actix-web `bind_rustls`/`bind_openssl`, axum-server `bind_rustls` with a `RustlsConfig`, tonic `ServerTlsConfig`, a `TlsAcceptor`, Rocket's `[default.tls]`), no `Strict-Transport-Security` header, no `X-Forwarded-Proto` read from a TLS-terminating proxy — so its traffic may cross the network in clear text. (−2.0 on this card.) The server: `axum::serve(` (crates/codegen/xai-grok-shell/src/agent/server.rs:633).
  • None of the 11 security response headers the OWASP Secure Headers Project recommends (Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options, …) is set on a response this repository's Rust server sends — defense in depth, even when a proxy could set them. (−2.0 on this card.) The server: `axum::serve(` (crates/codegen/xai-grok-shell/src/agent/server.rs:633).

What to do

  • Load cryptographic key and salt material from configuration, an environment variable or a secrets manager rather than fixing it in the source, and fail fast at startup when it is absent — a default that silently works is the one that reaches production. Rotate anything already committed: it must be treated as disclosed. Salts should be generated per password and stored with the hash, never shared across installations.
  • Secure the server's transport: serve TLS itself (`HttpServer::bind_rustls_0_23(addr, config)` in actix-web, `axum_server::bind_rustls(addr, RustlsConfig::from_pem_file(…))`, tonic's `Server::builder().tls_config(ServerTlsConfig::new().identity(…))`, Rocket's `[default.tls]`), or run it behind a TLS-terminating proxy and check `X-Forwarded-Proto`; send `Strict-Transport-Security` once it is HTTPS-only.
  • Set security response headers on what the server sends — actix-web's `DefaultHeaders::new().add((header::X_CONTENT_TYPE_OPTIONS, "nosniff"))`, tower-http's `SetResponseHeaderLayer::overriding(…)` on an axum router, or keep Rocket's default `Shield` — with `Content-Security-Policy`, `X-Content-Type-Options` and a frame policy on every response.
X1 · Async correctness8.0 / 10Strong✓ Tool-verified

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.

  • This `async` body is polled on an executor's worker thread, and `std::thread::sleep` blocks that thread: for the whole delay no other task scheduled on it makes progress — the Rust form of blocking on a task. Use `tokio::time::sleep(…).await` (or the runtime's own timer), which suspends only this task. Where the blocking work is not a sleep but a synchronous call that cannot be made async, move it off the executor with `tokio::task::spawn_blocking(…).await`. — crates/codegen/xai-grok-pager-pty-harness/src/scroll_matrix/runner.rs:158

What to do

  • Blocking `thread::sleep` inside an `async` body
X12 · Unreachable branch10.0 / 10Exemplary○ Nothing flagged

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.

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.

X14 · Bypassable address classification6.2 / 10Adequate✓ Tool-verified

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.

  • This function unwraps IPv4-MAPPED IPv6 (`to_ipv4_mapped`, line 70) and then rejects `10.0.0.0/8` on its IPv4 path — but the IPv6 decision at line 63 classifies the address as written, and IPv4 reaches IPv6 through three MORE embeddings this function never mentions: IPv4-compatible (`::a.b.c.d`), 6to4 (`2002::/16`) and NAT64 (`64:ff9b::/96`). So `::10.0.0.1`, `2002:0a00:0001::` and `64:ff9b::10.0.0.0` all name a host inside `10.0.0.0/8` — the range this same function declares non-public — and all reach the IPv6 decision un-unwrapped, taking the opposite verdict. Unwrap every embedding to its IPv4 form before classifying, or reject any IPv6 address carrying an embedded IPv4 outright. — crates/codegen/xai-grok-hooks/src/runner/http.rs:63

What to do

  • Each finding names the IPv4 branch that rejects the host and the IPv6 branch that accepts the same host in another notation. Confirm from the two, then unwrap every IPv4-in-IPv6 embedding before classifying, or reject non-native IPv6 outright.
X15 · Unvalidated length from an untrusted reader1.7 / 10Critical✓ Tool-verified

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.

  • `n_segs` is read from the bytes being parsed at line 829 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 835 — and nowhere in its scope is `n_segs` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `n_segs` against the bytes actually remaining and a maximum the format allows before allocating. — crates/codegen/xai-grok-workspace/src/file_system/index.rs:835
  • `n_entries` is read from the bytes being parsed at line 831 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 846 — and nowhere in its scope is `n_entries` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `n_entries` against the bytes actually remaining and a maximum the format allows before allocating. — crates/codegen/xai-grok-workspace/src/file_system/index.rs:846
  • `arena_len` is read from the bytes being parsed at line 1462 (`u32::from_le_bytes`), then used to size a `vec![…; n]` at line 1463 — and nowhere in its scope is `arena_len` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `arena_len` against the bytes actually remaining and a maximum the format allows before allocating. — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1463
  • `num_offsets` is read from the bytes being parsed at line 1468 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 1469 — and nowhere in its scope is `num_offsets` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `num_offsets` against the bytes actually remaining and a maximum the format allows before allocating. — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1469
  • `num_locations` is read from the bytes being parsed at line 1488 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 1489 — and nowhere in its scope is `num_locations` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `num_locations` against the bytes actually remaining and a maximum the format allows before allocating. — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1489
  • `num_locations` is read from the bytes being parsed at line 1508 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 1509 — and nowhere in its scope is `num_locations` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `num_locations` against the bytes actually remaining and a maximum the format allows before allocating. — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1509

What to do

  • Each finding names the read that takes the length from the input and the site that spends it, and states that the value is never compared in between. Confirm from the two, then bound the length against the remaining stream before using it.
X16 · Unfloored truncation loop10.0 / 10Exemplary○ Nothing flagged

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.

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.

X18 · Disposal-pattern correctness10.0 / 10Exemplary○ Nothing flagged

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.

X19 · Unrestored process-global state10.0 / 10Exemplary○ Nothing flagged

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.

X21 · Side-effecting pattern guard10.0 / 10Exemplary○ Nothing flagged

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.

X22 · Contradicted release guard10.0 / 10Exemplary○ Nothing flagged

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.

X23 · Unguarded diagnostic materialisation10.0 / 10Exemplary○ Nothing flagged

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.

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.

X25 · Inert configuration knob10.0 / 10Exemplary○ Nothing flagged

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.

X26 · Unsynchronised callback handoff10.0 / 10Exemplary○ Nothing flagged

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.

X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `for` loop leaves the `RefCell` it is walking alone — safe Rust rejects a body that changes the collection its loop borrows at compile time, except through interior mutability: a `RefCell` borrowed in the loop's header stays borrowed until the loop ends, so a `borrow_mut()` of it inside the body panics with `already borrowed: BorrowMutError` and the remaining elements are never seen. 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.

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.

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.

X3 · Exception handling10.0 / 10Exemplary○ Nothing flagged

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.

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.

X4 · Structured logging5.5 / 10Adequate✓ Tool-verified

Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.

Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. 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 `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `package.json` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.

  • `debug!` at line 374 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/common/xai-computer-hub-sdk/src/connection.rs:374
  • `info!` at line 26 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-tracing-macros/src/timestamp.rs:26
  • `info!` at line 33 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-tracing-macros/src/timestamp.rs:33
  • `warn!` at line 45 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-tracing-macros/src/timestamp.rs:45
  • `warn!` at line 52 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-tracing-macros/src/timestamp.rs:52
  • `debug!` at line 2070 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-ratatui-textarea/src/textarea.rs:2070
  • `debug!` at line 333 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-hunk-tracker/src/actor/mod.rs:333
  • `debug!` at line 512 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:512
  • `debug!` at line 595 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:595
  • `debug!` at line 613 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:613
  • `debug!` at line 632 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:632
  • `debug!` at line 636 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:636
  • `debug!` at line 204 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/fs_notify.rs:204
  • `debug!` at line 210 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/fs_notify.rs:210
  • `debug!` at line 215 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/fs_notify.rs:215
  • `debug!` at line 218 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/fs_notify.rs:218
  • `debug!` at line 227 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/fs_notify.rs:227
  • `warn!` at line 1884 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/handle.rs:1884
  • `warn!` at line 4173 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/handle.rs:4173
  • `warn!` at line 378 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/sandbox_mode.rs:378
  • `info!` at line 375 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/permission/sandbox_network.rs:375
  • `info!` at line 531 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs:531
  • `info!` at line 540 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs:540
  • `warn!` at line 202 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/file_system/attach_file.rs:202
  • `warn!` at line 226 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/file_system/attach_file.rs:226
  • `warn!` at line 239 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/file_system/attach_file.rs:239
  • `error!` at line 83 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/bin/workspace_server.rs:83
  • `info!` at line 408 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-workspace/src/bin/workspace_server.rs:408
  • `debug!` at line 223 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-voice/src/stt/streaming.rs:223
  • `warn!` at line 690 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:690
  • `warn!` at line 745 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:745
  • `warn!` at line 851 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:851
  • `debug!` at line 1241 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:1241
  • `debug!` at line 1299 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:1299
  • `debug!` at line 1332 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:1332
  • `debug!` at line 1442 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:1442
  • `warn!` at line 1486 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:1486
  • `warn!` at line 1868 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:1868
  • `debug!` at line 2095 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:2095
  • `debug!` at line 2109 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/codegen/xai-grok-update/src/auto_update.rs:2109

What to do

  • Interpolated log message defeats structured logging

Reference — by lens

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.

LensScoreRatingImpact
Code Health73%Adequate — gated by D2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture97%ExemplarySolid.
Maturity76%StrongSolid.
Readiness40%Weak — gated by P1, P7Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Security57%Adequate — gated by D30, S1Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Domain Modelling100%ExemplaryStrongest area.
Event-Driven80%StrongSolid.
Event Sourcing100%ExemplarySolid.
Performance75%StrongSolid.
Unscored — 4 check(s) recorded observations but carry no score

These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.

  • SC1 Supply-chain hygiene — 1 observation(s) recorded · Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 40 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X9 Subsumed condition operand — 10 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 2 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.

  • P4 Deployment & Rollback — not evidenced — no deploy/rollback/approval signal in the repo; absence of evidence is not evidence of a manual release
  • P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 53 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.

  • AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
  • AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
  • AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
  • AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
  • AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
  • AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
  • AC7 A11y enforcement — No web markup found — accessibility is not applicable to this repository.
  • AX1 Captive dependencies — Not applicable: Rust with no dependency-injection crate has no container to hand one lifetime's instance to another — every value is owned by the code that builds it, and the borrow checker rejects a longer-lived value keeping a borrow of a shorter-lived one.
  • AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No class in this Kotlin code is a Spring, JSR-330 or CDI singleton bean. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. No Swift request handler (a Vapor, Hummingbird, Kitura, Swifter or Perfect route handler, as a method or a registered closure) is declared, so no state is shared between request threads. Rust's compiler refuses unsynchronised shared mutation — a value shared across threads must be Sync — so the race this check looks for cannot be written. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
  • AX6 Interface segregation — not assessed — interface segregation is computed over a type surface 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
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • AXR1 Runtime accessibility — the service did not build — `cargo build --locked --bin 'chat-history-downgrade'` exited 1: info: syncing channel updates for 1.94.0-x86_64-unknown-linux-gnu error: could not download file from 'https://static.rust-lang.org/dist/channel-rust-1.94.0.toml.sha256' to '/usr/local/rustup/tmp/s0uw…; runtime evidence skipped (launch chosen because 'axum' dependency in crates/codegen/xai-grok-shell/Cargo.toml, binary 'chat-history-downgrade') 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 — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no data at rest for these controls to protect.
  • C3 Audit Trail — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no sensitive data whose changes an audit trail would record. If it does (through a store configured outside this repository, for instance), the trail belongs to wherever that data is stored.
  • C4 Data Retention — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no personal data whose lifetime a retention limit would bound.
  • C5 Data-Subject Rights — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no personal data for a data subject to erase, export or consent over.
  • D10 Test Quality — ~486687 lines of test source are present (.rs) but no test cases reached the test census for this repository — no test root we could resolve declared them, or the files we read declare no cases in a test framework we recognise — so skipped/assertion-free tests couldn't be counted. Not scored — this is a gap in the analyzer, not a finding about this repository.
  • D11 Test Reliability — Test reliability not included — the .rs suite was found but not re-run
  • D16 Bus Factor — single-contributor repository — bus factor is not applicable
  • 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.
  • D21 Naming Consistency — Naming consistency is measured on C# only; JavaScript, Kotlin, Python, Rust, Swift not measured.
  • D22 Internal API Consistency — API consistency is measured on C# only; the exposed Rust surface was not measured.
  • D24 Comment Value — D24 reads C# and Visual Basic comments only — this repository's production source is .py, .rs, which was left unread. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • 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 (.rs), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D31 IaC & Container Security — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
  • D32 Data Compliance (PII/GDPR) — 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.
  • D34 Knowledge Freshness — history too condensed to judge knowledge freshness
  • D36 Supply-chain Provenance & Signing — No CI/build pipeline found (.github/.forgejo/.gitea workflows, .circleci, .buildkite, .woodpecker, .teamcity, .gitlab-ci.yml, .travis.yml, bitbucket-pipelines.yml, .drone.yml, .cirrus.yml, .woodpecker.yml, appveyor.yml, azure-pipelines*.yml, .pipelines/, .vsts-ci/, .azuredevops/, Jenkinsfile); there is no build to attest provenance for.
  • 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.
  • 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 included — suite not readable by the collector
  • DM3 Integration-event coupling — no integration events detected — coupling check not applicable
  • DM6 Domain ↔ infrastructure boundary — this Rust crate maps no type to a persistence framework (diesel/sea-orm/sqlx), so DM6's domain↔infrastructure fusion read has no population to be taken over
  • DM7 Repository granularity — no repository abstraction detected (e.g. uses a document session)
  • ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and this analysis resolves a call's owner only where the receiver's type is written down in the source. Reported as guidance rather than measured
  • ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and a call made through an inferred or generic receiver has no resolvable owner in the source. Reported as guidance rather than measured
  • ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
  • 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 — no CI workflow found
  • P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
  • P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (lcov — `cargo install cargo-llvm-cov`, then `cargo llvm-cov --lcov --output-path lcov.info`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
  • PF2 Allocation hygiene — Not applicable: Rust spells out every heap allocation and makes borrowed slices (&[T], &str) its ordinary parameter types, so the allocation-aware style this card rewards elsewhere is the language's baseline rather than a rung to climb.
  • X2 Cancellation propagation — no C# was loaded; this repository's Python and Rust were read, and no request in it can be cancelled by a caller — a Python request takes no token: asyncio cancels the task and trio or anyio the scope that made it, from outside the call, and requests, httpx, aiohttp and gRPC take a timeout, not a cancellation; a Rust request takes no token: a future is cancelled by dropping it, from outside the call (select!, a timeout, an aborted task), and reqwest, hyper and tonic take none
  • 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.
  • 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
  • X6 Hand-rolled structured-format parsing — 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 — 5 finding(s)
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · High CVE · ×1
  • REDACTED
ED4 · Outbox / dual-write · Dual write (no outbox) · ×1
  • Dual write (no outbox): HostService.dispatch crates/codegen/xai-grok-shell/src/session/workflow/host_service.rs:210 — `HostService.dispatch` performs two independent DURABLE writes — a durable state write (`store.persist_now`, :220) and an independent publish to an event bus (`notify.emit`, :285) — in one command path with no shared transaction or outbox. A crash between the two leaves the stores diverged (one write committed, the other lost) or emits a phantom record. Wrap both in one transaction, or record the second write in the same store and dispatch it afterwards (a transactional outbox).
S1 · Web-Security Posture · Cryptographic key material is a compile-time constant · ×1
  • Cryptographic key material is a compile-time constant crates/codegen/xai-grok-cloud-config/src/settings_cache.rs:332 — `SETTINGS_CACHE_WRITE_HMAC_KEY` is the secret key and is a compile-time constant, so the secret this operation depends on is published with the source. A key that ships with the source is not secret: every contributor, fork, mirror and released binary carries it, so anyone holding the repository can decrypt what any installation encrypted, and there is no way to invalidate what was already protected because every deployment built from this source shares the value. Where the constant is a password salt the consequence differs but is no smaller — one global salt means precomputation amortises across every installation, which is the property salting exists to destroy. Read the value from configuration, an environment variable or a secrets manager at startup and FAIL FAST when it is absent, so a missing key stops the process instead of silently falling back to a shared default; treat the committed value as disclosed and rotate it rather than only deleting the line. For a salt, generate a fresh random one per password and store it alongside the hash.
Serious — 3108 finding(s)
D15 · Churn × Complexity Hotspots · Hotspot · ×311
  • Hotspot: crates/codegen/xai-grok-pager/src/app/agent_view/render.rs crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:562 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs changed 34 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 511 in AgentView::draw at line 562. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/agent_view/render.rs`: 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: crates/codegen/xai-grok-pager/src/app/dispatch/router.rs crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:165 — crates/codegen/xai-grok-pager/src/app/dispatch/router.rs changed 27 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 458 in xai_grok_pager::app::dispatch::router::dispatch_inner at line 165. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/dispatch/router.rs`: 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: crates/codegen/xai-grok-pager/src/app/effects/mod.rs crates/codegen/xai-grok-pager/src/app/effects/mod.rs:122 — crates/codegen/xai-grok-pager/src/app/effects/mod.rs changed 36 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 342 in xai_grok_pager::app::effects::execute at line 122. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/effects/mod.rs`: 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: crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs:457 — crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs changed 31 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 313 in xai_grok_pager::app::dispatch::task_result::dispatch_task_result at line 457. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs`: 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: crates/codegen/xai-grok-pager/src/app/event_loop.rs crates/codegen/xai-grok-pager/src/app/event_loop.rs:1034 — crates/codegen/xai-grok-pager/src/app/event_loop.rs changed 35 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 264 in xai_grok_pager::app::event_loop::run at line 1034. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/event_loop.rs`: 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: crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:354 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs changed 31 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 250 in xai_grok_shell::session::acp_session_impl::run_loop::run_session at line 354. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs`: 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: crates/codegen/xai-grok-pager/src/app/agent_view/input.rs crates/codegen/xai-grok-pager/src/app/agent_view/input.rs:328 — crates/codegen/xai-grok-pager/src/app/agent_view/input.rs changed 25 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 231 in AgentView::handle_input_inner at line 328. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/agent_view/input.rs`: 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: crates/codegen/xai-grok-shell/src/agent/subagent/handle_request.rs crates/codegen/xai-grok-shell/src/agent/subagent/handle_request.rs:357 — crates/codegen/xai-grok-shell/src/agent/subagent/handle_request.rs changed 33 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 170 in xai_grok_shell::agent::subagent::handle_request::run_shell_child at line 357. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/agent/subagent/handle_request.rs`: 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: crates/codegen/xai-grok-shell/src/session/acp_session_impl/spawn.rs crates/codegen/xai-grok-shell/src/session/acp_session_impl/spawn.rs:217 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/spawn.rs changed 38 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 142 in xai_grok_shell::session::acp_session_impl::spawn::spawn_session_actor at line 217. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/session/acp_session_impl/spawn.rs`: 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: crates/codegen/xai-grok-pager/src/app/mouse.rs crates/codegen/xai-grok-pager/src/app/mouse.rs:30 — crates/codegen/xai-grok-pager/src/app/mouse.rs changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 224 in AgentView::handle_mouse at line 30. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/mouse.rs`: 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: crates/codegen/xai-grok-pager/src/app/acp_handler/session_notification.rs crates/codegen/xai-grok-pager/src/app/acp_handler/session_notification.rs:184 — crates/codegen/xai-grok-pager/src/app/acp_handler/session_notification.rs changed 28 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 154 in xai_grok_pager::app::acp_handler::session_notification::handle_session_notification_with_origin at line 184. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/acp_handler/session_notification.rs`: 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: crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:503 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs changed 33 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 124 in SessionActor::handle_turn_input_inner at line 503. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs`: 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: crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs:438 — crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs changed 24 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 140 in xai_grok_workspace::permission::manager::spawn_permission_manager_with_pin at line 438. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs`: 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: crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:643 — crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs changed 29 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 92 in xai_grok_pager::app::dispatch::prompt::dispatch_send_prompt_submission at line 643. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs`: 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: crates/codegen/xai-grok-shell/src/session/persistence.rs crates/codegen/xai-grok-shell/src/session/persistence.rs:2082 — crates/codegen/xai-grok-shell/src/session/persistence.rs changed 27 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 97 in SessionPersistence::run at line 2082. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/session/persistence.rs`: 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: crates/codegen/xai-grok-workspace/src/hub_server.rs crates/codegen/xai-grok-workspace/src/hub_server.rs:392 — crates/codegen/xai-grok-workspace/src/hub_server.rs changed 23 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 110 in WorkspaceRpcHandler::dispatch at line 392. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-workspace/src/hub_server.rs`: 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: crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:251 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs changed 25 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 101 in SessionActor::cancel_running_task at line 251. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs`: 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: crates/codegen/xai-grok-pager/src/views/extensions_modal.rs crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2768 — crates/codegen/xai-grok-pager/src/views/extensions_modal.rs changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 172 in xai_grok_pager::views::extensions_modal::render_extensions_modal at line 2768. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/views/extensions_modal.rs`: 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: crates/codegen/xai-grok-shell/src/session/compaction.rs crates/codegen/xai-grok-shell/src/session/compaction.rs:922 — crates/codegen/xai-grok-shell/src/session/compaction.rs changed 25 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 93 in SessionActor::run_compact_inner at line 922. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/session/compaction.rs`: 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: crates/codegen/xai-grok-shell/src/leader/server.rs crates/codegen/xai-grok-shell/src/leader/server.rs:1505 — crates/codegen/xai-grok-shell/src/leader/server.rs changed 18 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 128 in xai_grok_shell::leader::server::run_leader_server at line 1505. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/leader/server.rs`: 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: crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:4134 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs changed 40 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 57 in MvpAgent::spawn_and_register_session at line 4134. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs`: 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: crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1983 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs changed 36 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 62 in MvpAgent::ext_method at line 1983. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs`: 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: crates/codegen/xai-grok-pager/src/app/agent_view/prompt.rs crates/codegen/xai-grok-pager/src/app/agent_view/prompt.rs:91 — crates/codegen/xai-grok-pager/src/app/agent_view/prompt.rs changed 18 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 120 in AgentView::handle_prompt_key at line 91. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/agent_view/prompt.rs`: 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: crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:484 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs changed 32 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 67 in SessionActor::execute_tool_calls_batch at line 484. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs`: 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: crates/codegen/xai-grok-pager/src/app/effects/helpers.rs crates/codegen/xai-grok-pager/src/app/effects/helpers.rs:987 — crates/codegen/xai-grok-pager/src/app/effects/helpers.rs changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 99 in xai_grok_pager::app::effects::helpers::persist_setting at line 987. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 16:57:09 +00:00' --until='2026-09-29 16:57:09 +00:00' --full-history --no-merges -- crates/codegen/xai-grok-pager/src/app/effects/helpers.rs`: 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.
  • + 286 more in this group — see findings.md.
D2 · Cognitive Complexity · xai_grok_pager · ×254
  • xai_grok_pager::app::event_loop::run (cognitive 556) crates/codegen/xai-grok-pager/src/app/event_loop.rs:1034 — xai_grok_pager::app::event_loop::run has cognitive complexity 556 (threshold 15). Drivers by points: if/else 180 (424 pts), match/switch 36 (84 pts), boolean chains 24, loops 9 (24 pts) (nesting depth added 307). 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.
  • xai_grok_pager::views::extensions_modal::render_extensions_modal (cognitive 493) crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2768 — xai_grok_pager::views::extensions_modal::render_extensions_modal has cognitive complexity 493 (threshold 15). Drivers by points: if/else 124 (342 pts), loops 20 (82 pts), match/switch 13 (47 pts), boolean chains 22 (nesting depth added 314). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager::app::effects::execute (cognitive 407) crates/codegen/xai-grok-pager/src/app/effects/mod.rs:122 — xai_grok_pager::app::effects::execute has cognitive complexity 407 (threshold 15). Drivers by points: if/else 92 (200 pts), match/switch 99 (188 pts), loops 5 (12 pts), boolean chains 7 (nesting depth added 204). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager::views::picker::handle_picker_input (cognitive 385) crates/codegen/xai-grok-pager/src/views/picker.rs:2480 — xai_grok_pager::views::picker::handle_picker_input has cognitive complexity 385 (threshold 15). Drivers by points: if/else 105 (298 pts), boolean chains 62, loops 8 (22 pts), match/switch 2 (3 pts) (nesting depth added 208). Of this number, 377 points are the body's own statements and 8 belong to 4 function items 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.
  • xai_grok_pager::app::dispatch::task_result::dispatch_task_result (cognitive 383) crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs:457 — xai_grok_pager::app::dispatch::task_result::dispatch_task_result has cognitive complexity 383 (threshold 15). Drivers by points: if/else 128 (298 pts), match/switch 16 (43 pts), boolean chains 37, loops 2 (5 pts) (nesting depth added 200). 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.
  • xai_grok_pager::app::dispatch::router::dispatch_inner (cognitive 323) crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:165 — xai_grok_pager::app::dispatch::router::dispatch_inner has cognitive complexity 323 (threshold 15). Drivers by points: if/else 129 (271 pts), match/switch 14 (24 pts), boolean chains 22, loops 2 (6 pts) (nesting depth added 156). 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.
  • xai_grok_pager::app::acp_handler::session_notification::handle_session_notification_with_origin (cognitive 250) crates/codegen/xai-grok-pager/src/app/acp_handler/session_notification.rs:184 — xai_grok_pager::app::acp_handler::session_notification::handle_session_notification_with_origin has cognitive complexity 250 (threshold 15). Drivers by points: if/else 107 (203 pts), boolean chains 28, match/switch 9 (17 pts), loops 1 (2 pts) (nesting depth added 105). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager::acp::tracker::tool_call_to_block (cognitive 225) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1816 — xai_grok_pager::acp::tracker::tool_call_to_block has cognitive complexity 225 (threshold 15). Drivers by points: if/else 81 (195 pts), match/switch 5 (16 pts), boolean chains 14 (nesting depth added 125). 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.
  • xai_grok_pager::scrollback::render::render_scrolled_entries_with_selection_boundaries (cognitive 182) crates/codegen/xai-grok-pager/src/scrollback/render.rs:225 — xai_grok_pager::scrollback::render::render_scrolled_entries_with_selection_boundaries has cognitive complexity 182 (threshold 15). Drivers by points: if/else 59 (142 pts), loops 8 (21 pts), boolean chains 13, match/switch 1 (6 pts) (nesting depth added 101). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager::app::acp_handler::handle_inner (cognitive 177) crates/codegen/xai-grok-pager/src/app/acp_handler/mod.rs:154 — xai_grok_pager::app::acp_handler::handle_inner has cognitive complexity 177 (threshold 15). Drivers by points: if/else 41 (138 pts), boolean chains 27, loops 2 (9 pts), match/switch 2 (3 pts) (nesting depth added 105). 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.
  • xai_grok_pager::app::dispatch::prompt::dispatch_send_prompt_submission (cognitive 160) crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:643 — xai_grok_pager::app::dispatch::prompt::dispatch_send_prompt_submission has cognitive complexity 160 (threshold 15). Drivers by points: if/else 63 (121 pts), boolean chains 26, match/switch 4 (8 pts), loops 1 (5 pts) (nesting depth added 66). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager::views::persona_detail::render_persona_detail (cognitive 156) crates/codegen/xai-grok-pager/src/views/persona_detail.rs:356 — xai_grok_pager::views::persona_detail::render_persona_detail has cognitive complexity 156 (threshold 15). Drivers by points: if/else 53 (129 pts), loops 7 (22 pts), boolean chains 5 (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.
  • xai_grok_pager::views::agents_modal::render_personas_tab (cognitive 150) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1462 — xai_grok_pager::views::agents_modal::render_personas_tab has cognitive complexity 150 (threshold 15). Drivers by points: if/else 47 (119 pts), loops 8 (24 pts), boolean chains 5, match/switch 1 (2 pts) (nesting depth added 89). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager::views::agent::build_hints (cognitive 140) crates/codegen/xai-grok-pager/src/views/agent.rs:685 — xai_grok_pager::views::agent::build_hints has cognitive complexity 140 (threshold 15). Drivers by points: if/else 62 (112 pts), boolean chains 23, match/switch 2 (3 pts), loops 1 (2 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.
  • xai_grok_pager::views::file_search::line_viewer::render_line_viewer (cognitive 124) crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:1440 — xai_grok_pager::views::file_search::line_viewer::render_line_viewer has cognitive complexity 124 (threshold 15). Drivers by points: if/else 60 (97 pts), loops 7 (24 pts), boolean chains 3 (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.
  • xai_grok_pager::app::dispatch::prompt::handle_prompt_response (cognitive 120) crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:1452 — xai_grok_pager::app::dispatch::prompt::handle_prompt_response has cognitive complexity 120 (threshold 15). Drivers by points: if/else 36 (85 pts), boolean chains 21, match/switch 5 (11 pts), loops 1 (3 pts) (nesting depth added 57). 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.
  • xai_grok_pager::views::dashboard::render::render_footer (cognitive 118) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2577 — xai_grok_pager::views::dashboard::render::render_footer has cognitive complexity 118 (threshold 15). Drivers by points: if/else 69 (108 pts), boolean chains 10 (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.
  • xai_grok_pager::views::goal_detail::render_goal_detail (cognitive 110) crates/codegen/xai-grok-pager/src/views/goal_detail.rs:405 — xai_grok_pager::views::goal_detail::render_goal_detail has cognitive complexity 110 (threshold 15). Drivers by points: if/else 59 (92 pts), loops 5 (10 pts), boolean chains 5, match/switch 1 (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.
  • xai_grok_pager::headless::run_single_turn (cognitive 105) crates/codegen/xai-grok-pager/src/headless.rs:804 — xai_grok_pager::headless::run_single_turn has cognitive complexity 105 (threshold 15). Drivers by points: if/else 39 (71 pts), match/switch 15 (23 pts), boolean chains 9, loops 1 (2 pts) (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.
  • xai_grok_pager::app::effects::helpers::persist_setting (cognitive 99) crates/codegen/xai-grok-pager/src/app/effects/helpers.rs:987 — xai_grok_pager::app::effects::helpers::persist_setting has cognitive complexity 99 (threshold 15). Drivers by points: if/else 49 (98 pts), match/switch 1 (nesting depth added 49). 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.
  • xai_grok_pager::views::picker::render_picker_row (cognitive 97) crates/codegen/xai-grok-pager/src/views/picker.rs:878 — xai_grok_pager::views::picker::render_picker_row has cognitive complexity 97 (threshold 15). Drivers by points: if/else 46 (79 pts), loops 4 (11 pts), boolean chains 6, match/switch 1 (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.
  • xai_grok_pager::views::turn_status::render_turn_status (cognitive 85) crates/codegen/xai-grok-pager/src/views/turn_status.rs:172 — xai_grok_pager::views::turn_status::render_turn_status has cognitive complexity 85 (threshold 15). Drivers by points: if/else 49 (65 pts), boolean chains 14, match/switch 4 (6 pts) (nesting depth added 18). 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.
  • xai_grok_pager::views::dashboard::peek::render_peek_panel (cognitive 81) crates/codegen/xai-grok-pager/src/views/dashboard/peek.rs:391 — xai_grok_pager::views::dashboard::peek::render_peek_panel has cognitive complexity 81 (threshold 15). Drivers by points: if/else 32 (69 pts), boolean chains 10, loops 1 (2 pts) (nesting depth added 38). 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.
  • xai_grok_pager::views::welcome::render_welcome_done (cognitive 80) crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:1709 — xai_grok_pager::views::welcome::render_welcome_done has cognitive complexity 80 (threshold 15). Drivers by points: if/else 50 (64 pts), boolean chains 14, match/switch 1 (2 pts) (nesting depth added 15). 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.
  • xai_grok_pager::views::workflows::render_detail (cognitive 74) crates/codegen/xai-grok-pager/src/views/workflows.rs:679 — xai_grok_pager::views::workflows::render_detail has cognitive complexity 74 (threshold 15). Drivers by points: if/else 50 (67 pts), loops 3, 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.
  • + 229 more in this group — see findings.md.
D1 · Cyclomatic Complexity · xai_grok_pager · ×153
  • xai_grok_pager::app::dispatch::router::dispatch_inner (cyclomatic 458) crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:165 — xai_grok_pager::app::dispatch::router::dispatch_inner has cyclomatic complexity 458 (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.
  • xai_grok_pager::app::effects::execute (cyclomatic 342) crates/codegen/xai-grok-pager/src/app/effects/mod.rs:122 — xai_grok_pager::app::effects::execute has cyclomatic complexity 342 (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.
  • xai_grok_pager::app::dispatch::task_result::dispatch_task_result (cyclomatic 313) crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs:457 — xai_grok_pager::app::dispatch::task_result::dispatch_task_result has cyclomatic complexity 313 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::app::event_loop::run (cyclomatic 264) crates/codegen/xai-grok-pager/src/app/event_loop.rs:1034 — xai_grok_pager::app::event_loop::run has cyclomatic complexity 264 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::views::picker::handle_picker_input (cyclomatic 175) crates/codegen/xai-grok-pager/src/views/picker.rs:2480 — xai_grok_pager::views::picker::handle_picker_input has cyclomatic complexity 175 (threshold 15). Of this number, 166 points are the body's own statements and 9 belong to 4 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::views::extensions_modal::render_extensions_modal (cyclomatic 172) crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2768 — xai_grok_pager::views::extensions_modal::render_extensions_modal has cyclomatic complexity 172 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::app::acp_handler::session_notification::handle_session_notification_with_origin (cyclomatic 154) crates/codegen/xai-grok-pager/src/app/acp_handler/session_notification.rs:184 — xai_grok_pager::app::acp_handler::session_notification::handle_session_notification_with_origin has cyclomatic complexity 154 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::acp::tracker::tool_call_to_block (cyclomatic 108) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1816 — xai_grok_pager::acp::tracker::tool_call_to_block has cyclomatic complexity 108 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::app::effects::helpers::persist_setting (cyclomatic 99) crates/codegen/xai-grok-pager/src/app/effects/helpers.rs:987 — xai_grok_pager::app::effects::helpers::persist_setting has cyclomatic complexity 99 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::app::dispatch::prompt::dispatch_send_prompt_submission (cyclomatic 92) crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:643 — xai_grok_pager::app::dispatch::prompt::dispatch_send_prompt_submission has cyclomatic complexity 92 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::views::agent::build_hints (cyclomatic 87) crates/codegen/xai-grok-pager/src/views/agent.rs:685 — xai_grok_pager::views::agent::build_hints has cyclomatic complexity 87 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::app::dispatch::settings::ui::apply_setting_rollback (cyclomatic 76) crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:824 — xai_grok_pager::app::dispatch::settings::ui::apply_setting_rollback has cyclomatic complexity 76 (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.
  • xai_grok_pager::app::acp_handler::handle_inner (cyclomatic 74) crates/codegen/xai-grok-pager/src/app/acp_handler/mod.rs:154 — xai_grok_pager::app::acp_handler::handle_inner has cyclomatic complexity 74 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_pager::headless::run_single_turn (cyclomatic 68) crates/codegen/xai-grok-pager/src/headless.rs:804 — xai_grok_pager::headless::run_single_turn 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.
  • xai_grok_pager::scrollback::render::render_scrolled_entries_with_selection_boundaries (cyclomatic 67) crates/codegen/xai-grok-pager/src/scrollback/render.rs:225 — xai_grok_pager::scrollback::render::render_scrolled_entries_with_selection_boundaries 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.
  • xai_grok_pager::views::goal_detail::render_goal_detail (cyclomatic 63) crates/codegen/xai-grok-pager/src/views/goal_detail.rs:405 — xai_grok_pager::views::goal_detail::render_goal_detail 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.
  • xai_grok_pager::app::dispatch::prompt::handle_prompt_response (cyclomatic 61) crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:1452 — xai_grok_pager::app::dispatch::prompt::handle_prompt_response 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.
  • xai_grok_pager::views::dashboard::render::render_footer (cyclomatic 60) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2577 — xai_grok_pager::views::dashboard::render::render_footer 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.
  • xai_grok_pager::views::agents_modal::render_personas_tab (cyclomatic 58) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1462 — xai_grok_pager::views::agents_modal::render_personas_tab 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.
  • xai_grok_pager::settings::registry::current_value_for (cyclomatic 57) crates/codegen/xai-grok-pager/src/settings/registry.rs:561 — xai_grok_pager::settings::registry::current_value_for has cyclomatic complexity 57 (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.
  • xai_grok_pager::views::turn_status::render_turn_status (cyclomatic 55) crates/codegen/xai-grok-pager/src/views/turn_status.rs:172 — xai_grok_pager::views::turn_status::render_turn_status has cyclomatic complexity 55 (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.
  • xai_grok_pager::app::run (cyclomatic 52) crates/codegen/xai-grok-pager/src/app/mod.rs:707 — xai_grok_pager::app::run 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.
  • xai_grok_pager::views::file_search::line_viewer::render_line_viewer (cyclomatic 48) crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:1440 — xai_grok_pager::views::file_search::line_viewer::render_line_viewer 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.
  • xai_grok_pager::views::shortcuts_help::handle_input (cyclomatic 48) crates/codegen/xai-grok-pager/src/views/shortcuts_help.rs:800 — xai_grok_pager::views::shortcuts_help::handle_input 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.
  • xai_grok_pager::views::welcome::render_welcome_done (cyclomatic 48) crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:1709 — xai_grok_pager::views::welcome::render_welcome_done has cyclomatic complexity 48 (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.
  • + 128 more in this group — see findings.md.
D2 · Cognitive Complexity · xai_grok_shell · ×100
  • xai_grok_shell::session::acp_session_impl::run_loop::run_session (cognitive 519) crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:354 — xai_grok_shell::session::acp_session_impl::run_loop::run_session has cognitive complexity 519 (threshold 15). Drivers by points: if/else 128 (455 pts), match/switch 14 (47 pts), boolean chains 13, loops 3 (4 pts) (nesting depth added 361). 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.
  • xai_grok_shell::leader::server::run_leader_server (cognitive 422) crates/codegen/xai-grok-shell/src/leader/server.rs:1505 — xai_grok_shell::leader::server::run_leader_server has cognitive complexity 422 (threshold 15). Drivers by points: if/else 83 (342 pts), match/switch 9 (33 pts), loops 6 (26 pts), boolean chains 21 (nesting depth added 303). 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.
  • xai_grok_shell::agent::subagent::handle_request::run_shell_child (cognitive 275) crates/codegen/xai-grok-shell/src/agent/subagent/handle_request.rs:357 — xai_grok_shell::agent::subagent::handle_request::run_shell_child has cognitive complexity 275 (threshold 15). Drivers by points: if/else 135 (197 pts), match/switch 26 (45 pts), boolean chains 26, loops 3 (7 pts) (nesting depth added 85). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_shell::session::acp_session_impl::spawn::spawn_session_actor (cognitive 224) crates/codegen/xai-grok-shell/src/session/acp_session_impl/spawn.rs:217 — xai_grok_shell::session::acp_session_impl::spawn::spawn_session_actor has cognitive complexity 224 (threshold 15). Drivers by points: if/else 114 (150 pts), match/switch 15 (32 pts), boolean chains 26, loops 8 (16 pts) (nesting depth added 61). 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.
  • xai_grok_shell::session::storage::search_content::collect_all_indexable_content_single_pass (cognitive 144) crates/codegen/xai-grok-shell/src/session/storage/search_content.rs:80 — xai_grok_shell::session::storage::search_content::collect_all_indexable_content_single_pass has cognitive complexity 144 (threshold 15). Drivers by points: if/else 26 (91 pts), loops 6 (34 pts), boolean chains 10, match/switch 4 (9 pts) (nesting depth added 98). 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.
  • xai_grok_shell::agent::relay::run_websocket_session_with_liveness (cognitive 98) crates/codegen/xai-grok-shell/src/agent/relay.rs:474 — xai_grok_shell::agent::relay::run_websocket_session_with_liveness has cognitive complexity 98 (threshold 15). Drivers by points: if/else 22 (70 pts), match/switch 8 (25 pts), loops 2, boolean chains 1 (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.
  • xai_grok_shell::session::helpers::session_compact::generate_session_compact (cognitive 87) crates/codegen/xai-grok-shell/src/session/helpers/session_compact.rs:433 — xai_grok_shell::session::helpers::session_compact::generate_session_compact has cognitive complexity 87 (threshold 15). Drivers by points: if/else 15 (47 pts), match/switch 14 (30 pts), loops 3 (6 pts), boolean chains 4 (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.
  • xai_grok_shell::tools::notification_bridge::handle_notification (cognitive 87) crates/codegen/xai-grok-shell/src/tools/notification_bridge.rs:239 — xai_grok_shell::tools::notification_bridge::handle_notification has cognitive complexity 87 (threshold 15). Drivers by points: if/else 40 (83 pts), boolean chains 3, match/switch 1 (nesting depth added 43). 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.
  • xai_grok_shell::agent::app::run_leader (cognitive 86) crates/codegen/xai-grok-shell/src/agent/app.rs:698 — xai_grok_shell::agent::app::run_leader has cognitive complexity 86 (threshold 15). Drivers by points: if/else 30 (51 pts), match/switch 10 (23 pts), loops 6 (8 pts), boolean chains 4 (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.
  • xai_grok_shell::agent::config::resolve_model_list (cognitive 81) crates/codegen/xai-grok-shell/src/agent/config.rs:2824 — xai_grok_shell::agent::config::resolve_model_list has cognitive complexity 81 (threshold 15). Drivers by points: if/else 26 (60 pts), loops 8 (10 pts), boolean chains 9, match/switch 1 (2 pts) (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_shell::extensions::mcp::handle_list (cognitive 75) crates/codegen/xai-grok-shell/src/extensions/mcp.rs:968 — xai_grok_shell::extensions::mcp::handle_list has cognitive complexity 75 (threshold 15). Drivers by points: if/else 18 (45 pts), loops 7 (18 pts), boolean chains 7, match/switch 3 (5 pts) (nesting depth added 40). 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.
  • xai_grok_shell::inspect::print_human (cognitive 59) crates/codegen/xai-grok-shell/src/inspect/mod.rs:1515 — xai_grok_shell::inspect::print_human has cognitive complexity 59 (threshold 15). Drivers by points: if/else 31 (34 pts), loops 9 (16 pts), match/switch 5 (8 pts), boolean chains 1 (nesting depth added 13). 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.
  • xai_grok_shell::leader::connect_or_spawn (cognitive 59) crates/codegen/xai-grok-shell/src/leader/mod.rs:1376 — xai_grok_shell::leader::connect_or_spawn has cognitive complexity 59 (threshold 15). Drivers by points: if/else 16 (44 pts), match/switch 5 (13 pts), boolean chains 1, loops 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.
  • xai_grok_shell::session::memory::capture_transcript::condense_turn_transcript (cognitive 55) crates/codegen/xai-grok-shell/src/session/memory/capture_transcript.rs:101 — xai_grok_shell::session::memory::capture_transcript::condense_turn_transcript has cognitive complexity 55 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 9 (17 pts), boolean chains 3, match/switch 1 (3 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.
  • xai_grok_shell::session::storage::collect_assistant_text (cognitive 55) crates/codegen/xai-grok-shell/src/session/storage/mod.rs:1907 — xai_grok_shell::session::storage::collect_assistant_text has cognitive complexity 55 (threshold 15). Drivers by points: if/else 11 (39 pts), loops 2 (7 pts), match/switch 3 (7 pts), boolean chains 2 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_shell::session::goal_classifier::evidence::walkdir_changes_blocking (cognitive 51) crates/codegen/xai-grok-shell/src/session/goal_classifier/evidence.rs:654 — xai_grok_shell::session::goal_classifier::evidence::walkdir_changes_blocking has cognitive complexity 51 (threshold 15). Drivers by points: if/else 18 (36 pts), boolean chains 6, match/switch 3 (6 pts), 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.
  • xai_grok_shell::config::apply_requirements_inner (cognitive 50) crates/codegen/xai-grok-shell/src/config/mod.rs:1075 — xai_grok_shell::config::apply_requirements_inner has cognitive complexity 50 (threshold 15). Drivers by points: if/else 26 (38 pts), match/switch 3 (6 pts), boolean chains 4, loops 2 (nesting depth added 15). Of this number, 49 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_shell::session::acp_conversion::acp_tool_update (cognitive 49) crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:116 — xai_grok_shell::session::acp_conversion::acp_tool_update has cognitive complexity 49 (threshold 15). Drivers by points: match/switch 16 (31 pts), if/else 11 (16 pts), boolean chains 2 (nesting depth added 20). 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.
  • xai_grok_shell::relay::sync::relay_sync_task (cognitive 46) crates/codegen/xai-grok-shell/src/relay/sync.rs:305 — xai_grok_shell::relay::sync::relay_sync_task has cognitive complexity 46 (threshold 15). Drivers by points: if/else 9 (32 pts), match/switch 3 (8 pts), loops 2 (5 pts), boolean chains 1 (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.
  • xai_grok_shell::agent::server::handle_connection (cognitive 43) crates/codegen/xai-grok-shell/src/agent/server.rs:338 — xai_grok_shell::agent::server::handle_connection has cognitive complexity 43 (threshold 15). Drivers by points: if/else 11 (32 pts), match/switch 4 (6 pts), boolean chains 3, loops 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.
  • xai_grok_shell::agent::relay::run_relay_loop (cognitive 39) crates/codegen/xai-grok-shell/src/agent/relay.rs:246 — xai_grok_shell::agent::relay::run_relay_loop has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (31 pts), match/switch 3 (7 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.
  • xai_grok_shell::session::mcp_dispatcher::run_dispatcher (cognitive 39) crates/codegen/xai-grok-shell/src/session/mcp_dispatcher.rs:489 — xai_grok_shell::session::mcp_dispatcher::run_dispatcher has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 5 (12 pts), match/switch 1 (3 pts), 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.
  • xai_grok_shell::session::two_pass::snap_split_idx_to_tool_boundaries (cognitive 39) crates/codegen/xai-grok-shell/src/session/two_pass.rs:52 — xai_grok_shell::session::two_pass::snap_split_idx_to_tool_boundaries has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 11, loops 6 (11 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.
  • xai_grok_shell::extensions::skills::handle (cognitive 36) crates/codegen/xai-grok-shell/src/extensions/skills.rs:359 — xai_grok_shell::extensions::skills::handle has cognitive complexity 36 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 3 (8 pts), boolean chains 1, match/switch 1 (nesting depth added 17). 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.
  • xai_grok_shell::agent::subagent::attempt_store::decoder::key_is_c (cognitive 35) crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/decoder.rs:369 — xai_grok_shell::agent::subagent::attempt_store::decoder::key_is_c has cognitive complexity 35 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 4 (14 pts), loops 2 (5 pts), boolean chains 2 (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.
  • + 75 more in this group — see findings.md.
D17 · Explicit Debt · TodoComment · ×95
  • TodoComment crates/common/xai-tracing/src/fastrace.rs:54 — // Tonic channel (TODO: Move into grpc_client when deprecated tracing) — 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 crates/common/xai-tracing/src/fastrace.rs:66 — // Request middleware (TODO: Move into http_client when deprecated tracing) — 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 crates/common/xai-grok-compaction/src/reminder.rs:13 — //! live workflows), TODO List, and Running Subagents — plus — 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 crates/common/xai-grok-compaction/src/reminder.rs:344 — /// → TODO → Running Subagents. — 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 crates/codegen/xai-hunk-tracker/src/actor/mod.rs:657 — // TODO: Re-emit HunkEvent::FileAdded / HunkEvent::HunkAdded for all restored files and hunks so that connected clients — 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 crates/codegen/xai-grok-workspace-types/src/identity.rs:76 — /// TODO: align with `xai_hunk_tracker::HunkId` when that wire surface moves here. — 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 crates/codegen/xai-grok-workspace-types/src/lib.rs:46 — //! # TODO: proto generation — 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 crates/codegen/xai-grok-workspace-types/src/types/config.rs:3 — //! TODO: align with the canonical project / permission / — 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 crates/codegen/xai-grok-workspace-types/src/types/config.rs:39 — /// TODO: align with the MCP/tool-server config in `xai-grok-tools` once the wire surface is firm. — 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 crates/codegen/xai-grok-workspace-types/src/types/config.rs:83 — /// TODO: align with `xai_grok_config::ProjectConfig`. — 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 crates/codegen/xai-grok-workspace-types/src/types/config.rs:95 — /// TODO: align with the canonical permission policy type (currently free-form JSON). — 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 crates/codegen/xai-grok-workspace-types/src/types/files.rs:3 — //! TODO(workspace): align with the canonical resolution result 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 crates/codegen/xai-grok-workspace-types/src/types/git.rs:3 — //! TODO: align with the canonical git types in — 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 crates/codegen/xai-grok-workspace-types/src/types/git.rs:9 — /// TODO: align with `xai_grok_shell::session::git::VcsKind`. — 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 crates/codegen/xai-grok-workspace-types/src/types/git.rs:32 — /// TODO: align with `GitStatusData` in `xai_grok_shell::session::git`. — 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 crates/codegen/xai-grok-workspace-types/src/types/git.rs:76 — /// TODO: align with `GitDiffsData` in `xai_grok_shell::session::git`. — 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 crates/codegen/xai-grok-workspace-types/src/types/hunk.rs:3 — //! TODO: align with `xai_hunk_tracker::Hunk` and — 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 crates/codegen/xai-grok-workspace-types/src/types/hunk.rs:14 — /// TODO: align with `xai_hunk_tracker::types::Hunk`. — 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 crates/codegen/xai-grok-workspace-types/src/types/hunk.rs:37 — /// TODO: align with `xai_hunk_tracker::types::HunkAction`. Adjacent tagging matches every other wire enum. — 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 crates/codegen/xai-grok-workspace-types/src/types/interaction.rs:8 — //! TODO(workspace): align with the canonical question/answer types in — 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 crates/codegen/xai-grok-workspace-types/src/types/memory.rs:3 — //! TODO(workspace): align with the canonical memory types (`MemoryChunk`, — 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 crates/codegen/xai-grok-workspace-types/src/types/permission.rs:6 — //! TODO(workspace): align with the canonical permission types in — 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 crates/codegen/xai-grok-workspace-types/src/types/plugins.rs:4 — //! TODO: align with the canonical types in — 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 crates/codegen/xai-grok-workspace-types/src/types/plugins.rs:38 — /// TODO: free-form string until aligned with `HookEvent`; typos currently pass. — 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 crates/codegen/xai-grok-workspace-types/src/types/search.rs:3 — //! TODO(workspace): align with the canonical ripgrep / fuzzy types in — 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.
  • + 70 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×72
  • Duplicated block (9 lines × 2) crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:67 — crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:67-75 | crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:77-85 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:166 — crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:166-174 | crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:214-222 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1001 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1001-1009 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1030-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 (9 lines × 2) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1239 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1239-1247 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1262-1270 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1493 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1493-1501 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1513-1521 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/queue.rs:2205 — crates/codegen/xai-file-utils/src/queue.rs:2205-2213 | crates/codegen/xai-file-utils/src/queue.rs:2295-2303 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/storage_client.rs:1085 — crates/codegen/xai-file-utils/src/storage_client.rs:1085-1093 | crates/codegen/xai-file-utils/src/storage_client.rs:1196-1204 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/config.rs:296 — crates/codegen/xai-grok-agent/src/config.rs:296-304 | crates/codegen/xai-grok-agent/src/config.rs:474-482 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-bundle/src/lib.rs:167 — crates/codegen/xai-grok-bundle/src/lib.rs:167-175 | crates/codegen/xai-grok-bundle/src/lib.rs:275-283 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-http/src/lib.rs:321 — crates/codegen/xai-grok-http/src/lib.rs:321-329 | crates/codegen/xai-grok-sampler/src/shared_http/mtls.rs:189-197 — 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) crates/codegen/xai-grok-login/src/manager.rs:896 — crates/codegen/xai-grok-login/src/manager.rs:896-904 | crates/codegen/xai-grok-login/src/manager.rs:942-950 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/mermaid.rs:767 — crates/codegen/xai-grok-markdown/src/mermaid.rs:767-775 | crates/codegen/xai-grok-markdown/src/mermaid.rs:981-989 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/mermaid.rs:2929 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2929-2937 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3716-3724 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/render.rs:456 — crates/codegen/xai-grok-markdown/src/render.rs:456-465 | crates/codegen/xai-grok-markdown/src/render.rs:484-492 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-mcp/src/servers.rs:3323 — crates/codegen/xai-grok-mcp/src/servers.rs:3323-3331 | crates/codegen/xai-grok-mcp/src/servers.rs:3372-3380 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-minimal/src/panel.rs:434 — crates/codegen/xai-grok-pager-minimal/src/panel.rs:434-442 | crates/codegen/xai-grok-pager-minimal/src/panel.rs:446-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 (9 lines × 2) crates/codegen/xai-grok-pager-pty-harness/src/lib.rs:381 — crates/codegen/xai-grok-pager-pty-harness/src/lib.rs:381-389 | crates/codegen/xai-grok-pager-pty-harness/src/lib.rs:427-435 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-render/src/render/gboom_overlay.rs:29 — crates/codegen/xai-grok-pager-render/src/render/gboom_overlay.rs:29-37 | crates/codegen/xai-grok-pager-render/src/render/video_overlay.rs:28-36 — 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 × 2) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:966 — crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:966-974 | crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1369-1377 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/notices.rs:326 — crates/codegen/xai-grok-pager/src/app/agent_view/notices.rs:326-334 | crates/codegen/xai-grok-pager/src/app/agent_view/notices.rs:346-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 (9 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:901 — crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:901-909 | crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:1001-1009 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3573 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3573-3581 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3616-3624 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:119 — crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:119-127 | crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:267-275 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:2133 — crates/codegen/xai-grok-pager/src/app/app_view.rs:2133-2141 | crates/codegen/xai-grok-pager/src/app/app_view.rs:2162-2170 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:2177 — crates/codegen/xai-grok-pager/src/app/app_view.rs:2177-2185 | crates/codegen/xai-grok-pager/src/app/app_view.rs:2195-2203 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 47 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×67
  • Duplicated block (8 lines × 2) crates/codegen/xai-codebase-graph/src/navigation.rs:223 — crates/codegen/xai-codebase-graph/src/navigation.rs:223-231 | crates/codegen/xai-codebase-graph/src/navigation.rs:280-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.
  • Duplicated block (8 lines × 2) crates/codegen/xai-crash-handler/src/handler.rs:367 — crates/codegen/xai-crash-handler/src/handler.rs:367-374 | crates/codegen/xai-crash-handler/src/handler.rs:669-676 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/api/gc.rs:546 — crates/codegen/xai-fast-worktree/src/api/gc.rs:546-553 | crates/codegen/xai-fast-worktree/src/api/gc.rs:569-577 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:155 — crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:155-162 | crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:279-286 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/bin/worktree_lifecycle_bench/runtime.rs:423 — crates/codegen/xai-fast-worktree/src/bin/worktree_lifecycle_bench/runtime.rs:423-430 | crates/codegen/xai-fast-worktree/src/bin/worktree_lifecycle_bench/runtime.rs:456-463 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/queue.rs:709 — crates/codegen/xai-file-utils/src/queue.rs:709-716 | crates/codegen/xai-file-utils/src/queue.rs:866-873 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/queue.rs:856 — crates/codegen/xai-file-utils/src/queue.rs:856-863 | crates/codegen/xai-file-utils/src/queue.rs:1034-1041 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/storage_client.rs:1076 — crates/codegen/xai-file-utils/src/storage_client.rs:1076-1083 | crates/codegen/xai-file-utils/src/storage_client.rs:1187-1194 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-config/src/fs_atomic.rs:1429 — crates/codegen/xai-grok-config/src/fs_atomic.rs:1429-1436 | crates/codegen/xai-grok-config/src/managed_text/transaction.rs:251-258 — 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 (8 lines × 2) crates/codegen/xai-grok-memory/src/batch_dream_io.rs:16 — crates/codegen/xai-grok-memory/src/batch_dream_io.rs:16-23 | crates/codegen/xai-grok-memory/src/batch_dream_io.rs:163-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 (8 lines × 2) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1038 — crates/codegen/xai-grok-pager/src/acp/tracker.rs:1038-1045 | crates/codegen/xai-grok-pager/src/acp/tracker.rs:1503-1510 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:893 — crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:893-900 | crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:993-1000 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3287 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3287-3294 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3853-3860 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:171 — crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:171-178 | crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:223-230 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/cta.rs:450 — crates/codegen/xai-grok-pager/src/app/dispatch/cta.rs:450-459 | crates/codegen/xai-grok-pager/src/app/dispatch/cta.rs:506-513 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2343 — crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2343-2350 | crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2456-2463 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2367 — crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2367-2374 | crates/codegen/xai-grok-pager/src/app/dispatch/permissions.rs:155-164 — 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 (8 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/import_claude.rs:14 — crates/codegen/xai-grok-pager/src/app/dispatch/import_claude.rs:14-21 | crates/codegen/xai-grok-pager/src/app/dispatch/import_claude.rs:75-82 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:403 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:403-410 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1548-1555 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 74 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 (8 lines × 2) crates/codegen/xai-grok-pager/src/plugin_cmd.rs:870 — crates/codegen/xai-grok-pager/src/plugin_cmd.rs:870-877 | crates/codegen/xai-grok-shell/src/extensions/marketplace.rs:692-699 — 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 (8 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/state/selection.rs:119 — crates/codegen/xai-grok-pager/src/scrollback/state/selection.rs:119-126 | crates/codegen/xai-grok-pager/src/scrollback/state/selection.rs:162-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 (8 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2008 — crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2008-2015 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2030-2037 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3422 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3422-3429 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3710-3717 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3436 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3436-3443 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3617-3624 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3451 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3451-3458 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3678-3685 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 42 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×58
  • Duplicated block (6 lines × 2) crates/codegen/xai-acp-lib/src/gateway.rs:171 — crates/codegen/xai-acp-lib/src/gateway.rs:171-176 | crates/codegen/xai-acp-lib/src/gateway.rs:233-238 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1030 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1030-1035 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1041-1046 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1084 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1084-1089 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1097-1102 — both copies are in the same file, so extract the 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) crates/codegen/xai-crash-handler/src/handler.rs:660 — crates/codegen/xai-crash-handler/src/handler.rs:660-665 | crates/codegen/xai-crash-handler/src/handler.rs:676-681 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/storage_client.rs:608 — crates/codegen/xai-file-utils/src/storage_client.rs:608-614 | crates/codegen/xai-file-utils/src/storage_client.rs:659-664 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-config/src/compat.rs:254 — crates/codegen/xai-grok-config/src/compat.rs:254-259 | crates/codegen/xai-grok-config/src/compat.rs:373-378 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-config/src/managed_text/format.rs:207 — crates/codegen/xai-grok-config/src/managed_text/format.rs:207-212 | crates/codegen/xai-grok-config/src/managed_text/format.rs:221-226 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-egress-proxy/src/http.rs:187 — crates/codegen/xai-grok-egress-proxy/src/http.rs:187-192 | crates/codegen/xai-grok-egress-proxy/src/request.rs:50-55 — 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) crates/codegen/xai-grok-gboom/src/assets.rs:132 — crates/codegen/xai-grok-gboom/src/assets.rs:132-137 | crates/codegen/xai-grok-gboom/src/assets.rs:187-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 (6 lines × 2) crates/codegen/xai-grok-markdown/src/colors.rs:256 — crates/codegen/xai-grok-markdown/src/colors.rs:256-261 | crates/codegen/xai-grok-pager-render/src/render/color.rs:13-19 — 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) crates/codegen/xai-grok-memory/src/index.rs:463 — crates/codegen/xai-grok-memory/src/index.rs:463-468 | crates/codegen/xai-grok-memory/src/index.rs:484-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 (6 lines × 2) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:484 — crates/codegen/xai-grok-pager-render/src/render/bidi.rs:484-489 | crates/codegen/xai-grok-pager-render/src/render/bidi.rs:513-518 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:389 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:389-395 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:400-405 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3314 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3314-3319 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3328-3333 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:1853 — crates/codegen/xai-grok-pager/src/app/app_view.rs:1853-1858 | crates/codegen/xai-grok-pager/src/app/app_view.rs:2131-2136 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:3774 — crates/codegen/xai-grok-pager/src/app/app_view.rs:3774-3779 | crates/codegen/xai-grok-pager/src/app/app_view.rs:3895-3900 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:293 — crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:293-298 | crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:425-430 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:326 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:326-331 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:484-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 (6 lines × 2) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:2468 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:2468-2473 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:2497-2502 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/block_viewer/selection.rs:368 — crates/codegen/xai-grok-pager/src/views/block_viewer/selection.rs:368-373 | crates/codegen/xai-grok-pager/src/views/block_viewer/selection.rs:543-548 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2655 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2655-2660 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2666-2671 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3404 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3404-3409 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3584-3589 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3425 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3425-3430 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3439-3444 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/modal_window.rs:458 — crates/codegen/xai-grok-pager/src/views/modal_window.rs:458-463 | crates/codegen/xai-grok-pager/src/views/modal_window.rs:640-645 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/tutorial.rs:180 — crates/codegen/xai-grok-pager/src/views/tutorial.rs:180-185 | crates/codegen/xai-grok-pager/src/views/tutorial.rs:244-249 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 33 more in this group — see findings.md.
D2 · Cognitive Complexity · AgentView · ×55
  • AgentView::draw (cognitive 1121) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:562 — AgentView::draw has cognitive complexity 1121 (threshold 15). Drivers by points: if/else 470 (887 pts), boolean chains 113, loops 27 (83 pts), match/switch 16 (38 pts) (nesting depth added 495). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • AgentView::handle_mouse (cognitive 526) crates/codegen/xai-grok-pager/src/app/mouse.rs:30 — AgentView::handle_mouse has cognitive complexity 526 (threshold 15). Drivers by points: if/else 168 (443 pts), boolean chains 56, match/switch 7 (24 pts), loops 1 (3 pts) (nesting depth added 294). 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.
  • AgentView::handle_input_inner (cognitive 362) crates/codegen/xai-grok-pager/src/app/agent_view/input.rs:328 — AgentView::handle_input_inner has cognitive complexity 362 (threshold 15). Drivers by points: if/else 125 (252 pts), match/switch 29 (64 pts), boolean chains 41, loops 1 (5 pts) (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.
  • AgentView::execute_modal_button_action (cognitive 244) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1681 — AgentView::execute_modal_button_action has cognitive complexity 244 (threshold 15). Drivers by points: if/else 82 (217 pts), match/switch 6 (17 pts), boolean chains 10 (nesting depth added 146). 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.
  • AgentView::handle_prompt_key (cognitive 196) crates/codegen/xai-grok-pager/src/app/agent_view/prompt.rs:91 — AgentView::handle_prompt_key has cognitive complexity 196 (threshold 15). Drivers by points: if/else 69 (149 pts), boolean chains 30, match/switch 8 (17 pts) (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.
  • AgentView::handle_line_viewer_mouse (cognitive 172) crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:387 — AgentView::handle_line_viewer_mouse has cognitive complexity 172 (threshold 15). Drivers by points: if/else 66 (156 pts), boolean chains 14, match/switch 2 (nesting depth added 90). 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.
  • AgentView::handle_palette_or_arg_input_with_registry (cognitive 126) crates/codegen/xai-grok-pager/src/app/modals.rs:701 — AgentView::handle_palette_or_arg_input_with_registry has cognitive complexity 126 (threshold 15). Drivers by points: if/else 33 (90 pts), match/switch 10 (24 pts), boolean chains 12 (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.
  • AgentView::draw_active_modal (cognitive 125) crates/codegen/xai-grok-pager/src/app/modals.rs:1684 — AgentView::draw_active_modal has cognitive complexity 125 (threshold 15). Drivers by points: if/else 45 (108 pts), boolean chains 10, loops 1 (4 pts), match/switch 1 (3 pts) (nesting depth added 68). 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.
  • AgentView::handle_question_key (cognitive 110) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:333 — AgentView::handle_question_key has cognitive complexity 110 (threshold 15). Drivers by points: if/else 34 (89 pts), match/switch 5 (11 pts), boolean chains 10 (nesting depth added 61). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • AgentView::handle_question_mouse (cognitive 104) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:583 — AgentView::handle_question_mouse has cognitive complexity 104 (threshold 15). Drivers by points: if/else 36 (93 pts), boolean chains 8, loops 1 (2 pts), match/switch 1 (nesting depth added 58). 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.
  • AgentView::handle_permission_key (cognitive 94) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:30 — AgentView::handle_permission_key has cognitive complexity 94 (threshold 15). Drivers by points: if/else 31 (71 pts), boolean chains 16, match/switch 4 (7 pts) (nesting depth added 43). 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.
  • AgentView::handle_line_viewer_key (cognitive 91) crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:79 — AgentView::handle_line_viewer_key has cognitive complexity 91 (threshold 15). Drivers by points: if/else 43 (77 pts), boolean chains 14 (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.
  • AgentView::handle_workflows_overlay_input (cognitive 76) crates/codegen/xai-grok-pager/src/app/agent_view/workflows_overlay.rs:80 — AgentView::handle_workflows_overlay_input has cognitive complexity 76 (threshold 15). Drivers by points: if/else 17 (49 pts), match/switch 6 (22 pts), boolean chains 5 (nesting depth added 48). 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.
  • AgentView::handle_modal_key_with_registry (cognitive 70) crates/codegen/xai-grok-pager/src/app/modals.rs:106 — AgentView::handle_modal_key_with_registry has cognitive complexity 70 (threshold 15). Drivers by points: if/else 22 (37 pts), match/switch 14 (29 pts), boolean chains 4 (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.
  • AgentView::handle_scroll (cognitive 69) crates/codegen/xai-grok-pager/src/app/agent_view/panes.rs:1102 — AgentView::handle_scroll has cognitive complexity 69 (threshold 15). Drivers by points: if/else 36 (54 pts), boolean chains 10, match/switch 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.
  • AgentView::handle_modal_mouse_with_registry (cognitive 62) crates/codegen/xai-grok-pager/src/app/modals.rs:1358 — AgentView::handle_modal_mouse_with_registry has cognitive complexity 62 (threshold 15). Drivers by points: if/else 19 (42 pts), match/switch 8 (18 pts), loops 1 (2 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • AgentView::handle_queue_key (cognitive 60) crates/codegen/xai-grok-pager/src/app/agent_view/queue.rs:517 — AgentView::handle_queue_key has cognitive complexity 60 (threshold 15). Drivers by points: if/else 22 (53 pts), boolean chains 5, match/switch 1 (2 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.
  • AgentView::handle_extensions_modal_key (cognitive 58) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:634 — AgentView::handle_extensions_modal_key has cognitive complexity 58 (threshold 15). Drivers by points: if/else 28 (43 pts), match/switch 6 (9 pts), boolean chains 6 (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.
  • AgentView::handle_plan_feedback_key (cognitive 58) crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:741 — AgentView::handle_plan_feedback_key has cognitive complexity 58 (threshold 15). Drivers by points: if/else 23 (50 pts), boolean chains 4, match/switch 3 (4 pts) (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.
  • AgentView::handle_elicitation_key (cognitive 51) crates/codegen/xai-grok-pager/src/app/agent_view/elicitation.rs:22 — AgentView::handle_elicitation_key has cognitive complexity 51 (threshold 15). Drivers by points: if/else 19 (31 pts), match/switch 7 (15 pts), boolean chains 5 (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.
  • AgentView::handle_bg_tasks_key (cognitive 48) crates/codegen/xai-grok-pager/src/app/agent_view/panes.rs:965 — AgentView::handle_bg_tasks_key has cognitive complexity 48 (threshold 15). Drivers by points: if/else 21 (36 pts), boolean chains 8, match/switch 2 (4 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.
  • AgentView::extensions_action_target (cognitive 44) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:480 — AgentView::extensions_action_target has cognitive complexity 44 (threshold 15). Drivers by points: if/else 20 (33 pts), boolean chains 10, match/switch 1 (nesting depth added 13). 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.
  • AgentView::handle_extensions_modal_mouse_with_copy (cognitive 42) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1156 — AgentView::handle_extensions_modal_mouse_with_copy has cognitive complexity 42 (threshold 15). Drivers by points: if/else 23 (34 pts), match/switch 5, boolean chains 3 (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.
  • AgentView::normal_pane_hints (cognitive 41) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:340 — AgentView::normal_pane_hints has cognitive complexity 41 (threshold 15). Drivers by points: if/else 23 (30 pts), boolean chains 11 (nesting depth added 7). 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.
  • AgentView::extensions_modal_set_collapsed (cognitive 38) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1594 — AgentView::extensions_modal_set_collapsed has cognitive complexity 38 (threshold 15). Drivers by points: if/else 23 (37 pts), match/switch 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.
  • + 30 more in this group — see findings.md.
D1 · Cyclomatic Complexity · xai_grok_shell · ×53
  • xai_grok_shell::session::acp_session_impl::run_loop::run_session (cyclomatic 250) crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:354 — xai_grok_shell::session::acp_session_impl::run_loop::run_session has cyclomatic complexity 250 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_shell::agent::subagent::handle_request::run_shell_child (cyclomatic 170) crates/codegen/xai-grok-shell/src/agent/subagent/handle_request.rs:357 — xai_grok_shell::agent::subagent::handle_request::run_shell_child has cyclomatic complexity 170 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_shell::session::acp_session_impl::spawn::spawn_session_actor (cyclomatic 142) crates/codegen/xai-grok-shell/src/session/acp_session_impl/spawn.rs:217 — xai_grok_shell::session::acp_session_impl::spawn::spawn_session_actor has cyclomatic complexity 142 (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.
  • xai_grok_shell::leader::server::run_leader_server (cyclomatic 128) crates/codegen/xai-grok-shell/src/leader/server.rs:1505 — xai_grok_shell::leader::server::run_leader_server has cyclomatic complexity 128 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_shell::agent::app::run_leader (cyclomatic 62) crates/codegen/xai-grok-shell/src/agent/app.rs:698 — xai_grok_shell::agent::app::run_leader 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.
  • xai_grok_shell::session::acp_conversion::acp_tool_update (cyclomatic 52) crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:116 — xai_grok_shell::session::acp_conversion::acp_tool_update has cyclomatic complexity 52 (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.
  • xai_grok_shell::tools::notification_bridge::handle_notification (cyclomatic 52) crates/codegen/xai-grok-shell/src/tools/notification_bridge.rs:239 — xai_grok_shell::tools::notification_bridge::handle_notification 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.
  • xai_grok_shell::inspect::print_human (cyclomatic 48) crates/codegen/xai-grok-shell/src/inspect/mod.rs:1515 — xai_grok_shell::inspect::print_human has cyclomatic complexity 48 (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.
  • xai_grok_shell::session::storage::search_content::collect_all_indexable_content_single_pass (cyclomatic 46) crates/codegen/xai-grok-shell/src/session/storage/search_content.rs:80 — xai_grok_shell::session::storage::search_content::collect_all_indexable_content_single_pass 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.
  • xai_grok_shell::agent::config::resolve_model_list (cyclomatic 44) crates/codegen/xai-grok-shell/src/agent/config.rs:2824 — xai_grok_shell::agent::config::resolve_model_list 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.
  • xai_grok_shell::session::helpers::session_compact::generate_session_compact (cyclomatic 44) crates/codegen/xai-grok-shell/src/session/helpers/session_compact.rs:433 — xai_grok_shell::session::helpers::session_compact::generate_session_compact 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.
  • xai_grok_shell::config::apply_requirements_inner (cyclomatic 43) crates/codegen/xai-grok-shell/src/config/mod.rs:1075 — xai_grok_shell::config::apply_requirements_inner has cyclomatic complexity 43 (threshold 15). Of this number, 42 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_shell::agent::relay::run_websocket_session_with_liveness (cyclomatic 37) crates/codegen/xai-grok-shell/src/agent/relay.rs:474 — xai_grok_shell::agent::relay::run_websocket_session_with_liveness 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.
  • xai_grok_shell::extensions::mcp::handle_list (cyclomatic 36) crates/codegen/xai-grok-shell/src/extensions/mcp.rs:968 — xai_grok_shell::extensions::mcp::handle_list 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.
  • xai_grok_shell::extensions::worktree::handle (cyclomatic 33) crates/codegen/xai-grok-shell/src/extensions/worktree.rs:169 — xai_grok_shell::extensions::worktree::handle has cyclomatic complexity 33 (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.
  • xai_grok_shell::session::goal_classifier::evidence::walkdir_changes_blocking (cyclomatic 30) crates/codegen/xai-grok-shell/src/session/goal_classifier/evidence.rs:654 — xai_grok_shell::session::goal_classifier::evidence::walkdir_changes_blocking 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.
  • xai_grok_shell::session::two_pass::snap_split_idx_to_tool_boundaries (cyclomatic 28) crates/codegen/xai-grok-shell/src/session/two_pass.rs:52 — xai_grok_shell::session::two_pass::snap_split_idx_to_tool_boundaries has cyclomatic complexity 28 (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.
  • xai_grok_shell::extensions::hunk_tracker::handle (cyclomatic 27) crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:296 — xai_grok_shell::extensions::hunk_tracker::handle has cyclomatic complexity 27 (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.
  • xai_grok_shell::leader::connect_or_spawn (cyclomatic 27) crates/codegen/xai-grok-shell/src/leader/mod.rs:1376 — xai_grok_shell::leader::connect_or_spawn 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.
  • xai_grok_shell::session::memory::capture_transcript::condense_turn_transcript (cyclomatic 27) crates/codegen/xai-grok-shell/src/session/memory/capture_transcript.rs:101 — xai_grok_shell::session::memory::capture_transcript::condense_turn_transcript 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.
  • xai_grok_shell::agent::server::handle_connection (cyclomatic 25) crates/codegen/xai-grok-shell/src/agent/server.rs:338 — xai_grok_shell::agent::server::handle_connection 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.
  • xai_grok_shell::extensions::git::handle (cyclomatic 25) crates/codegen/xai-grok-shell/src/extensions/git.rs:275 — xai_grok_shell::extensions::git::handle 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.
  • xai_grok_shell::extensions::skills::handle (cyclomatic 25) crates/codegen/xai-grok-shell/src/extensions/skills.rs:359 — xai_grok_shell::extensions::skills::handle 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.
  • xai_grok_shell::session::acp_session_impl::mcp_argument_coercion::walk (cyclomatic 23) crates/codegen/xai-grok-shell/src/session/acp_session_impl/mcp_argument_coercion.rs:234 — xai_grok_shell::session::acp_session_impl::mcp_argument_coercion::walk 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.
  • xai_grok_shell::agent::subagent::attempt_store::decoder::key_is_c (cyclomatic 22) crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/decoder.rs:369 — xai_grok_shell::agent::subagent::attempt_store::decoder::key_is_c 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.
  • + 28 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×51
  • Duplicated block (11 lines × 2) crates/codegen/xai-crash-handler/src/handler.rs:462 — crates/codegen/xai-crash-handler/src/handler.rs:462-472 | crates/codegen/xai-crash-handler/src/handler.rs:789-799 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/auto_gc.rs:161 — crates/codegen/xai-fast-worktree/src/auto_gc.rs:161-171 | crates/codegen/xai-fast-worktree/src/auto_gc.rs:176-186 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/storage_client.rs:770 — crates/codegen/xai-file-utils/src/storage_client.rs:770-780 | crates/codegen/xai-file-utils/src/storage_client.rs:887-897 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-gboom/src/engine.rs:284 — crates/codegen/xai-grok-gboom/src/engine.rs:284-294 | crates/codegen/xai-grok-gboom/src/game.rs:120-130 — 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 (11 lines × 2) crates/codegen/xai-grok-hooks/src/runner/command.rs:604 — crates/codegen/xai-grok-hooks/src/runner/command.rs:604-614 | crates/codegen/xai-grok-hooks/src/runner/command.rs:646-656 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/mermaid.rs:2358 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2358-2368 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2531-2541 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/mermaid.rs:2408 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2408-2418 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2585-2595 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/parse.rs:338 — crates/codegen/xai-grok-markdown/src/parse.rs:338-348 | crates/codegen/xai-grok-markdown/src/parse.rs:350-360 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-memory/src/v2_capture.rs:641 — crates/codegen/xai-grok-memory/src/v2_capture.rs:641-651 | crates/codegen/xai-grok-memory/src/v2_capture.rs:664-674 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-bin/src/main.rs:1259 — crates/codegen/xai-grok-pager-bin/src/main.rs:1259-1269 | crates/codegen/xai-grok-pager/src/app/mod.rs:748-758 — 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 (11 lines × 2) crates/codegen/xai-grok-pager-render/src/render/gboom_overlay.rs:40 — crates/codegen/xai-grok-pager-render/src/render/gboom_overlay.rs:40-50 | crates/codegen/xai-grok-pager-render/src/render/video_overlay.rs:39-49 — 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 (11 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:374 — crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:374-384 | crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:851-861 — 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 (11 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:885 — crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:885-896 | crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:924-934 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:4171 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:4171-4181 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:4191-4201 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:2602 — crates/codegen/xai-grok-pager/src/app/app_view.rs:2602-2612 | crates/codegen/xai-grok-pager/src/app/app_view.rs:2736-2746 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:5065 — crates/codegen/xai-grok-pager/src/app/app_view.rs:5065-5075 | crates/codegen/xai-grok-pager/src/app/app_view.rs:5112-5122 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:429 — crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:429-439 | crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:500-510 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:371 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:371-381 | crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:452-462 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:216 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:216-226 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1144-1154 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/effects/helpers.rs:836 — crates/codegen/xai-grok-pager/src/app/effects/helpers.rs:836-846 | crates/codegen/xai-grok-pager/src/app/effects/helpers.rs:922-932 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/effects/mod.rs:3401 — crates/codegen/xai-grok-pager/src/app/effects/mod.rs:3401-3411 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:3460-3470 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/headless.rs:539 — crates/codegen/xai-grok-pager/src/headless.rs:539-549 | crates/codegen/xai-grok-pager/src/headless.rs:565-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.
  • Duplicated block (11 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs:95 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs:95-105 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:156-166 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 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 (11 lines × 2) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1287 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1287-1297 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1498-1508 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/modal.rs:938 — crates/codegen/xai-grok-pager/src/views/modal.rs:938-948 | crates/codegen/xai-grok-pager/src/views/permission_view.rs:1454-1464 — 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.
  • + 26 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×48
  • Duplicated block (5 lines × 2) crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:16 — crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:16-20 | crates/codegen/xai-codebase-graph/src/bin/bench_index.rs:16-20 — 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:998 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:998-1002 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1124-1128 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1009 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1009-1013 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1139-1143 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1392 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1392-1396 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1403-1407 — both copies are in the same file, so extract the 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) crates/codegen/xai-crash-handler/src/handler.rs:358 — crates/codegen/xai-crash-handler/src/handler.rs:358-362 | crates/codegen/xai-crash-handler/src/handler.rs:375-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 (5 lines × 2) crates/codegen/xai-file-utils/src/queue.rs:713 — crates/codegen/xai-file-utils/src/queue.rs:713-717 | crates/codegen/xai-file-utils/src/queue.rs:799-803 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/storage_client.rs:734 — crates/codegen/xai-file-utils/src/storage_client.rs:734-738 | crates/codegen/xai-file-utils/src/storage_client.rs:870-874 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/plugins/registry.rs:454 — crates/codegen/xai-grok-agent/src/plugins/registry.rs:454-458 | crates/codegen/xai-grok-agent/src/plugins/registry.rs:466-470 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-config/src/endpoints.rs:265 — crates/codegen/xai-grok-config/src/endpoints.rs:265-269 | crates/codegen/xai-grok-telemetry/src/external/config.rs:226-230 — 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) crates/codegen/xai-grok-login/src/oidc/protocol.rs:512 — crates/codegen/xai-grok-login/src/oidc/protocol.rs:512-516 | crates/codegen/xai-grok-shell/src/extensions/consent.rs:73-78 — 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) crates/codegen/xai-grok-markdown/src/latex/symbols.rs:102 — crates/codegen/xai-grok-markdown/src/latex/symbols.rs:102-106 | crates/codegen/xai-grok-markdown/src/latex/symbols.rs:143-147 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/mermaid.rs:2402 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2402-2406 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2576-2580 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-memory/src/v2_access.rs:240 — crates/codegen/xai-grok-memory/src/v2_access.rs:240-244 | crates/codegen/xai-grok-memory/src/v2_access.rs:453-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 (5 lines × 2) crates/codegen/xai-grok-memory/src/v2_consolidation.rs:372 — crates/codegen/xai-grok-memory/src/v2_consolidation.rs:372-376 | crates/codegen/xai-grok-memory/src/v2_consolidation.rs:498-502 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:248 — crates/codegen/xai-grok-pager-render/src/render/bidi.rs:248-252 | crates/codegen/xai-grok-pager-render/src/render/bidi.rs:307-311 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:3196 — crates/codegen/xai-grok-pager/src/app/app_view.rs:3196-3200 | crates/codegen/xai-grok-pager/src/app/app_view.rs:3239-3243 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:1176 — crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:1176-1180 | crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:1366-1370 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:99 — crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:99-104 | crates/codegen/xai-grok-pager/src/views/slash_dropdown.rs:81-85 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs` and `crates/codegen/xai-grok-pager/src/views/slash_dropdown.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 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 (5 lines × 2) crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:175 — crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:175-182 | crates/codegen/xai-grok-pager/src/views/slash_dropdown.rs:315-319 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs` and `crates/codegen/xai-grok-pager/src/views/slash_dropdown.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 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 (5 lines × 2) crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2349 — crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2349-2353 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3331-3335 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/persona_detail.rs:449 — crates/codegen/xai-grok-pager/src/views/persona_detail.rs:449-454 | crates/codegen/xai-grok-pager/src/views/persona_detail.rs:541-545 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1351 — crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1351-1355 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1478-1482 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/agent/handlers/model_switch.rs:48 — crates/codegen/xai-grok-shell/src/agent/handlers/model_switch.rs:48-52 | crates/codegen/xai-grok-shell/src/agent/handlers/model_switch.rs:307-311 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/extensions/bundle.rs:263 — crates/codegen/xai-grok-shell/src/extensions/bundle.rs:263-267 | crates/codegen/xai-grok-shell/src/extensions/bundle.rs:293-297 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/leader/server.rs:691 — crates/codegen/xai-grok-shell/src/leader/server.rs:691-695 | crates/codegen/xai-grok-shell/src/leader/server.rs:780-784 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 23 more in this group — see findings.md.
D2 · Cognitive Complexity · xai_grok_tools · ×47
  • xai_grok_tools::mcp_elicitation::validate::validate_field (cognitive 56) crates/codegen/xai-grok-tools/src/mcp_elicitation/validate.rs:62 — xai_grok_tools::mcp_elicitation::validate::validate_field has cognitive complexity 56 (threshold 15). Drivers by points: if/else 23 (41 pts), boolean chains 10, match/switch 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.
  • xai_grok_tools::implementations::grok_build::read_file::run_read_file (cognitive 49) crates/codegen/xai-grok-tools/src/implementations/grok_build/read_file/mod.rs:396 — xai_grok_tools::implementations::grok_build::read_file::run_read_file has cognitive complexity 49 (threshold 15). Drivers by points: if/else 21 (31 pts), boolean chains 11, match/switch 6 (7 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.
  • xai_grok_tools::implementations::grok_build::grep::rg_heading::render_rg_heading (cognitive 43) crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/rg_heading.rs:28 — xai_grok_tools::implementations::grok_build::grep::rg_heading::render_rg_heading has cognitive complexity 43 (threshold 15). Drivers by points: if/else 9 (29 pts), match/switch 2 (6 pts), boolean chains 4, loops 2 (4 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.
  • xai_grok_tools::implementations::codex::apply_patch::seek_sequence::seek_sequence (cognitive 42) crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/seek_sequence.rs:26 — xai_grok_tools::implementations::codex::apply_patch::seek_sequence::seek_sequence has cognitive complexity 42 (threshold 15). Drivers by points: if/else 14 (30 pts), loops 7 (10 pts), boolean chains 1, match/switch 1 (nesting depth added 19). Of this number, 41 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_tools::implementations::grok_build::search_replace::handle_replacement (cognitive 41) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:515 — xai_grok_tools::implementations::grok_build::search_replace::handle_replacement has cognitive complexity 41 (threshold 15). Drivers by points: if/else 20 (27 pts), match/switch 6 (11 pts), boolean chains 3 (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.
  • xai_grok_tools::implementations::skills::skill::resolve_skill_internal_links (cognitive 40) crates/codegen/xai-grok-tools/src/implementations/skills/skill.rs:327 — xai_grok_tools::implementations::skills::skill::resolve_skill_internal_links has cognitive complexity 40 (threshold 15). Drivers by points: if/else 10 (29 pts), match/switch 4 (8 pts), loops 2, 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.
  • xai_grok_tools::implementations::grok_build::bash::contains_background_operator (cognitive 38) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:708 — xai_grok_tools::implementations::grok_build::bash::contains_background_operator has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (27 pts), boolean chains 7, loops 2 (4 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.
  • xai_grok_tools::implementations::grok_build_hashline::edit::to_search_replace (cognitive 36) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/mod.rs:90 — xai_grok_tools::implementations::grok_build_hashline::edit::to_search_replace has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (22 pts), match/switch 5 (14 pts) (nesting depth added 19). 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.
  • xai_grok_tools::implementations::grok_build::web_fetch::client::strip_base64_data_uris (cognitive 35) crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/client.rs:769 — xai_grok_tools::implementations::grok_build::web_fetch::client::strip_base64_data_uris has cognitive complexity 35 (threshold 15). Drivers by points: if/else 13 (33 pts), boolean chains 1, loops 1 (nesting depth added 20). 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.
  • xai_grok_tools::implementations::skills::discovery::discover_skills_for_paths (cognitive 35) crates/codegen/xai-grok-tools/src/implementations/skills/discovery.rs:828 — xai_grok_tools::implementations::skills::discovery::discover_skills_for_paths has cognitive complexity 35 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 4 (10 pts), match/switch 1 (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.
  • xai_grok_tools::implementations::grok_build_hashline::benchmark::run_phase1_for_file (cognitive 34) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/benchmark.rs:362 — xai_grok_tools::implementations::grok_build_hashline::benchmark::run_phase1_for_file has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (20 pts), match/switch 2 (6 pts), boolean chains 4, loops 3 (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.
  • xai_grok_tools::implementations::grok_build::read_file::extract_file_content_lines (cognitive 31) crates/codegen/xai-grok-tools/src/implementations/grok_build/read_file/mod.rs:292 — xai_grok_tools::implementations::grok_build::read_file::extract_file_content_lines has cognitive complexity 31 (threshold 15). Drivers by points: if/else 15 (22 pts), boolean chains 6, match/switch 1 (2 pts), loops 1 (nesting depth added 8). Of this number, 29 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_tools::implementations::grok_build::list_dir::versions::legacy_0_4_10::collect (cognitive 29) crates/codegen/xai-grok-tools/src/implementations/grok_build/list_dir/versions/legacy_0_4_10.rs:171 — xai_grok_tools::implementations::grok_build::list_dir::versions::legacy_0_4_10::collect has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (23 pts), loops 3 (5 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.
  • xai_grok_tools::implementations::web_search::client::extract_citation_pairs (cognitive 29) crates/codegen/xai-grok-tools/src/implementations/web_search/client.rs:347 — xai_grok_tools::implementations::web_search::client::extract_citation_pairs has cognitive complexity 29 (threshold 15). Drivers by points: if/else 4 (19 pts), loops 3 (9 pts), boolean chains 1 (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • xai_grok_tools::computer::local::shell_state::shell_commands (cognitive 28) crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs:638 — xai_grok_tools::computer::local::shell_state::shell_commands has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (24 pts), match/switch 1 (2 pts), boolean chains 1, 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.
  • xai_grok_tools::implementations::grok_build_hashline::edit::apply::apply_edits (cognitive 28) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/apply.rs:153 — xai_grok_tools::implementations::grok_build_hashline::edit::apply::apply_edits has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 3 (9 pts), loops 4, 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.
  • xai_grok_tools::implementations::skills::skill::apply_substitutions (cognitive 27) crates/codegen/xai-grok-tools/src/implementations/skills/skill.rs:228 — xai_grok_tools::implementations::skills::skill::apply_substitutions has cognitive complexity 27 (threshold 15). Drivers by points: if/else 14 (21 pts), loops 3 (4 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.
  • xai_grok_tools::implementations::codex::apply_patch::apply::compute_replacements (cognitive 26) crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/apply.rs:43 — xai_grok_tools::implementations::codex::apply_patch::apply::compute_replacements has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 2, 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.
  • xai_grok_tools::implementations::codex::read_file::indentation::read_block (cognitive 26) crates/codegen/xai-grok-tools/src/implementations/codex/read_file/indentation.rs:155 — xai_grok_tools::implementations::codex::read_file::indentation::read_block has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (24 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.
  • xai_grok_tools::implementations::read_file::pdf::parse_page_range (cognitive 26) crates/codegen/xai-grok-tools/src/implementations/read_file/pdf.rs:115 — xai_grok_tools::implementations::read_file::pdf::parse_page_range has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (20 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.
  • xai_grok_tools::implementations::grok_build_hashline::edit::apply::resolve_op (cognitive 25) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/apply.rs:395 — xai_grok_tools::implementations::grok_build_hashline::edit::apply::resolve_op has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (21 pts), match/switch 2 (3 pts), boolean chains 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.
  • xai_grok_tools::implementations::grok_build_hashline::mutate::apply_mutation (cognitive 24) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/mutate.rs:71 — xai_grok_tools::implementations::grok_build_hashline::mutate::apply_mutation has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (21 pts), 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.
  • xai_grok_tools::registry::types::explain_requirement_failure (cognitive 23) crates/codegen/xai-grok-tools/src/registry/types.rs:2193 — xai_grok_tools::registry::types::explain_requirement_failure has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 5, 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.
  • xai_grok_tools::util::command_display::take_path_token (cognitive 23) crates/codegen/xai-grok-tools/src/util/command_display.rs:179 — xai_grok_tools::util::command_display::take_path_token has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 2 (4 pts), boolean chains 3, 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.
  • xai_grok_tools::implementations::codex::apply_patch::parser::parse_one_hunk (cognitive 22) crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/parser.rs:198 — xai_grok_tools::implementations::codex::apply_patch::parser::parse_one_hunk has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 2 (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.
  • + 22 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×47
  • Duplicated block (7 lines × 2) crates/codegen/xai-chat-state/src/actor/mutations.rs:258 — crates/codegen/xai-chat-state/src/actor/mutations.rs:258-264 | crates/codegen/xai-chat-state/src/actor/mutations.rs:321-327 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1025 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1025-1031 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1067-1073 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1155 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1155-1161 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1194-1200 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1580 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1580-1586 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1587-1593 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:152 — crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:152-159 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:307-313 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/mount_info.rs:104 — crates/codegen/xai-fast-worktree/src/mount_info.rs:104-110 | crates/codegen/xai-fast-worktree/src/mount_info.rs:127-133 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-config/src/global_hook_sources.rs:147 — crates/codegen/xai-grok-config/src/global_hook_sources.rs:147-153 | crates/codegen/xai-grok-config/src/global_hook_sources.rs:217-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 (7 lines × 2) crates/codegen/xai-grok-hooks/src/runner/http.rs:103 — crates/codegen/xai-grok-hooks/src/runner/http.rs:103-109 | crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/ssrf.rs:140-147 — 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) crates/codegen/xai-grok-markdown/src/latex/symbols.rs:119 — crates/codegen/xai-grok-markdown/src/latex/symbols.rs:119-125 | crates/codegen/xai-grok-markdown/src/latex/symbols.rs:132-138 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-mcp/src/servers.rs:713 — crates/codegen/xai-grok-mcp/src/servers.rs:713-719 | crates/codegen/xai-grok-mcp/src/servers.rs:724-730 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-memory/src/v2.rs:875 — crates/codegen/xai-grok-memory/src/v2.rs:875-881 | crates/codegen/xai-grok-memory/src/v2.rs:950-956 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:979 — crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:979-985 | crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1381-1387 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3867 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3867-3873 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3895-3901 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/settings/setters.rs:1804 — crates/codegen/xai-grok-pager/src/app/dispatch/settings/setters.rs:1804-1810 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:978-984 — 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 × 2) crates/codegen/xai-grok-pager/src/diagnostics/probes/mod.rs:192 — crates/codegen/xai-grok-pager/src/diagnostics/probes/mod.rs:192-198 | crates/codegen/xai-grok-pager/src/diagnostics/probes/mod.rs:357-363 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:760 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:760-766 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:780-786 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:168 — crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:168-174 | crates/codegen/xai-grok-pager/src/views/slash_dropdown.rs:302-309 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs` and `crates/codegen/xai-grok-pager/src/views/slash_dropdown.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 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 (7 lines × 2) crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:660 — crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:660-666 | crates/codegen/xai-grok-pager/src/views/welcome/menu.rs:83-89 — 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) crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:896 — crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:896-902 | crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:1711-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 (7 lines × 2) crates/codegen/xai-grok-pager/src/views/welcome/hero_box.rs:551 — crates/codegen/xai-grok-pager/src/views/welcome/hero_box.rs:551-557 | crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:1638-1644 — 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 × 2) crates/codegen/xai-grok-plugin-marketplace/src/config.rs:222 — crates/codegen/xai-grok-plugin-marketplace/src/config.rs:222-228 | crates/codegen/xai-grok-plugin-marketplace/src/config.rs:245-251 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:851 — crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:851-857 | crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:872-878 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1694 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1694-1700 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1818-1824 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:3777 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:3777-3783 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/mod.rs:2149-2155 — 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 × 2) crates/codegen/xai-grok-shell/src/extensions/session_admin.rs:120 — crates/codegen/xai-grok-shell/src/extensions/session_admin.rs:120-126 | crates/codegen/xai-grok-shell/src/extensions/session_admin.rs:213-219 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 22 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×46
  • Duplicated block (10 lines × 2) crates/codegen/xai-agent-lifecycle/src/local/registry.rs:49 — crates/codegen/xai-agent-lifecycle/src/local/registry.rs:49-58 | crates/codegen/xai-agent-lifecycle/src/send/registry.rs:45-54 — 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) crates/codegen/xai-codebase-graph/src/navigation.rs:234 — crates/codegen/xai-codebase-graph/src/navigation.rs:234-243 | crates/codegen/xai-codebase-graph/src/navigation.rs:290-299 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1127 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1127-1136 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1142-1151 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1169 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1169-1178 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1208-1217 — both copies are in the same file, so extract the 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) crates/codegen/xai-crash-handler/src/lib.rs:136 — crates/codegen/xai-crash-handler/src/lib.rs:136-145 | crates/codegen/xai-grok-pager-render/src/clipboard/mod.rs:505-514 — 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) crates/codegen/xai-grok-login/src/oidc/login.rs:248 — crates/codegen/xai-grok-login/src/oidc/login.rs:248-257 | crates/codegen/xai-grok-login/src/oidc/login.rs:305-314 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/mermaid.rs:2941 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2941-2950 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3714-3723 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-bin/src/main.rs:68 — crates/codegen/xai-grok-pager-bin/src/main.rs:68-77 | crates/codegen/xai-grok-pager-bin/src/main.rs:108-117 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-render/src/render/wrapping.rs:458 — crates/codegen/xai-grok-pager-render/src/render/wrapping.rs:458-467 | crates/codegen/xai-grok-pager-render/src/render/wrapping.rs:490-499 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/input.rs:1337 — crates/codegen/xai-grok-pager/src/app/agent_view/input.rs:1337-1346 | crates/codegen/xai-grok-pager/src/app/agent_view/input.rs: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.
  • Duplicated block (10 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2347 — crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2347-2356 | crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2397-2406 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:308 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:308-317 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs: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.
  • Duplicated block (10 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:280 — crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:280-290 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:322-331 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs:1390 — crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs:1390-1399 | crates/codegen/xai-grok-pager/src/app/dispatch/task_result.rs:1423-1432 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/effects/mod.rs:4902 — crates/codegen/xai-grok-pager/src/app/effects/mod.rs:4902-4911 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:4998-5007 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/plugin_cmd.rs:910 — crates/codegen/xai-grok-pager/src/plugin_cmd.rs:910-919 | crates/codegen/xai-grok-shell/src/extensions/marketplace.rs:766-775 — 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) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:170 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:170-179 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:204-213 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 142 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 × 2) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search.rs:401 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search.rs:401-410 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:294-303 — 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 (10 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2720 — crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2720-2729 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2737-2746 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:708 — crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:708-717 | crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:737-746 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/picker.rs:1862 — crates/codegen/xai-grok-pager/src/views/picker.rs:1862-1871 | crates/codegen/xai-grok-pager/src/views/shortcuts_help.rs:1325-1334 — 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 (10 lines × 2) crates/codegen/xai-grok-sampler/src/actor/request_task.rs:213 — crates/codegen/xai-grok-sampler/src/actor/request_task.rs:213-222 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/sampler_turn.rs:1509-1518 — 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) crates/codegen/xai-grok-shell/src/agent/feedback_client.rs:243 — crates/codegen/xai-grok-shell/src/agent/feedback_client.rs:243-252 | crates/codegen/xai-grok-shell/src/agent/feedback_client.rs:277-286 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:278 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:278-287 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:295-304 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/extensions/consent.rs:42 — crates/codegen/xai-grok-shell/src/extensions/consent.rs:42-51 | crates/codegen/xai-grok-shell/src/extensions/privacy.rs:43-52 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/extensions/consent.rs` and `crates/codegen/xai-grok-shell/src/extensions/privacy.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 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.
  • + 21 more in this group — see findings.md.
D2 · Cognitive Complexity · SessionActor · ×45
  • SessionActor::process_conversation_turn_inner (cognitive 219) crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:2615 — SessionActor::process_conversation_turn_inner has cognitive complexity 219 (threshold 15). Drivers by points: if/else 77 (163 pts), match/switch 13 (36 pts), boolean chains 17, loops 2 (3 pts) (nesting depth added 110). 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.
  • SessionActor::handle_turn_input_inner (cognitive 216) crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:503 — SessionActor::handle_turn_input_inner has cognitive complexity 216 (threshold 15). Drivers by points: if/else 82 (153 pts), match/switch 19 (34 pts), loops 8 (17 pts), boolean chains 12 (nesting depth added 95). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SessionActor::execute_builtin_slash_command (cognitive 207) crates/codegen/xai-grok-shell/src/session/acp_session_impl/slash_exec.rs:5 — SessionActor::execute_builtin_slash_command has cognitive complexity 207 (threshold 15). Drivers by points: if/else 60 (134 pts), match/switch 24 (60 pts), loops 3 (12 pts), boolean chains 1 (nesting depth added 119). 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.
  • SessionActor::cancel_running_task (cognitive 167) crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:251 — SessionActor::cancel_running_task has cognitive complexity 167 (threshold 15). Drivers by points: if/else 91 (134 pts), boolean chains 21, match/switch 6 (9 pts), loops 2 (3 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.
  • SessionActor::run_compact_inner (cognitive 153) crates/codegen/xai-grok-shell/src/session/compaction.rs:922 — SessionActor::run_compact_inner has cognitive complexity 153 (threshold 15). Drivers by points: if/else 75 (101 pts), match/switch 19 (38 pts), boolean chains 13, loops 1 (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SessionActor::execute_tool_calls_batch (cognitive 113) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:484 — SessionActor::execute_tool_calls_batch has cognitive complexity 113 (threshold 15). Drivers by points: if/else 40 (70 pts), match/switch 11 (24 pts), loops 9 (15 pts), boolean chains 4 (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.
  • SessionActor::prepare_tool_call (cognitive 96) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:1445 — SessionActor::prepare_tool_call has cognitive complexity 96 (threshold 15). Drivers by points: if/else 39 (65 pts), match/switch 14 (22 pts), boolean chains 5, loops 1 (4 pts) (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SessionActor::run_v2_capture_worker (cognitive 75) crates/codegen/xai-grok-shell/src/session/acp_session_impl/memory_capture.rs:657 — SessionActor::run_v2_capture_worker has cognitive complexity 75 (threshold 15). Drivers by points: if/else 21 (53 pts), match/switch 8 (19 pts), boolean chains 2, loops 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.
  • SessionActor::handle_rewind (cognitive 74) crates/codegen/xai-grok-shell/src/session/acp_session_impl/rewind.rs:121 — SessionActor::handle_rewind has cognitive complexity 74 (threshold 15). Drivers by points: if/else 29 (54 pts), loops 4 (9 pts), match/switch 2 (6 pts), boolean chains 5 (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.
  • SessionActor::drain_goal_updates_with_extra (cognitive 73) crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal.rs:1673 — SessionActor::drain_goal_updates_with_extra has cognitive complexity 73 (threshold 15). Drivers by points: if/else 28 (59 pts), loops 3 (6 pts), match/switch 3 (6 pts), boolean chains 2 (nesting depth added 37). 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.
  • SessionActor::handle_sampling_event (cognitive 72) crates/codegen/xai-grok-shell/src/session/acp_session_impl/sampling_events.rs:105 — SessionActor::handle_sampling_event has cognitive complexity 72 (threshold 15). Drivers by points: if/else 27 (65 pts), match/switch 3 (4 pts), boolean chains 3 (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.
  • SessionActor::handle_sampling_failure (cognitive 71) crates/codegen/xai-grok-shell/src/session/acp_session_impl/sampler_turn.rs:1189 — SessionActor::handle_sampling_failure has cognitive complexity 71 (threshold 15). Drivers by points: if/else 36 (51 pts), boolean chains 19, 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.
  • SessionActor::maybe_run_goal_planner (cognitive 48) crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal_support.rs:1157 — SessionActor::maybe_run_goal_planner has cognitive complexity 48 (threshold 15). Drivers by points: if/else 9 (29 pts), match/switch 4 (12 pts), boolean chains 6, 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.
  • SessionActor::send_tool_call_start (cognitive 47) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:2321 — SessionActor::send_tool_call_start has cognitive complexity 47 (threshold 15). Drivers by points: match/switch 11 (25 pts), if/else 15 (21 pts), boolean chains 1 (nesting depth added 20). 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.
  • SessionActor::handle_plugins_action (cognitive 45) crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:362 — SessionActor::handle_plugins_action has cognitive complexity 45 (threshold 15). Drivers by points: if/else 10 (22 pts), match/switch 10 (20 pts), loops 1 (3 pts) (nesting depth added 24). 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.
  • SessionActor::handle_hooks_action (cognitive 44) crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:133 — SessionActor::handle_hooks_action has cognitive complexity 44 (threshold 15). Drivers by points: if/else 13 (27 pts), match/switch 7 (13 pts), boolean chains 2, loops 1 (2 pts) (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.
  • SessionActor::queue_input (cognitive 43) crates/codegen/xai-grok-shell/src/session/acp_session_impl/prompt_queue.rs:113 — SessionActor::queue_input has cognitive complexity 43 (threshold 15). Drivers by points: if/else 23 (28 pts), boolean chains 11, loops 1 (4 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • SessionActor::manage_workflow_run (cognitive 43) crates/codegen/xai-grok-shell/src/session/acp_session_impl/workflow.rs:100 — SessionActor::manage_workflow_run has cognitive complexity 43 (threshold 15). Drivers by points: if/else 13 (24 pts), match/switch 8 (13 pts), boolean chains 4, loops 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.
  • SessionActor::run_memory_flush (cognitive 42) crates/codegen/xai-grok-shell/src/session/acp_session_impl/memory_dream.rs:541 — SessionActor::run_memory_flush has cognitive complexity 42 (threshold 15). Drivers by points: if/else 20 (32 pts), match/switch 6 (10 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.
  • SessionActor::handle_bridge_tool_success (cognitive 40) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:2959 — SessionActor::handle_bridge_tool_success has cognitive complexity 40 (threshold 15). Drivers by points: if/else 22 (32 pts), loops 2 (6 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.
  • SessionActor::maybe_start_running_task (cognitive 37) crates/codegen/xai-grok-shell/src/session/acp_session_impl/notification_drain.rs:119 — SessionActor::maybe_start_running_task has cognitive complexity 37 (threshold 15). Drivers by points: if/else 19 (25 pts), match/switch 3 (6 pts), boolean chains 5, loops 1 (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.
  • SessionActor::maybe_fire_laziness_check (cognitive 36) crates/codegen/xai-grok-shell/src/session/acp_session_impl/laziness.rs:277 — SessionActor::maybe_fire_laziness_check has cognitive complexity 36 (threshold 15). Drivers by points: if/else 18 (23 pts), match/switch 5 (8 pts), boolean chains 3, loops 2 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • SessionActor::submit_turn_request (cognitive 32) crates/codegen/xai-grok-shell/src/session/acp_session_impl/sampler_turn.rs:1781 — SessionActor::submit_turn_request has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (29 pts), boolean chains 1, loops 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.
  • SessionActor::handle_xai_session_notification (cognitive 30) crates/codegen/xai-grok-shell/src/session/acp_session_impl/updates.rs:635 — SessionActor::handle_xai_session_notification has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (18 pts), match/switch 6 (10 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.
  • SessionActor::retry_unreachable_servers (cognitive 28) crates/codegen/xai-grok-shell/src/session/acp_session_impl/mcp.rs:418 — SessionActor::retry_unreachable_servers has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 3 (5 pts), match/switch 2 (5 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.
  • + 20 more in this group — see findings.md.
D2 · Cognitive Complexity · xai_grok_workspace · ×42
  • xai_grok_workspace::permission::manager::spawn_permission_manager_with_pin (cognitive 266) crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs:438 — xai_grok_workspace::permission::manager::spawn_permission_manager_with_pin has cognitive complexity 266 (threshold 15). Drivers by points: if/else 61 (163 pts), match/switch 18 (70 pts), boolean chains 32, loops 1 (nesting depth added 154). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_workspace::folder_trust::collect_repo_config_kinds (cognitive 98) crates/codegen/xai-grok-workspace/src/folder_trust.rs:433 — xai_grok_workspace::folder_trust::collect_repo_config_kinds has cognitive complexity 98 (threshold 15). Drivers by points: if/else 54 (96 pts), boolean chains 1, loops 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.
  • xai_grok_workspace::permission::prompter::map_selected_outcome (cognitive 78) crates/codegen/xai-grok-workspace/src/permission/prompter.rs:903 — xai_grok_workspace::permission::prompter::map_selected_outcome has cognitive complexity 78 (threshold 15). Drivers by points: if/else 34 (64 pts), match/switch 3 (9 pts), boolean chains 5 (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.
  • xai_grok_workspace::session::git::parse_porcelain_v2 (cognitive 67) crates/codegen/xai-grok-workspace/src/session/git.rs:1173 — xai_grok_workspace::session::git::parse_porcelain_v2 has cognitive complexity 67 (threshold 15). Drivers by points: if/else 27 (60 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_workspace::permission::grants::evaluate_bash (cognitive 56) crates/codegen/xai-grok-workspace/src/permission/grants.rs:547 — xai_grok_workspace::permission::grants::evaluate_bash has cognitive complexity 56 (threshold 15). Drivers by points: if/else 27 (43 pts), boolean chains 10, 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.
  • xai_grok_workspace::session::git::status_ungated (cognitive 42) crates/codegen/xai-grok-workspace/src/session/git.rs:1476 — xai_grok_workspace::session::git::status_ungated has cognitive complexity 42 (threshold 15). Drivers by points: if/else 20 (36 pts), boolean chains 3, match/switch 2, 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.
  • xai_grok_workspace::bin::workspace_server::run (cognitive 39) crates/codegen/xai-grok-workspace/src/bin/workspace_server.rs:333 — xai_grok_workspace::bin::workspace_server::run has cognitive complexity 39 (threshold 15). Drivers by points: if/else 21 (25 pts), match/switch 11 (13 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.
  • xai_grok_workspace::file_system::file_tree::list_contents (cognitive 38) crates/codegen/xai-grok-workspace/src/file_system/file_tree.rs:373 — xai_grok_workspace::file_system::file_tree::list_contents has cognitive complexity 38 (threshold 15). Drivers by points: if/else 18 (31 pts), loops 4 (7 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_workspace::mcp::drive_server_starts (cognitive 33) crates/codegen/xai-grok-workspace/src/mcp.rs:480 — xai_grok_workspace::mcp::drive_server_starts has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (24 pts), loops 3 (5 pts), boolean chains 2, match/switch 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.
  • xai_grok_workspace::file_system::content::content_search_streaming (cognitive 32) crates/codegen/xai-grok-workspace/src/file_system/content.rs:131 — xai_grok_workspace::file_system::content::content_search_streaming has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 6, match/switch 2 (4 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.
  • xai_grok_workspace::hub_auth::proactive::refresh_loop (cognitive 32) crates/codegen/xai-grok-workspace/src/hub_auth/proactive.rs:318 — xai_grok_workspace::hub_auth::proactive::refresh_loop has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (21 pts), match/switch 4 (8 pts), boolean chains 2, 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.
  • xai_grok_workspace::file_system::git_status::git_status_impl (cognitive 31) crates/codegen/xai-grok-workspace/src/file_system/git_status.rs:111 — xai_grok_workspace::file_system::git_status::git_status_impl has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 3 (7 pts), loops 2 (4 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.
  • xai_grok_workspace::session::file_state::rewind_files (cognitive 28) crates/codegen/xai-grok-workspace/src/session/file_state.rs:780 — xai_grok_workspace::session::file_state::rewind_files has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 3 (4 pts), match/switch 2 (4 pts), boolean chains 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_workspace::path_virtualization::rewrite_chat_completion_output (cognitive 24) crates/codegen/xai-grok-workspace/src/path_virtualization.rs:421 — xai_grok_workspace::path_virtualization::rewrite_chat_completion_output has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (23 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.
  • xai_grok_workspace::permission::grants::bash_grant_pre_decision (cognitive 23) crates/codegen/xai-grok-workspace/src/permission/grants.rs:898 — xai_grok_workspace::permission::grants::bash_grant_pre_decision has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (20 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.
  • xai_grok_workspace::permission::sandbox_gate::decide (cognitive 22) crates/codegen/xai-grok-workspace/src/permission/sandbox_gate.rs:253 — xai_grok_workspace::permission::sandbox_gate::decide has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (18 pts), match/switch 3, 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.
  • xai_grok_workspace::recovery::run_startup_recovery (cognitive 22) crates/codegen/xai-grok-workspace/src/recovery.rs:89 — xai_grok_workspace::recovery::run_startup_recovery has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (11 pts), match/switch 5 (10 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.
  • xai_grok_workspace::worktree::create_worktree_from_worktree_streaming (cognitive 22) crates/codegen/xai-grok-workspace/src/worktree/mod.rs:1903 — xai_grok_workspace::worktree::create_worktree_from_worktree_streaming has cognitive complexity 22 (threshold 15). Drivers by points: if/else 16 (18 pts), match/switch 3 (4 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, 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.
  • xai_grok_workspace::image_capabilities::load_from_dir (cognitive 21) crates/codegen/xai-grok-workspace/src/image_capabilities.rs:96 — xai_grok_workspace::image_capabilities::load_from_dir has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 2, loops 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.
  • xai_grok_workspace::permission::auto_mode::command_env_risk (cognitive 21) crates/codegen/xai-grok-workspace/src/permission/auto_mode/mod.rs:934 — xai_grok_workspace::permission::auto_mode::command_env_risk has cognitive complexity 21 (threshold 15). Drivers by points: if/else 3 (10 pts), match/switch 2 (6 pts), loops 2 (4 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.
  • xai_grok_workspace::permission::grants::ps_dumps_environment (cognitive 21) crates/codegen/xai-grok-workspace/src/permission/grants.rs:157 — xai_grok_workspace::permission::grants::ps_dumps_environment has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 7, 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.
  • xai_grok_workspace::permission::sandbox_wire::tied_to_violation (cognitive 21) crates/codegen/xai-grok-workspace/src/permission/sandbox_wire.rs:801 — xai_grok_workspace::permission::sandbox_wire::tied_to_violation has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 4 (7 pts) (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.
  • xai_grok_workspace::session::git::git_cli_verb_index (cognitive 21) crates/codegen/xai-grok-workspace/src/session/git.rs:66 — xai_grok_workspace::session::git::git_cli_verb_index 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.
  • xai_grok_workspace::worktree::create_worktree_streaming_in (cognitive 21) crates/codegen/xai-grok-workspace/src/worktree/mod.rs:1128 — xai_grok_workspace::worktree::create_worktree_streaming_in has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (14 pts), match/switch 4 (5 pts), boolean chains 2 (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.
  • xai_grok_workspace::path_virtualization::rewrite_text_inbound (cognitive 20) crates/codegen/xai-grok-workspace/src/path_virtualization.rs:273 — xai_grok_workspace::path_virtualization::rewrite_text_inbound has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 2 (4 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.
  • + 17 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×42
  • Duplicated block (12 lines × 2) crates/codegen/ptyctl/src/term.rs:246 — crates/codegen/ptyctl/src/term.rs:246-257 | crates/codegen/ptyctl/src/term.rs:310-321 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/bin/code_graph.rs:260 — crates/codegen/xai-codebase-graph/src/bin/code_graph.rs:260-271 | crates/codegen/xai-codebase-graph/src/bin/code_graph.rs:310-321 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/config.rs:263 — crates/codegen/xai-grok-agent/src/config.rs:263-274 | crates/codegen/xai-grok-agent/src/config.rs:501-512 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:502 — crates/codegen/xai-grok-agent/src/plugins/git_install.rs:502-513 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:452-463 — before extracting anything, compare `crates/codegen/xai-grok-agent/src/plugins/git_install.rs` and `crates/codegen/xai-grok-plugin-marketplace/src/installer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 127 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 (12 lines × 2) crates/codegen/xai-grok-feedback/src/draft_store.rs:506 — crates/codegen/xai-grok-feedback/src/draft_store.rs:506-517 | crates/codegen/xai-grok-feedback/src/draft_store.rs:830-841 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-login/src/manager/lock.rs:240 — crates/codegen/xai-grok-login/src/manager/lock.rs:240-251 | crates/codegen/xai-grok-login/src/manager/lock.rs:316-327 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/colors.rs:231 — crates/codegen/xai-grok-markdown/src/colors.rs:231-242 | crates/codegen/xai-grok-pager-render/src/syntax.rs:65-76 — 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 (12 lines × 2) crates/codegen/xai-grok-markdown/src/parse.rs:1773 — crates/codegen/xai-grok-markdown/src/parse.rs:1773-1784 | crates/codegen/xai-grok-markdown/src/parse.rs:1813-1824 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/parse.rs:1787 — crates/codegen/xai-grok-markdown/src/parse.rs:1787-1798 | crates/codegen/xai-grok-markdown/src/parse.rs:1828-1839 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:468 — crates/codegen/xai-grok-pager-render/src/render/bidi.rs:468-479 | crates/codegen/xai-grok-pager-render/src/render/wrapping.rs:317-328 — 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) crates/codegen/xai-grok-pager-render/src/render/highlight.rs:39 — crates/codegen/xai-grok-pager-render/src/render/highlight.rs:39-50 | crates/codegen/xai-grok-pager-render/src/render/highlight.rs:75-86 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1839 — crates/codegen/xai-grok-pager/src/acp/tracker.rs:1839-1850 | crates/codegen/xai-grok-pager/src/acp/tracker.rs:2275-2286 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:3465 — crates/codegen/xai-grok-pager/src/app/app_view.rs:3465-3476 | crates/codegen/xai-grok-pager/src/app/app_view.rs:3494-3505 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:83 — crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:83-94 | crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:127-138 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/queue_edit.rs:424 — crates/codegen/xai-grok-pager/src/app/queue_edit.rs:424-435 | crates/codegen/xai-grok-pager/src/app/queue_edit.rs:533-544 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/scrollback/entry.rs:156 — crates/codegen/xai-grok-pager/src/scrollback/entry.rs:156-167 | crates/codegen/xai-grok-pager/src/scrollback/entry.rs:185-196 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/slash/mod.rs:814 — crates/codegen/xai-grok-pager/src/slash/mod.rs:814-825 | crates/codegen/xai-grok-pager/src/slash/mod.rs:1387-1398 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1688 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1688-1699 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1711-1722 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2128 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2128-2139 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2336-2347 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dock/layout.rs:262 — crates/codegen/xai-grok-pager/src/views/dock/layout.rs:262-273 | crates/codegen/xai-grok-pager/src/views/dock/layout.rs:284-295 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) crates/codegen/xai-grok-pager/src/views/goal_detail.rs:52 — crates/codegen/xai-grok-pager/src/views/goal_detail.rs:52-63 | crates/codegen/xai-grok-shell/src/session/goal_orchestrator.rs:240-251 — 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 (12 lines × 2) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:662 — crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:662-673 | crates/codegen/xai-grok-pager/src/views/todo_pane.rs:190-201 — 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) crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:87 — crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:87-98 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:172-183 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-sampler/src/client.rs:1349 — crates/codegen/xai-grok-sampler/src/client.rs:1349-1360 | crates/codegen/xai-grok-sampler/src/client.rs:1706-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 (12 lines × 2) crates/codegen/xai-grok-sampler/src/client.rs:1497 — crates/codegen/xai-grok-sampler/src/client.rs:1497-1508 | crates/codegen/xai-grok-sampler/src/client.rs:1824-1835 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 17 more in this group — see findings.md.
D1 · Cyclomatic Complexity · AgentView · ×39
  • AgentView::draw (cyclomatic 511) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:562 — AgentView::draw has cyclomatic complexity 511 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AgentView::handle_input_inner (cyclomatic 231) crates/codegen/xai-grok-pager/src/app/agent_view/input.rs:328 — AgentView::handle_input_inner has cyclomatic complexity 231 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AgentView::handle_mouse (cyclomatic 224) crates/codegen/xai-grok-pager/src/app/mouse.rs:30 — AgentView::handle_mouse has cyclomatic complexity 224 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AgentView::handle_prompt_key (cyclomatic 120) crates/codegen/xai-grok-pager/src/app/agent_view/prompt.rs:91 — AgentView::handle_prompt_key has cyclomatic complexity 120 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AgentView::execute_modal_button_action (cyclomatic 113) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1681 — AgentView::execute_modal_button_action has cyclomatic complexity 113 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AgentView::handle_line_viewer_mouse (cyclomatic 84) crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:387 — AgentView::handle_line_viewer_mouse has cyclomatic complexity 84 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AgentView::handle_palette_or_arg_input_with_registry (cyclomatic 80) crates/codegen/xai-grok-pager/src/app/modals.rs:701 — AgentView::handle_palette_or_arg_input_with_registry has cyclomatic complexity 80 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AgentView::handle_modal_key_with_registry (cyclomatic 64) crates/codegen/xai-grok-pager/src/app/modals.rs:106 — AgentView::handle_modal_key_with_registry has cyclomatic complexity 64 (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.
  • AgentView::handle_permission_key (cyclomatic 63) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:30 — AgentView::handle_permission_key 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.
  • AgentView::handle_question_key (cyclomatic 63) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:333 — AgentView::handle_question_key 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.
  • AgentView::handle_line_viewer_key (cyclomatic 56) crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:79 — AgentView::handle_line_viewer_key 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.
  • AgentView::handle_extensions_modal_key (cyclomatic 53) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:634 — AgentView::handle_extensions_modal_key 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.
  • AgentView::draw_active_modal (cyclomatic 50) crates/codegen/xai-grok-pager/src/app/modals.rs:1684 — AgentView::draw_active_modal 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.
  • AgentView::handle_scroll (cyclomatic 48) crates/codegen/xai-grok-pager/src/app/agent_view/panes.rs:1102 — AgentView::handle_scroll 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.
  • AgentView::handle_modal_mouse_with_registry (cyclomatic 47) crates/codegen/xai-grok-pager/src/app/modals.rs:1358 — AgentView::handle_modal_mouse_with_registry 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.
  • AgentView::handle_elicitation_key (cyclomatic 46) crates/codegen/xai-grok-pager/src/app/agent_view/elicitation.rs:22 — AgentView::handle_elicitation_key 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.
  • AgentView::handle_question_mouse (cyclomatic 45) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:583 — AgentView::handle_question_mouse 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.
  • AgentView::handle_workflows_overlay_input (cyclomatic 45) crates/codegen/xai-grok-pager/src/app/agent_view/workflows_overlay.rs:80 — AgentView::handle_workflows_overlay_input 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.
  • AgentView::handle_extensions_modal_mouse_with_copy (cyclomatic 42) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1156 — AgentView::handle_extensions_modal_mouse_with_copy 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.
  • AgentView::handle_bg_tasks_key (cyclomatic 38) crates/codegen/xai-grok-pager/src/app/agent_view/panes.rs:965 — AgentView::handle_bg_tasks_key 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.
  • AgentView::handle_plan_feedback_key (cyclomatic 32) crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:741 — AgentView::handle_plan_feedback_key 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.
  • AgentView::handle_queue_key (cyclomatic 31) crates/codegen/xai-grok-pager/src/app/agent_view/queue.rs:517 — AgentView::handle_queue_key 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.
  • AgentView::handle_scrollback_key (cyclomatic 30) crates/codegen/xai-grok-pager/src/app/agent_view/panes.rs:20 — AgentView::handle_scrollback_key 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.
  • AgentView::handle_scrollback_click (cyclomatic 30) crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:1082 — AgentView::handle_scrollback_click 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.
  • AgentView::extensions_action_target (cyclomatic 29) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:480 — AgentView::extensions_action_target 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.
  • + 14 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×37
  • Duplicated block (13 lines × 2) crates/codegen/xai-fast-worktree/src/api.rs:1103 — crates/codegen/xai-fast-worktree/src/api.rs:1103-1115 | crates/codegen/xai-fast-worktree/src/api.rs:1268-1280 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:350 — crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:350-362 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:383-395 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/git/index.rs:207 — crates/codegen/xai-fast-worktree/src/git/index.rs:207-219 | crates/codegen/xai-fast-worktree/src/git/index.rs:237-249 — both copies are in the same file, so extract the 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) crates/codegen/xai-fast-worktree/src/overlay/snapshot.rs:311 — crates/codegen/xai-fast-worktree/src/overlay/snapshot.rs:311-323 | crates/codegen/xai-fast-worktree/src/overlay/snapshot.rs:377-389 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/config.rs:404 — crates/codegen/xai-grok-agent/src/config.rs:404-416 | crates/codegen/xai-grok-agent/src/config.rs:482-494 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/plugins/discovery.rs:718 — crates/codegen/xai-grok-agent/src/plugins/discovery.rs:718-730 | crates/codegen/xai-grok-agent/src/plugins/discovery.rs:734-746 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-memory/src/storage.rs:233 — crates/codegen/xai-grok-memory/src/storage.rs:233-245 | crates/codegen/xai-grok-memory/src/storage.rs:265-277 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-minimal/src/panel.rs:157 — crates/codegen/xai-grok-pager-minimal/src/panel.rs:157-169 | crates/codegen/xai-grok-pager-minimal/src/panel.rs:208-220 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/input.rs:487 — crates/codegen/xai-grok-pager/src/app/agent_view/input.rs:487-499 | crates/codegen/xai-grok-pager/src/app/agent_view/input.rs:703-715 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:474 — crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:474-486 | crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:521-533 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:411 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:411-423 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1261-1273 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs` 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. 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 (13 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:279 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:279-291 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1193-1205 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:346 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:346-358 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:504-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.
  • Duplicated block (13 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/blocks/thinking.rs:344 — crates/codegen/xai-grok-pager/src/scrollback/blocks/thinking.rs:344-356 | crates/codegen/xai-grok-pager/src/scrollback/blocks/thinking.rs:420-432 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/agent.rs:297 — crates/codegen/xai-grok-pager/src/views/agent.rs:297-309 | crates/codegen/xai-grok-pager/src/views/agent.rs:311-323 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:201 — crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:201-213 | crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:254-266 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:137 — crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:137-149 | crates/codegen/xai-grok-pager/src/views/slash_dropdown.rs:208-220 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs` and `crates/codegen/xai-grok-pager/src/views/slash_dropdown.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 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 (13 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/peek.rs:788 — crates/codegen/xai-grok-pager/src/views/dashboard/peek.rs:788-800 | crates/codegen/xai-grok-pager/src/views/session_title.rs:107-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.
  • Duplicated block (13 lines × 2) crates/codegen/xai-grok-pager/src/views/welcome/hero_box.rs:535 — crates/codegen/xai-grok-pager/src/views/welcome/hero_box.rs:535-547 | crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:1623-1635 — 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) crates/codegen/xai-grok-sampler/src/client.rs:1330 — crates/codegen/xai-grok-sampler/src/client.rs:1330-1342 | crates/codegen/xai-grok-sampler/src/client.rs:1687-1699 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-sampler/src/doom_loop_recovery.rs:235 — crates/codegen/xai-grok-sampler/src/doom_loop_recovery.rs:235-247 | crates/codegen/xai-grok-sampler/src/doom_loop_recovery.rs:259-271 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:249 — crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:249-261 | crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:422-434 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/agent/feedback_client.rs:256 — crates/codegen/xai-grok-shell/src/agent/feedback_client.rs:256-268 | crates/codegen/xai-grok-shell/src/agent/feedback_client.rs:290-302 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/extensions/session_updates.rs:160 — crates/codegen/xai-grok-shell/src/extensions/session_updates.rs:160-172 | crates/codegen/xai-grok-shell/src/extensions/session_updates.rs:413-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.
  • Duplicated block (13 lines × 2) crates/codegen/xai-grok-shell/src/extensions/suggest/history_provider.rs:262 — crates/codegen/xai-grok-shell/src/extensions/suggest/history_provider.rs:262-274 | crates/codegen/xai-grok-shell/src/extensions/suggest/history_provider.rs:326-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.
  • + 12 more in this group — see findings.md.
D1 · Cyclomatic Complexity · SessionActor · ×35
  • SessionActor::handle_turn_input_inner (cyclomatic 124) crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:503 — SessionActor::handle_turn_input_inner has cyclomatic complexity 124 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SessionActor::process_conversation_turn_inner (cyclomatic 111) crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:2615 — SessionActor::process_conversation_turn_inner has cyclomatic complexity 111 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SessionActor::execute_builtin_slash_command (cyclomatic 108) crates/codegen/xai-grok-shell/src/session/acp_session_impl/slash_exec.rs:5 — SessionActor::execute_builtin_slash_command has cyclomatic complexity 108 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SessionActor::cancel_running_task (cyclomatic 101) crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:251 — SessionActor::cancel_running_task has cyclomatic complexity 101 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SessionActor::run_compact_inner (cyclomatic 93) crates/codegen/xai-grok-shell/src/session/compaction.rs:922 — SessionActor::run_compact_inner has cyclomatic complexity 93 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SessionActor::execute_tool_calls_batch (cyclomatic 67) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:484 — SessionActor::execute_tool_calls_batch 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.
  • SessionActor::send_tool_call_start (cyclomatic 67) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:2321 — SessionActor::send_tool_call_start has cyclomatic complexity 67 (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.
  • SessionActor::prepare_tool_call (cyclomatic 63) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:1445 — SessionActor::prepare_tool_call 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.
  • SessionActor::handle_sampling_failure (cyclomatic 52) crates/codegen/xai-grok-shell/src/session/acp_session_impl/sampler_turn.rs:1189 — SessionActor::handle_sampling_failure 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.
  • SessionActor::handle_sampling_event (cyclomatic 46) crates/codegen/xai-grok-shell/src/session/acp_session_impl/sampling_events.rs:105 — SessionActor::handle_sampling_event 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.
  • SessionActor::handle_plugins_action (cyclomatic 39) crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:362 — SessionActor::handle_plugins_action has cyclomatic complexity 39 (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.
  • SessionActor::drain_goal_updates_with_extra (cyclomatic 34) crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal.rs:1673 — SessionActor::drain_goal_updates_with_extra 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.
  • SessionActor::run_v2_capture_worker (cyclomatic 34) crates/codegen/xai-grok-shell/src/session/acp_session_impl/memory_capture.rs:657 — SessionActor::run_v2_capture_worker 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.
  • SessionActor::handle_rewind (cyclomatic 34) crates/codegen/xai-grok-shell/src/session/acp_session_impl/rewind.rs:121 — SessionActor::handle_rewind 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.
  • SessionActor::manage_workflow_run (cyclomatic 32) crates/codegen/xai-grok-shell/src/session/acp_session_impl/workflow.rs:100 — SessionActor::manage_workflow_run 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.
  • SessionActor::handle_hooks_action (cyclomatic 31) crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:133 — SessionActor::handle_hooks_action 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.
  • SessionActor::maybe_start_running_task (cyclomatic 30) crates/codegen/xai-grok-shell/src/session/acp_session_impl/notification_drain.rs:119 — SessionActor::maybe_start_running_task 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.
  • SessionActor::queue_input (cyclomatic 29) crates/codegen/xai-grok-shell/src/session/acp_session_impl/prompt_queue.rs:113 — SessionActor::queue_input 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.
  • SessionActor::maybe_fire_laziness_check (cyclomatic 28) crates/codegen/xai-grok-shell/src/session/acp_session_impl/laziness.rs:277 — SessionActor::maybe_fire_laziness_check has cyclomatic complexity 28 (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.
  • SessionActor::execute_v2_dream (cyclomatic 26) crates/codegen/xai-grok-shell/src/session/acp_session_impl/v2_memory_dream.rs:748 — SessionActor::execute_v2_dream has cyclomatic complexity 26 (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.
  • SessionActor::flush_v2_capture (cyclomatic 25) crates/codegen/xai-grok-shell/src/session/acp_session_impl/memory_capture.rs:1071 — SessionActor::flush_v2_capture 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.
  • SessionActor::handle_xai_session_notification (cyclomatic 25) crates/codegen/xai-grok-shell/src/session/acp_session_impl/updates.rs:635 — SessionActor::handle_xai_session_notification 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.
  • SessionActor::maybe_run_goal_planner (cyclomatic 23) crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal_support.rs:1157 — SessionActor::maybe_run_goal_planner 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.
  • SessionActor::run_memory_flush (cyclomatic 23) crates/codegen/xai-grok-shell/src/session/acp_session_impl/memory_dream.rs:541 — SessionActor::run_memory_flush 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.
  • SessionActor::handle_recap (cyclomatic 22) crates/codegen/xai-grok-shell/src/session/acp_session_impl/recap.rs:271 — SessionActor::handle_recap 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.
  • + 10 more in this group — see findings.md.
D2 · Cognitive Complexity · xai_grok_markdown · ×30
  • xai_grok_markdown::mermaid::layout_sequence (cognitive 128) crates/codegen/xai-grok-markdown/src/mermaid.rs:3639 — xai_grok_markdown::mermaid::layout_sequence has cognitive complexity 128 (threshold 15). Drivers by points: if/else 39 (93 pts), loops 12 (18 pts), match/switch 6 (15 pts), boolean chains 2 (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.
  • xai_grok_markdown::latex::commands::render_command (cognitive 69) crates/codegen/xai-grok-markdown/src/latex/commands.rs:185 — xai_grok_markdown::latex::commands::render_command has cognitive complexity 69 (threshold 15). Drivers by points: if/else 22 (47 pts), match/switch 7 (16 pts), boolean chains 3, loops 1 (3 pts) (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.
  • xai_grok_markdown::parse::cell_word_separator (cognitive 67) crates/codegen/xai-grok-markdown/src/parse.rs:226 — xai_grok_markdown::parse::cell_word_separator has cognitive complexity 67 (threshold 15). Drivers by points: if/else 27 (51 pts), match/switch 2 (8 pts), boolean chains 5, loops 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.
  • xai_grok_markdown::mermaid::place_td (cognitive 64) crates/codegen/xai-grok-markdown/src/mermaid.rs:2344 — xai_grok_markdown::mermaid::place_td has cognitive complexity 64 (threshold 15). Drivers by points: if/else 22 (53 pts), loops 7 (10 pts), boolean chains 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.
  • xai_grok_markdown::mermaid::layout_canvas (cognitive 58) crates/codegen/xai-grok-markdown/src/mermaid.rs:1868 — xai_grok_markdown::mermaid::layout_canvas has cognitive complexity 58 (threshold 15). Drivers by points: if/else 22 (43 pts), match/switch 5 (8 pts), loops 5, 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.
  • xai_grok_markdown::latex_delimiters::find_display_close (cognitive 55) crates/codegen/xai-grok-markdown/src/latex_delimiters.rs:636 — xai_grok_markdown::latex_delimiters::find_display_close has cognitive complexity 55 (threshold 15). Drivers by points: if/else 13 (40 pts), loops 3 (8 pts), match/switch 2 (5 pts), boolean chains 2 (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.
  • xai_grok_markdown::mermaid::order_ranks (cognitive 55) crates/codegen/xai-grok-markdown/src/mermaid.rs:2672 — xai_grok_markdown::mermaid::order_ranks has cognitive complexity 55 (threshold 15). Drivers by points: if/else 13 (33 pts), loops 9 (20 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.
  • xai_grok_markdown::mermaid::parse_class (cognitive 51) crates/codegen/xai-grok-markdown/src/mermaid.rs:980 — xai_grok_markdown::mermaid::parse_class has cognitive complexity 51 (threshold 15). Drivers by points: if/else 16 (38 pts), match/switch 3 (8 pts), boolean chains 3, loops 2 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_markdown::latex::environments::env_rows_to_strings (cognitive 50) crates/codegen/xai-grok-markdown/src/latex/environments.rs:103 — xai_grok_markdown::latex::environments::env_rows_to_strings has cognitive complexity 50 (threshold 15). Drivers by points: if/else 16 (36 pts), loops 5 (10 pts), boolean chains 2, 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.
  • xai_grok_markdown::mermaid::parse_sequence (cognitive 49) crates/codegen/xai-grok-markdown/src/mermaid.rs:3440 — xai_grok_markdown::mermaid::parse_sequence has cognitive complexity 49 (threshold 15). Drivers by points: if/else 14 (38 pts), match/switch 3 (9 pts), loops 2 (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.
  • xai_grok_markdown::mermaid::place_lr (cognitive 45) crates/codegen/xai-grok-markdown/src/mermaid.rs:2492 — xai_grok_markdown::mermaid::place_lr has cognitive complexity 45 (threshold 15). Drivers by points: if/else 15 (34 pts), loops 6 (9 pts), boolean chains 2 (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.
  • xai_grok_markdown::mermaid::relax_rank (cognitive 45) crates/codegen/xai-grok-markdown/src/mermaid.rs:2870 — xai_grok_markdown::mermaid::relax_rank has cognitive complexity 45 (threshold 15). Drivers by points: if/else 18 (33 pts), match/switch 3 (7 pts), loops 4, 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.
  • xai_grok_markdown::mermaid::parse_link (cognitive 37) crates/codegen/xai-grok-markdown/src/mermaid.rs:651 — xai_grok_markdown::mermaid::parse_link has cognitive complexity 37 (threshold 15). Drivers by points: if/else 16 (23 pts), loops 4 (8 pts), boolean chains 6 (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.
  • xai_grok_markdown::mermaid::wrap_label (cognitive 34) crates/codegen/xai-grok-markdown/src/mermaid.rs:2963 — xai_grok_markdown::mermaid::wrap_label has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 3 (7 pts), match/switch 1 (5 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.
  • xai_grok_markdown::parse::cell_wrap_joins (cognitive 34) crates/codegen/xai-grok-markdown/src/parse.rs:392 — xai_grok_markdown::parse::cell_wrap_joins has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (27 pts), match/switch 1 (5 pts), boolean chains 1, 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.
  • xai_grok_markdown::mermaid::assign_positions (cognitive 28) crates/codegen/xai-grok-markdown/src/mermaid.rs:2806 — xai_grok_markdown::mermaid::assign_positions has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 6 (11 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.
  • xai_grok_markdown::latex::environments::render_environment (cognitive 27) crates/codegen/xai-grok-markdown/src/latex/environments.rs:11 — xai_grok_markdown::latex::environments::render_environment has cognitive complexity 27 (threshold 15). Drivers by points: if/else 15 (25 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.
  • xai_grok_markdown::mermaid::parse_er (cognitive 25) crates/codegen/xai-grok-markdown/src/mermaid.rs:1258 — xai_grok_markdown::mermaid::parse_er has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 2, match/switch 1 (2 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.
  • xai_grok_markdown::mermaid::dfs_dag (cognitive 24) crates/codegen/xai-grok-markdown/src/mermaid.rs:3333 — xai_grok_markdown::mermaid::dfs_dag has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (23 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.
  • xai_grok_markdown::mermaid::parse_statement (cognitive 23) crates/codegen/xai-grok-markdown/src/mermaid.rs:319 — xai_grok_markdown::mermaid::parse_statement has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (16 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.
  • xai_grok_markdown::mermaid::parse_state (cognitive 23) crates/codegen/xai-grok-markdown/src/mermaid.rs:766 — xai_grok_markdown::mermaid::parse_state has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 2 (5 pts), loops 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.
  • xai_grok_markdown::mermaid::compute_ranks (cognitive 23) crates/codegen/xai-grok-markdown/src/mermaid.rs:3290 — xai_grok_markdown::mermaid::compute_ranks has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 4 (5 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.
  • xai_grok_markdown::mermaid::render_grouped (cognitive 21) crates/codegen/xai-grok-markdown/src/mermaid.rs:2065 — xai_grok_markdown::mermaid::render_grouped has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 5, boolean chains 4, match/switch 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.
  • xai_grok_markdown::mermaid::build_scope (cognitive 21) crates/codegen/xai-grok-markdown/src/mermaid.rs:2156 — xai_grok_markdown::mermaid::build_scope has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 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.
  • xai_grok_markdown::mermaid::parse_class_relation (cognitive 19) crates/codegen/xai-grok-markdown/src/mermaid.rs:1137 — xai_grok_markdown::mermaid::parse_class_relation has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), boolean chains 3, loops 2 (3 pts), 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.
  • + 5 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×28
  • Duplicated block (14 lines × 2) crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:215 — crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:215-228 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:250-263 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-markdown/src/latex/symbols.rs:4 — crates/codegen/xai-grok-markdown/src/latex/symbols.rs:4-17 | crates/codegen/xai-grok-markdown/src/latex/symbols.rs:54-67 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-memory/src/v2_consolidation.rs:1549 — crates/codegen/xai-grok-memory/src/v2_consolidation.rs:1549-1562 | crates/codegen/xai-grok-memory/src/v2_consolidation.rs:1855-1868 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-memory/src/v2_maintenance.rs:463 — crates/codegen/xai-grok-memory/src/v2_maintenance.rs:463-476 | crates/codegen/xai-grok-memory/src/v2_maintenance.rs:616-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 (14 lines × 2) crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:144 — crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:144-157 | crates/codegen/xai-grok-pager/src/views/file_search/dropdown.rs:80-93 — 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 × 2) crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:724 — crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:724-737 | crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:784-797 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/modal_window.rs:465 — crates/codegen/xai-grok-pager/src/views/modal_window.rs:465-478 | crates/codegen/xai-grok-pager/src/views/modal_window.rs:647-660 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:3053 — crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:3053-3066 | crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:3380-3393 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/tutorial.rs:160 — crates/codegen/xai-grok-pager/src/views/tutorial.rs:160-173 | crates/codegen/xai-grok-pager/src/views/tutorial.rs:200-213 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-sampler/src/client.rs:2094 — crates/codegen/xai-grok-sampler/src/client.rs:2094-2107 | crates/codegen/xai-grok-sampler/src/client.rs:2127-2140 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1625 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1625-1638 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1770-1783 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:132 — crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:132-145 | crates/codegen/xai-grok-shell/src/remote/workspaces_client.rs:110-123 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs` and `crates/codegen/xai-grok-shell/src/remote/workspaces_client.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 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 (14 lines × 2) crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal_support.rs:268 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal_support.rs:268-284 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal_support.rs:305-318 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:614 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:614-627 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:704-717 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:2112 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:2112-2125 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:2171-2184 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:2040 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:2040-2053 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:2062-2075 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/session/goal_planner.rs:286 — crates/codegen/xai-grok-shell/src/session/goal_planner.rs:286-299 | crates/codegen/xai-grok-shell/src/session/goal_strategist.rs:167-180 — 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) crates/codegen/xai-grok-shell/src/session/telemetry/read_profile.rs:230 — crates/codegen/xai-grok-shell/src/session/telemetry/read_profile.rs:230-243 | crates/codegen/xai-grok-shell/src/session/telemetry/read_profile.rs: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.
  • Duplicated block (14 lines × 2) crates/codegen/xai-grok-shell/src/tools/notification_bridge.rs:408 — crates/codegen/xai-grok-shell/src/tools/notification_bridge.rs:408-421 | crates/codegen/xai-grok-shell/src/tools/notification_bridge.rs:547-560 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs:786 — crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs:786-799 | crates/codegen/xai-grok-tools/src/computer/local/static_shell.rs:192-205 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs` and `crates/codegen/xai-grok-tools/src/computer/local/static_shell.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 49 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 (14 lines × 2) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:461 — crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:461-474 | crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:494-507 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs:371 — crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs:371-384 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/wait_tasks.rs:228-241 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/wait_tasks.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 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 (14 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/client.rs:608 — crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/client.rs:608-621 | crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/client.rs:653-666 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:645 — crates/codegen/xai-grok-agent/src/plugins/git_install.rs:645-658 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:667-680 — before extracting anything, compare `crates/codegen/xai-grok-agent/src/plugins/git_install.rs` and `crates/codegen/xai-grok-plugin-marketplace/src/installer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 127 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 (14 lines × 2) crates/codegen/xai-grok-pager/src/views/goal_detail.rs:820 — crates/codegen/xai-grok-pager/src/views/goal_detail.rs:820-834 | crates/codegen/xai-grok-pager/src/views/goal_detail.rs:899-912 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 3 more in this group — see findings.md.
D2 · Cognitive Complexity · xai_fast_worktree · ×26
  • xai_fast_worktree::api::try_btrfs_remove_from_metadata_inner (cognitive 83) crates/codegen/xai-fast-worktree/src/api.rs:1089 — xai_fast_worktree::api::try_btrfs_remove_from_metadata_inner has cognitive complexity 83 (threshold 15). Drivers by points: if/else 19 (68 pts), match/switch 1 (8 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 59). 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.
  • xai_fast_worktree::api::cleanup_orphaned_btrfs_snapshots_inner (cognitive 54) crates/codegen/xai-fast-worktree/src/api.rs:1254 — xai_fast_worktree::api::cleanup_orphaned_btrfs_snapshots_inner has cognitive complexity 54 (threshold 15). Drivers by points: if/else 13 (43 pts), loops 3 (6 pts), boolean chains 5 (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.
  • xai_fast_worktree::sync::apply_porcelain_v2_entries (cognitive 43) crates/codegen/xai-fast-worktree/src/sync.rs:298 — xai_fast_worktree::sync::apply_porcelain_v2_entries has cognitive complexity 43 (threshold 15). Drivers by points: if/else 15 (41 pts), boolean chains 1, loops 1 (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.
  • xai_fast_worktree::discovery::register_nfs_from_union (cognitive 42) crates/codegen/xai-fast-worktree/src/discovery.rs:292 — xai_fast_worktree::discovery::register_nfs_from_union has cognitive complexity 42 (threshold 15). Drivers by points: if/else 14 (34 pts), boolean chains 6, loops 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.
  • xai_fast_worktree::api::gc::reclaim_expired_worktrees (cognitive 33) crates/codegen/xai-fast-worktree/src/api/gc.rs:482 — xai_fast_worktree::api::gc::reclaim_expired_worktrees has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (23 pts), match/switch 2 (5 pts), boolean chains 4, 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.
  • xai_fast_worktree::bin::cli::main (cognitive 31) crates/codegen/xai-fast-worktree/src/bin/cli.rs:100 — xai_fast_worktree::bin::cli::main has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (23 pts), loops 2 (6 pts), boolean chains 1, 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.
  • xai_fast_worktree::overlay::snapshot::cleanup_orphaned_overlay_snapshots (cognitive 31) crates/codegen/xai-fast-worktree/src/overlay/snapshot.rs:360 — xai_fast_worktree::overlay::snapshot::cleanup_orphaned_overlay_snapshots has cognitive complexity 31 (threshold 15). Drivers by points: if/else 13 (26 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.
  • xai_fast_worktree::btrfs::detect::resolve_via_subvol_mount (cognitive 30) crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:245 — xai_fast_worktree::btrfs::detect::resolve_via_subvol_mount has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (27 pts), boolean chains 2, loops 1 (nesting depth added 18). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • xai_fast_worktree::btrfs::detect::resolve_bind_mount_source (cognitive 28) crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:134 — xai_fast_worktree::btrfs::detect::resolve_bind_mount_source has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (23 pts), match/switch 1 (4 pts), loops 1 (nesting depth added 17). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • xai_fast_worktree::bin::worktree_lifecycle_bench::runtime::run_contained_command_impl (cognitive 27) crates/codegen/xai-fast-worktree/src/bin/worktree_lifecycle_bench/runtime.rs:314 — xai_fast_worktree::bin::worktree_lifecycle_bench::runtime::run_contained_command_impl has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (14 pts), match/switch 6 (11 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.
  • xai_fast_worktree::git::worktree::remove_stale_worktree_registrations (cognitive 27) crates/codegen/xai-fast-worktree/src/git/worktree.rs:45 — xai_fast_worktree::git::worktree::remove_stale_worktree_registrations has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (18 pts), match/switch 4 (6 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.
  • xai_fast_worktree::copy::standalone::rewrite_origin_fetch_in_config (cognitive 26) crates/codegen/xai-fast-worktree/src/copy/standalone.rs:362 — xai_fast_worktree::copy::standalone::rewrite_origin_fetch_in_config has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (20 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.
  • xai_fast_worktree::api::cleanup_worktrees_in_with_delegate (cognitive 25) crates/codegen/xai-fast-worktree/src/api.rs:758 — xai_fast_worktree::api::cleanup_worktrees_in_with_delegate has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 2 (5 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.
  • xai_fast_worktree::git::probe::run_with_timeout (cognitive 24) crates/codegen/xai-fast-worktree/src/git/probe.rs:159 — xai_fast_worktree::git::probe::run_with_timeout has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (17 pts), match/switch 2 (4 pts), loops 2, 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.
  • xai_fast_worktree::copy::engine::copy_parallel (cognitive 23) crates/codegen/xai-fast-worktree/src/copy/engine.rs:28 — xai_fast_worktree::copy::engine::copy_parallel has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12, match/switch 5, loops 3 (4 pts), boolean chains 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.
  • xai_fast_worktree::git::safety::reachability::collect_reflog_tips (cognitive 23) crates/codegen/xai-fast-worktree/src/git/safety/reachability.rs:174 — xai_fast_worktree::git::safety::reachability::collect_reflog_tips has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (8 pts), match/switch 1 (2 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.
  • xai_fast_worktree::auto_gc::maybe_auto_gc (cognitive 21) crates/codegen/xai-fast-worktree/src/auto_gc.rs:365 — xai_fast_worktree::auto_gc::maybe_auto_gc has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10, match/switch 4 (6 pts), boolean chains 5 (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.
  • xai_fast_worktree::overlay::snapshot::try_remove_from_metadata (cognitive 21) crates/codegen/xai-fast-worktree/src/overlay/snapshot.rs:295 — xai_fast_worktree::overlay::snapshot::try_remove_from_metadata has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (18 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.
  • xai_fast_worktree::api::try_btrfs_remove (cognitive 20) crates/codegen/xai-fast-worktree/src/api.rs:914 — xai_fast_worktree::api::try_btrfs_remove has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (17 pts), match/switch 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.
  • xai_fast_worktree::copy::standalone::filter_packed_refs (cognitive 19) crates/codegen/xai-fast-worktree/src/copy/standalone.rs:537 — xai_fast_worktree::copy::standalone::filter_packed_refs has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, match/switch 1 (2 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.
  • xai_fast_worktree::copy::gitdir::copy_git_dir_with_workers (cognitive 18) crates/codegen/xai-fast-worktree/src/copy/gitdir.rs:83 — xai_fast_worktree::copy::gitdir::copy_git_dir_with_workers has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (7 pts), loops 3 (6 pts), match/switch 1 (3 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.
  • xai_fast_worktree::git::safety::working_tree::find_working_tree_content (cognitive 18) crates/codegen/xai-fast-worktree/src/git/safety/working_tree.rs:14 — xai_fast_worktree::git::safety::working_tree::find_working_tree_content has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 7 (11 pts), if/else 3 (4 pts), boolean chains 2, loops 1 (nesting depth added 5). 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.
  • xai_fast_worktree::bin::pool_perf_bench::compute_summary (cognitive 17) crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:512 — xai_fast_worktree::bin::pool_perf_bench::compute_summary has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (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.
  • xai_fast_worktree::discovery::scan_two_level_dir (cognitive 17) crates/codegen/xai-fast-worktree/src/discovery.rs:72 — xai_fast_worktree::discovery::scan_two_level_dir 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.
  • xai_fast_worktree::bin::pool_perf_bench::main (cognitive 16) crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:698 — xai_fast_worktree::bin::pool_perf_bench::main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (14 pts), 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, 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.
  • + 1 more in this group — see findings.md.
D5 · Coupling · Off the main sequence · ×22
  • Off the main sequence: prod-mc-cli-chat-proxy-types — prod-mc-cli-chat-proxy-types: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 6 project(s), so it's rigid to change.
  • Off the main sequence: ptyctl — ptyctl: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-crash-handler — xai-crash-handler: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-fsnotify — xai-fsnotify: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-gboom — xai-grok-gboom: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-pager-diff — xai-grok-pager-diff: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-plugin-marketplace — xai-grok-plugin-marketplace: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-tools-api — xai-grok-tools-api: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-workspace-client — xai-grok-workspace-client: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
  • Off the main sequence: xai-hooks-plugins-types — xai-hooks-plugins-types: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-workflow — xai-workflow: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-workspace-types — xai-grok-workspace-types: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-fast-worktree — xai-fast-worktree: abstractness 0.01, instability 0.00, distance 0.99 — zone of pain — concrete and depended on by 3 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-sandbox — xai-grok-sandbox: abstractness 0.03, instability 0.00, distance 0.97 — zone of pain — concrete and depended on by 10 project(s), so it's rigid to change.
  • Off the main sequence: xai-hunk-tracker — xai-hunk-tracker: abstractness 0.04, instability 0.00, distance 0.96 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-voice — xai-grok-voice: abstractness 0.10, instability 0.00, distance 0.90 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
  • Off the main sequence: xai-computer-hub-mcp-adapter — xai-computer-hub-mcp-adapter: abstractness 0.13, instability 0.00, distance 0.88 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-workspace-daemon — xai-grok-workspace-daemon: abstractness 0.13, instability 0.00, distance 0.88 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-sampling-types — xai-grok-sampling-types: abstractness 0.02, instability 0.13, distance 0.86 — zone of pain — concrete and depended on by 7 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-hooks — xai-grok-hooks: abstractness 0.00, instability 0.20, distance 0.80 — zone of pain — concrete and depended on by 4 project(s), so it's rigid to change.
  • Off the main sequence: xai-grok-compaction — xai-grok-compaction: abstractness 0.27, instability 0.00, distance 0.73 — zone of pain — concrete and depended on by 3 project(s), so it's rigid to change.
  • Off the main sequence: xai-file-utils — xai-file-utils: abstractness 0.07, instability 0.22, distance 0.70 — zone of pain — concrete and depended on by 7 project(s), so it's rigid to change.
D1 · Cyclomatic Complexity · xai_grok_workspace · ×21
  • xai_grok_workspace::permission::manager::spawn_permission_manager_with_pin (cyclomatic 140) crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs:438 — xai_grok_workspace::permission::manager::spawn_permission_manager_with_pin has cyclomatic complexity 140 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_workspace::folder_trust::collect_repo_config_kinds (cyclomatic 57) crates/codegen/xai-grok-workspace/src/folder_trust.rs:433 — xai_grok_workspace::folder_trust::collect_repo_config_kinds 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.
  • xai_grok_workspace::permission::grants::evaluate_bash (cyclomatic 37) crates/codegen/xai-grok-workspace/src/permission/grants.rs:547 — xai_grok_workspace::permission::grants::evaluate_bash 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.
  • xai_grok_workspace::permission::prompter::map_selected_outcome (cyclomatic 34) crates/codegen/xai-grok-workspace/src/permission/prompter.rs:903 — xai_grok_workspace::permission::prompter::map_selected_outcome 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.
  • xai_grok_workspace::bin::workspace_server::run (cyclomatic 31) crates/codegen/xai-grok-workspace/src/bin/workspace_server.rs:333 — xai_grok_workspace::bin::workspace_server::run has cyclomatic complexity 31 (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.
  • xai_grok_workspace::session::git::parse_porcelain_v2 (cyclomatic 30) crates/codegen/xai-grok-workspace/src/session/git.rs:1173 — xai_grok_workspace::session::git::parse_porcelain_v2 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.
  • xai_grok_workspace::file_system::git_status::git_status_impl (cyclomatic 23) crates/codegen/xai-grok-workspace/src/file_system/git_status.rs:111 — xai_grok_workspace::file_system::git_status::git_status_impl 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.
  • xai_grok_workspace::permission::sandbox_gate::decide (cyclomatic 22) crates/codegen/xai-grok-workspace/src/permission/sandbox_gate.rs:253 — xai_grok_workspace::permission::sandbox_gate::decide 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.
  • xai_grok_workspace::file_system::content::content_search_streaming (cyclomatic 21) crates/codegen/xai-grok-workspace/src/file_system/content.rs:131 — xai_grok_workspace::file_system::content::content_search_streaming 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.
  • xai_grok_workspace::file_system::file_tree::list_contents (cyclomatic 20) crates/codegen/xai-grok-workspace/src/file_system/file_tree.rs:373 — xai_grok_workspace::file_system::file_tree::list_contents 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.
  • xai_grok_workspace::permission::hub_permission::reply_to_outcome (cyclomatic 20) crates/codegen/xai-grok-workspace/src/permission/hub_permission.rs:197 — xai_grok_workspace::permission::hub_permission::reply_to_outcome has cyclomatic complexity 20 (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.
  • xai_grok_workspace::mcp::drive_server_starts (cyclomatic 19) crates/codegen/xai-grok-workspace/src/mcp.rs:480 — xai_grok_workspace::mcp::drive_server_starts 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.
  • xai_grok_workspace::session::git::status_ungated (cyclomatic 19) crates/codegen/xai-grok-workspace/src/session/git.rs:1476 — xai_grok_workspace::session::git::status_ungated 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.
  • xai_grok_workspace::permission::auto_mode::bash_command_is_routine (cyclomatic 17) crates/codegen/xai-grok-workspace/src/permission/auto_mode/mod.rs:619 — xai_grok_workspace::permission::auto_mode::bash_command_is_routine 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.
  • xai_grok_workspace::permission::auto_mode::build_classifier_messages (cyclomatic 17) crates/codegen/xai-grok-workspace/src/permission/auto_mode/mod.rs:1182 — xai_grok_workspace::permission::auto_mode::build_classifier_messages 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.
  • xai_grok_workspace::permission::grants::record_prompt_outcome (cyclomatic 17) crates/codegen/xai-grok-workspace/src/permission/grants.rs:1015 — xai_grok_workspace::permission::grants::record_prompt_outcome 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.
  • xai_grok_workspace::permission::grants::ps_dumps_environment (cyclomatic 16) crates/codegen/xai-grok-workspace/src/permission/grants.rs:157 — xai_grok_workspace::permission::grants::ps_dumps_environment 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.
  • xai_grok_workspace::permission::hub_gate::settle (cyclomatic 16) crates/codegen/xai-grok-workspace/src/permission/hub_gate.rs:300 — xai_grok_workspace::permission::hub_gate::settle 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.
  • xai_grok_workspace::session::file_state::rewind_files (cyclomatic 16) crates/codegen/xai-grok-workspace/src/session/file_state.rs:780 — xai_grok_workspace::session::file_state::rewind_files 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.
  • xai_grok_workspace::worktree::create_worktree_streaming_in (cyclomatic 16) crates/codegen/xai-grok-workspace/src/worktree/mod.rs:1128 — xai_grok_workspace::worktree::create_worktree_streaming_in 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.
  • xai_grok_workspace::worktree::create_worktree_from_worktree_streaming (cyclomatic 16) crates/codegen/xai-grok-workspace/src/worktree/mod.rs:1903 — xai_grok_workspace::worktree::create_worktree_from_worktree_streaming 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.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×21
  • Duplicated block (15 lines × 2) crates/codegen/xai-crash-handler/src/handler.rs:73 — crates/codegen/xai-crash-handler/src/handler.rs:73-87 | crates/codegen/xai-crash-handler/src/handler.rs:124-138 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/config.rs:1239 — crates/codegen/xai-grok-agent/src/config.rs:1239-1253 | crates/codegen/xai-grok-agent/src/config.rs:1265-1279 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:477 — crates/codegen/xai-grok-agent/src/plugins/git_install.rs:477-491 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:553-567 — before extracting anything, compare `crates/codegen/xai-grok-agent/src/plugins/git_install.rs` and `crates/codegen/xai-grok-plugin-marketplace/src/installer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 127 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 (15 lines × 2) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:581 — crates/codegen/xai-grok-agent/src/plugins/git_install.rs:581-595 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:621-635 — before extracting anything, compare `crates/codegen/xai-grok-agent/src/plugins/git_install.rs` and `crates/codegen/xai-grok-plugin-marketplace/src/installer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 127 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 (15 lines × 2) crates/codegen/xai-grok-memory/src/v2_access.rs:388 — crates/codegen/xai-grok-memory/src/v2_access.rs:388-402 | crates/codegen/xai-grok-memory/src/v2_access.rs:469-483 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:4084 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:4084-4098 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:4110-4124 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:176 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:176-190 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1162-1176 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs` 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. 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 (15 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:451 — crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:451-465 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1281-1295 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:388 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:388-402 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:535-549 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:273 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:273-287 | crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:419-433 — 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 (15 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2177 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2177-2191 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2272-2286 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:1277 — crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:1277-1291 | crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:1307-1321 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:573 — crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:573-587 | crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:594-608 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-sampler/src/client.rs:1358 — crates/codegen/xai-grok-sampler/src/client.rs:1358-1372 | crates/codegen/xai-grok-sampler/src/client.rs:1527-1541 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2182 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2182-2196 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2242-2256 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/session/acp_session_impl/laziness.rs:444 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/laziness.rs:444-458 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/laziness.rs:477-491 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:617 — crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:617-631 | crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:632-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 (15 lines × 2) crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:1219 — crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:1219-1234 | crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:1554-1568 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/config/mod.rs:767 — crates/codegen/xai-grok-shell/src/config/mod.rs:767-781 | crates/codegen/xai-grok-shell/src/config/mod.rs:796-810 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/remote/skills_client.rs:531 — crates/codegen/xai-grok-shell/src/remote/skills_client.rs:531-545 | crates/codegen/xai-grok-shell/src/remote/skills_client.rs:569-583 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-memory/src/v2_capture.rs:1581 — crates/codegen/xai-grok-memory/src/v2_capture.rs:1581-1595 | crates/codegen/xai-grok-memory/src/v2_consolidation.rs:1721-1735 — 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.
D1 · Cyclomatic Complexity · xai_grok_markdown · ×19
  • xai_grok_markdown::latex::commands::render_command (cyclomatic 80) crates/codegen/xai-grok-markdown/src/latex/commands.rs:185 — xai_grok_markdown::latex::commands::render_command has cyclomatic complexity 80 (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.
  • xai_grok_markdown::mermaid::layout_sequence (cyclomatic 62) crates/codegen/xai-grok-markdown/src/mermaid.rs:3639 — xai_grok_markdown::mermaid::layout_sequence 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.
  • xai_grok_markdown::mermaid::layout_canvas (cyclomatic 39) crates/codegen/xai-grok-markdown/src/mermaid.rs:1868 — xai_grok_markdown::mermaid::layout_canvas 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.
  • xai_grok_markdown::parse::cell_word_separator (cyclomatic 30) crates/codegen/xai-grok-markdown/src/parse.rs:226 — xai_grok_markdown::parse::cell_word_separator 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.
  • xai_grok_markdown::mermaid::parse_class (cyclomatic 29) crates/codegen/xai-grok-markdown/src/mermaid.rs:980 — xai_grok_markdown::mermaid::parse_class 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.
  • xai_grok_markdown::mermaid::place_td (cyclomatic 29) crates/codegen/xai-grok-markdown/src/mermaid.rs:2344 — xai_grok_markdown::mermaid::place_td 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.
  • xai_grok_markdown::latex::environments::env_rows_to_strings (cyclomatic 27) crates/codegen/xai-grok-markdown/src/latex/environments.rs:103 — xai_grok_markdown::latex::environments::env_rows_to_strings 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.
  • xai_grok_markdown::latex_delimiters::find_display_close (cyclomatic 25) crates/codegen/xai-grok-markdown/src/latex_delimiters.rs:636 — xai_grok_markdown::latex_delimiters::find_display_close 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.
  • xai_grok_markdown::mermaid::relax_rank (cyclomatic 25) crates/codegen/xai-grok-markdown/src/mermaid.rs:2870 — xai_grok_markdown::mermaid::relax_rank 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.
  • xai_grok_markdown::mermaid::parse_sequence (cyclomatic 25) crates/codegen/xai-grok-markdown/src/mermaid.rs:3440 — xai_grok_markdown::mermaid::parse_sequence 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.
  • xai_grok_markdown::mermaid::parse_link (cyclomatic 24) crates/codegen/xai-grok-markdown/src/mermaid.rs:651 — xai_grok_markdown::mermaid::parse_link 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.
  • xai_grok_markdown::mermaid::order_ranks (cyclomatic 24) crates/codegen/xai-grok-markdown/src/mermaid.rs:2672 — xai_grok_markdown::mermaid::order_ranks 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.
  • xai_grok_markdown::mermaid::place_lr (cyclomatic 23) crates/codegen/xai-grok-markdown/src/mermaid.rs:2492 — xai_grok_markdown::mermaid::place_lr 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.
  • xai_grok_markdown::mermaid::render_grouped (cyclomatic 18) crates/codegen/xai-grok-markdown/src/mermaid.rs:2065 — xai_grok_markdown::mermaid::render_grouped has cyclomatic complexity 18 (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. This is NOT this file's highest cyclomatic complexity: xai_grok_markdown::mermaid::flip_glyph_v (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.
  • xai_grok_markdown::latex::commands::render_sequence (cyclomatic 17) crates/codegen/xai-grok-markdown/src/latex/commands.rs:26 — xai_grok_markdown::latex::commands::render_sequence 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. This is NOT this file's highest cyclomatic complexity: xai_grok_markdown::latex::commands::format_fraction (cyclomatic 22) 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.
  • xai_grok_markdown::mermaid::parse_state (cyclomatic 17) crates/codegen/xai-grok-markdown/src/mermaid.rs:766 — xai_grok_markdown::mermaid::parse_state 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: xai_grok_markdown::mermaid::flip_glyph_v (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.
  • xai_grok_markdown::latex::environments::render_environment (cyclomatic 16) crates/codegen/xai-grok-markdown/src/latex/environments.rs:11 — xai_grok_markdown::latex::environments::render_environment 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.
  • xai_grok_markdown::mermaid::parse_graph (cyclomatic 16) crates/codegen/xai-grok-markdown/src/mermaid.rs:189 — xai_grok_markdown::mermaid::parse_graph 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: xai_grok_markdown::mermaid::flip_glyph_v (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.
  • xai_grok_markdown::mermaid::wrap_label (cyclomatic 16) crates/codegen/xai-grok-markdown/src/mermaid.rs:2963 — xai_grok_markdown::mermaid::wrap_label 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: xai_grok_markdown::mermaid::flip_glyph_v (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.
D1 · Cyclomatic Complexity · xai_grok_tools · ×19
  • xai_grok_tools::mcp_elicitation::validate::validate_field (cyclomatic 40) crates/codegen/xai-grok-tools/src/mcp_elicitation/validate.rs:62 — xai_grok_tools::mcp_elicitation::validate::validate_field 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.
  • xai_grok_tools::implementations::grok_build::read_file::run_read_file (cyclomatic 38) crates/codegen/xai-grok-tools/src/implementations/grok_build/read_file/mod.rs:396 — xai_grok_tools::implementations::grok_build::read_file::run_read_file 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.
  • xai_grok_tools::implementations::grok_build::search_replace::handle_replacement (cyclomatic 29) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:515 — xai_grok_tools::implementations::grok_build::search_replace::handle_replacement 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.
  • xai_grok_tools::implementations::codex::apply_patch::seek_sequence::seek_sequence (cyclomatic 26) crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/seek_sequence.rs:26 — xai_grok_tools::implementations::codex::apply_patch::seek_sequence::seek_sequence has cyclomatic complexity 26 (threshold 15). Of this number, 22 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_tools::implementations::grok_build::bash::contains_background_operator (cyclomatic 21) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:708 — xai_grok_tools::implementations::grok_build::bash::contains_background_operator 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.
  • xai_grok_tools::implementations::grok_build::read_file::extract_file_content_lines (cyclomatic 20) crates/codegen/xai-grok-tools/src/implementations/grok_build/read_file/mod.rs:292 — xai_grok_tools::implementations::grok_build::read_file::extract_file_content_lines has cyclomatic complexity 20 (threshold 15). Of this number, 18 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_tools::implementations::skills::skill::resolve_skill_internal_links (cyclomatic 20) crates/codegen/xai-grok-tools/src/implementations/skills/skill.rs:327 — xai_grok_tools::implementations::skills::skill::resolve_skill_internal_links 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.
  • xai_grok_tools::registry::types::explain_requirement_failure (cyclomatic 20) crates/codegen/xai-grok-tools/src/registry/types.rs:2193 — xai_grok_tools::registry::types::explain_requirement_failure 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.
  • xai_grok_tools::implementations::grok_build::grep::grep_progress_stream (cyclomatic 19) crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/mod.rs:436 — xai_grok_tools::implementations::grok_build::grep::grep_progress_stream has cyclomatic complexity 19 (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.
  • xai_grok_tools::implementations::grok_build::grep::rg_heading::render_rg_heading (cyclomatic 18) crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/rg_heading.rs:28 — xai_grok_tools::implementations::grok_build::grep::rg_heading::render_rg_heading 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.
  • xai_grok_tools::implementations::grok_build_hashline::benchmark::run_phase1_for_file (cyclomatic 18) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/benchmark.rs:362 — xai_grok_tools::implementations::grok_build_hashline::benchmark::run_phase1_for_file 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.
  • xai_grok_tools::implementations::skills::skill::apply_substitutions (cyclomatic 18) crates/codegen/xai-grok-tools/src/implementations/skills/skill.rs:228 — xai_grok_tools::implementations::skills::skill::apply_substitutions 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.
  • xai_grok_tools::computer::local::shell_state::shell_commands (cyclomatic 17) crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs:638 — xai_grok_tools::computer::local::shell_state::shell_commands 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.
  • xai_grok_tools::implementations::grok_build_hashline::edit::apply::apply_edits (cyclomatic 17) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/apply.rs:153 — xai_grok_tools::implementations::grok_build_hashline::edit::apply::apply_edits 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.
  • xai_grok_tools::util::command_display::peel_cd_prefix (cyclomatic 17) crates/codegen/xai-grok-tools/src/util/command_display.rs:97 — xai_grok_tools::util::command_display::peel_cd_prefix 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.
  • xai_grok_tools::computer::local::shell_state::ansi_c_quoted (cyclomatic 16) crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs:729 — xai_grok_tools::computer::local::shell_state::ansi_c_quoted has cyclomatic complexity 16 (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.
  • xai_grok_tools::implementations::codex::read_file::indentation::read_block (cyclomatic 16) crates/codegen/xai-grok-tools/src/implementations/codex/read_file/indentation.rs:155 — xai_grok_tools::implementations::codex::read_file::indentation::read_block 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.
  • xai_grok_tools::implementations::grok_build::grep::card::finalize_grep (cyclomatic 16) crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:86 — xai_grok_tools::implementations::grok_build::grep::card::finalize_grep has cyclomatic complexity 16 (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.
  • xai_grok_tools::util::base64_images::scan_payload_end (cyclomatic 16) crates/codegen/xai-grok-tools/src/util/base64_images.rs:72 — xai_grok_tools::util::base64_images::scan_payload_end has cyclomatic complexity 16 (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.
D2 · Cognitive Complexity · xai_grok_permission_rules · ×17
  • xai_grok_permission_rules::policy::shell_dash_c_script (cognitive 69) crates/codegen/xai-grok-permission-rules/src/policy.rs:420 — xai_grok_permission_rules::policy::shell_dash_c_script has cognitive complexity 69 (threshold 15). Drivers by points: if/else 28 (52 pts), boolean chains 8, match/switch 4 (8 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.
  • xai_grok_permission_rules::bash_command_splitting::env_scan (cognitive 62) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:302 — xai_grok_permission_rules::bash_command_splitting::env_scan has cognitive complexity 62 (threshold 15). Drivers by points: if/else 17 (50 pts), match/switch 3 (9 pts), boolean chains 2, loops 1 (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.
  • xai_grok_permission_rules::bash_permission_script::readers_allow (cognitive 39) crates/codegen/xai-grok-permission-rules/src/bash_permission_script.rs:219 — xai_grok_permission_rules::bash_permission_script::readers_allow has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (23 pts), boolean chains 9, match/switch 2 (6 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.
  • xai_grok_permission_rules::bash_command_splitting::strip_wrapper_command (cognitive 35) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:459 — xai_grok_permission_rules::bash_command_splitting::strip_wrapper_command has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 5 (10 pts), boolean chains 1, match/switch 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.
  • xai_grok_permission_rules::rules::parse_permission_rule (cognitive 35) crates/codegen/xai-grok-permission-rules/src/rules.rs:109 — xai_grok_permission_rules::rules::parse_permission_rule has cognitive complexity 35 (threshold 15). Drivers by points: if/else 19 (31 pts), boolean chains 2, match/switch 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.
  • xai_grok_permission_rules::bash_command_splitting::parse_plain_command_from_node (cognitive 28) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:921 — xai_grok_permission_rules::bash_command_splitting::parse_plain_command_from_node has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (24 pts), match/switch 1 (2 pts), boolean chains 1, 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.
  • xai_grok_permission_rules::shell_access::shell_command_invocations (cognitive 27) crates/codegen/xai-grok-permission-rules/src/shell_access.rs:954 — xai_grok_permission_rules::shell_access::shell_command_invocations has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 2 (7 pts), loops 3 (6 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.
  • xai_grok_permission_rules::bash_command_splitting::try_parse_word_only_commands_sequence (cognitive 25) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:53 — xai_grok_permission_rules::bash_command_splitting::try_parse_word_only_commands_sequence has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (19 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.
  • xai_grok_permission_rules::resolution::resolve_claude_settings_inner (cognitive 25) crates/codegen/xai-grok-permission-rules/src/resolution.rs:596 — xai_grok_permission_rules::resolution::resolve_claude_settings_inner has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 4, loops 2 (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.
  • xai_grok_permission_rules::git_content_filters::read_local_git_config_entries (cognitive 24) crates/codegen/xai-grok-permission-rules/src/git_content_filters.rs:61 — xai_grok_permission_rules::git_content_filters::read_local_git_config_entries has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 5 (7 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.
  • xai_grok_permission_rules::bash_command_splitting::strip_exec_prefix (cognitive 23) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:749 — xai_grok_permission_rules::bash_command_splitting::strip_exec_prefix has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 2 (4 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.
  • xai_grok_permission_rules::exec_risk::git_effective_cwd (cognitive 22) crates/codegen/xai-grok-permission-rules/src/exec_risk.rs:418 — xai_grok_permission_rules::exec_risk::git_effective_cwd has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (18 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.
  • xai_grok_permission_rules::managed_policy::url_match::decode_unreserved_escapes (cognitive 20) crates/codegen/xai-grok-permission-rules/src/managed_policy/url_match.rs:438 — xai_grok_permission_rules::managed_policy::url_match::decode_unreserved_escapes has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (16 pts), boolean chains 2, loops 1, match/switch 1 (nesting depth added 10). Of this number, 19 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_permission_rules::resolution::parse_toml_permission_section (cognitive 20) crates/codegen/xai-grok-permission-rules/src/resolution.rs:96 — xai_grok_permission_rules::resolution::parse_toml_permission_section has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (11 pts), match/switch 1 (5 pts), loops 2 (4 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.
  • xai_grok_permission_rules::managed_policy::apply_policy_source (cognitive 19) crates/codegen/xai-grok-permission-rules/src/managed_policy/mod.rs:258 — xai_grok_permission_rules::managed_policy::apply_policy_source has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 2, match/switch 1 (2 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.
  • xai_grok_permission_rules::managed_policy::url_match::warn_on_unmatchable_allow_url (cognitive 17) crates/codegen/xai-grok-permission-rules/src/managed_policy/url_match.rs:10 — xai_grok_permission_rules::managed_policy::url_match::warn_on_unmatchable_allow_url has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 4, match/switch 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • xai_grok_permission_rules::bash_command_splitting::strip_command_prefix (cognitive 16) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:795 — xai_grok_permission_rules::bash_command_splitting::strip_command_prefix has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 6, loops 1, match/switch 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.
D2 · Cognitive Complexity · xai_grok_pager_render · ×17
  • xai_grok_pager_render::render::osc8::scan_logical_line (cognitive 65) crates/codegen/xai-grok-pager-render/src/render/osc8.rs:489 — xai_grok_pager_render::render::osc8::scan_logical_line has cognitive complexity 65 (threshold 15). Drivers by points: if/else 22 (52 pts), boolean chains 8, loops 4 (5 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.
  • xai_grok_pager_render::render::highlight::paint_match_highlights (cognitive 55) crates/codegen/xai-grok-pager-render/src/render/highlight.rs:14 — xai_grok_pager_render::render::highlight::paint_match_highlights has cognitive complexity 55 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 7 (19 pts), boolean chains 4 (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.
  • xai_grok_pager_render::location_path::shorten_location_path (cognitive 41) crates/codegen/xai-grok-pager-render/src/location_path.rs:12 — xai_grok_pager_render::location_path::shorten_location_path has cognitive complexity 41 (threshold 15). Drivers by points: if/else 18 (21 pts), boolean chains 19, 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, 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.
  • xai_grok_pager_render::render::tool_paths::shorten_path (cognitive 29) crates/codegen/xai-grok-pager-render/src/render/tool_paths.rs:124 — xai_grok_pager_render::render::tool_paths::shorten_path has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 2, 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.
  • xai_grok_pager_render::terminal::detect_terminal_brand_from_env (cognitive 29) crates/codegen/xai-grok-pager-render/src/terminal/mod.rs:659 — xai_grok_pager_render::terminal::detect_terminal_brand_from_env has cognitive complexity 29 (threshold 15). Drivers by points: if/else 19 (22 pts), boolean chains 7 (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.
  • xai_grok_pager_render::render::image_overlay::render_image_overlay_inner (cognitive 26) crates/codegen/xai-grok-pager-render/src/render/image_overlay.rs:55 — xai_grok_pager_render::render::image_overlay::render_image_overlay_inner has cognitive complexity 26 (threshold 15). Drivers by points: if/else 18 (22 pts), boolean chains 4 (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.
  • xai_grok_pager_render::render::bidi::logical_slice_for_visual_cols (cognitive 24) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:199 — xai_grok_pager_render::render::bidi::logical_slice_for_visual_cols has cognitive complexity 24 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 3, loops 2, match/switch 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.
  • xai_grok_pager_render::render::bidi::visual_col_to_logical_col (cognitive 20) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:280 — xai_grok_pager_render::render::bidi::visual_col_to_logical_col has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (13 pts), match/switch 1 (3 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.
  • xai_grok_pager_render::terminal::probe::write_all_until (cognitive 20) crates/codegen/xai-grok-pager-render/src/terminal/probe.rs:54 — xai_grok_pager_render::terminal::probe::write_all_until has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 1 (3 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager_render::render::preview_overlay::render_content_lines (cognitive 19) crates/codegen/xai-grok-pager-render/src/render/preview_overlay.rs:165 — xai_grok_pager_render::render::preview_overlay::render_content_lines has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (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.
  • xai_grok_pager_render::render::bidi::visual_line_with_level (cognitive 18) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:133 — xai_grok_pager_render::render::bidi::visual_line_with_level has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager_render::clipboard::trust::resolve_copy_decision (cognitive 17) crates/codegen/xai-grok-pager-render/src/clipboard/trust.rs:178 — xai_grok_pager_render::clipboard::trust::resolve_copy_decision has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, match/switch 1 (2 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.
  • xai_grok_pager_render::render::bidi::reorder_body (cognitive 17) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:481 — xai_grok_pager_render::render::bidi::reorder_body has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (7 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.
  • xai_grok_pager_render::render::line_utils::fit_line_to_width (cognitive 17) crates/codegen/xai-grok-pager-render/src/render/line_utils.rs:90 — xai_grok_pager_render::render::line_utils::fit_line_to_width has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager_render::render::color::blend_area (cognitive 16) crates/codegen/xai-grok-pager-render/src/render/color.rs:226 — xai_grok_pager_render::render::color::blend_area has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 2 (3 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.
  • xai_grok_pager_render::render::wrapping::word_wrap_line_with_joiners (cognitive 16) crates/codegen/xai-grok-pager-render/src/render/wrapping.rs:331 — xai_grok_pager_render::render::wrapping::word_wrap_line_with_joiners has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), match/switch 3 (5 pts), boolean chains 1, 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, 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.
  • xai_grok_pager_render::terminal::image::place_inline_image (cognitive 16) crates/codegen/xai-grok-pager-render/src/terminal/image.rs:494 — xai_grok_pager_render::terminal::image::place_inline_image has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 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.
D2 · Cognitive Complexity · MvpAgent · ×15
  • MvpAgent::prompt (cognitive 86) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1032 — MvpAgent::prompt has cognitive complexity 86 (threshold 15). Drivers by points: if/else 40 (57 pts), match/switch 8 (17 pts), loops 2 (8 pts), boolean chains 4 (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.
  • MvpAgent::spawn_and_register_session (cognitive 79) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:4134 — MvpAgent::spawn_and_register_session has cognitive complexity 79 (threshold 15). Drivers by points: if/else 43 (51 pts), match/switch 10 (15 pts), boolean chains 9, loops 3 (4 pts) (nesting depth added 14). 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.
  • MvpAgent::ext_notification (cognitive 73) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2381 — MvpAgent::ext_notification has cognitive complexity 73 (threshold 15). Drivers by points: if/else 39 (67 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.
  • MvpAgent::authenticate (cognitive 57) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:635 — MvpAgent::authenticate has cognitive complexity 57 (threshold 15). Drivers by points: if/else 21 (42 pts), match/switch 7 (15 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.
  • MvpAgent::attach_session (cognitive 48) crates/codegen/xai-grok-shell/src/agent/mvp_agent/session_setup.rs:929 — MvpAgent::attach_session has cognitive complexity 48 (threshold 15). Drivers by points: if/else 31 (39 pts), boolean chains 6, match/switch 2 (3 pts) (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.
  • MvpAgent::new_session_inner_impl (cognitive 46) crates/codegen/xai-grok-shell/src/agent/mvp_agent/session_setup.rs:388 — MvpAgent::new_session_inner_impl has cognitive complexity 46 (threshold 15). Drivers by points: if/else 26 (28 pts), match/switch 8 (10 pts), boolean chains 8 (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.
  • MvpAgent::initialize (cognitive 36) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:130 — MvpAgent::initialize has cognitive complexity 36 (threshold 15). Drivers by points: if/else 25 (28 pts), boolean chains 4, match/switch 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.
  • MvpAgent::retry_subscription_check (cognitive 30) crates/codegen/xai-grok-shell/src/agent/mvp_agent/mod.rs:1494 — MvpAgent::retry_subscription_check has cognitive complexity 30 (threshold 15). Drivers by points: if/else 15 (25 pts), match/switch 1 (3 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.
  • MvpAgent::forward_raw_replay_line (cognitive 29) crates/codegen/xai-grok-shell/src/agent/mvp_agent/replay.rs:79 — MvpAgent::forward_raw_replay_line has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (25 pts), boolean chains 3, 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.
  • MvpAgent::replay_session_updates (cognitive 19) crates/codegen/xai-grok-shell/src/agent/mvp_agent/replay.rs:184 — MvpAgent::replay_session_updates has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 2, loops 1, 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, 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.
  • MvpAgent::find_orphaned_background_tasks (cognitive 18) crates/codegen/xai-grok-shell/src/agent/mvp_agent/mod.rs:1285 — MvpAgent::find_orphaned_background_tasks has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 2 (3 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.
  • MvpAgent::handle_evict_sessions (cognitive 17) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:2523 — MvpAgent::handle_evict_sessions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 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.
  • MvpAgent::resolve_agent_definition (cognitive 17) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:3906 — MvpAgent::resolve_agent_definition has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (10 pts), match/switch 4 (5 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.
  • MvpAgent::spawn_heap_profile_monitor (cognitive 17) crates/codegen/xai-grok-shell/src/agent/mvp_agent/heap_profile.rs:54 — MvpAgent::spawn_heap_profile_monitor has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 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.
  • MvpAgent::add_local_workspace_mid_session (cognitive 16) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:1079 — MvpAgent::add_local_workspace_mid_session has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (11 pts), match/switch 5 (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.
D2 · Cognitive Complexity · ScrollbackState · ×14
  • ScrollbackState::prepare_layout (cognitive 71) crates/codegen/xai-grok-pager/src/scrollback/state/mod.rs:1318 — ScrollbackState::prepare_layout has cognitive complexity 71 (threshold 15). Drivers by points: if/else 33 (55 pts), boolean chains 13, loops 1 (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.
  • ScrollbackState::ensure_selected_visible (cognitive 35) crates/codegen/xai-grok-pager/src/scrollback/state/nav.rs:592 — ScrollbackState::ensure_selected_visible has cognitive complexity 35 (threshold 15). Drivers by points: if/else 23 (29 pts), boolean chains 6 (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.
  • ScrollbackState::finish_running_with_time (cognitive 27) crates/codegen/xai-grok-pager/src/scrollback/state/mod.rs:1108 — ScrollbackState::finish_running_with_time has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 3, 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.
  • ScrollbackState::measure_window_exact (cognitive 25) crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:662 — ScrollbackState::measure_window_exact has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 5, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ScrollbackState::patch_virtual_y_for_dirty (cognitive 25) crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:1085 — ScrollbackState::patch_virtual_y_for_dirty has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 5 (6 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.
  • ScrollbackState::settle_visible_measurements (cognitive 24) crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:734 — ScrollbackState::settle_visible_measurements has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (20 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.
  • ScrollbackState::rebuild_with_fold_anchor (cognitive 20) crates/codegen/xai-grok-pager/src/scrollback/state/selection.rs:360 — ScrollbackState::rebuild_with_fold_anchor has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 6 (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.
  • ScrollbackState::expand_all_groups (cognitive 19) crates/codegen/xai-grok-pager/src/scrollback/state/selection.rs:580 — ScrollbackState::expand_all_groups has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (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.
  • ScrollbackState::update_dirty_entry_heights (cognitive 18) crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:970 — ScrollbackState::update_dirty_entry_heights 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.
  • ScrollbackState::prev_response (cognitive 18) crates/codegen/xai-grok-pager/src/scrollback/state/nav.rs:254 — ScrollbackState::prev_response 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. This shape REPEATS in the file: one other method here (ScrollbackState::next_response) 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.
  • ScrollbackState::next_response (cognitive 18) crates/codegen/xai-grok-pager/src/scrollback/state/nav.rs:294 — ScrollbackState::next_response 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. This shape REPEATS in the file: one other method here (ScrollbackState::prev_response) 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.
  • ScrollbackState::extend_layout_cache_with_new_entry (cognitive 17) crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:1174 — ScrollbackState::extend_layout_cache_with_new_entry has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (14 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, 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.
  • ScrollbackState::prev_turn (cognitive 17) crates/codegen/xai-grok-pager/src/scrollback/state/nav.rs:179 — ScrollbackState::prev_turn has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 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.
  • ScrollbackState::replace_tool_block (cognitive 16) crates/codegen/xai-grok-pager/src/scrollback/state/mod.rs:980 — ScrollbackState::replace_tool_block has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 4, match/switch 2 (3 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · xai_grok_agent · ×14
  • xai_grok_agent::prompt::skills::dedupe_skills (cognitive 46) crates/codegen/xai-grok-agent/src/prompt/skills.rs:385 — xai_grok_agent::prompt::skills::dedupe_skills has cognitive complexity 46 (threshold 15). Drivers by points: if/else 11 (43 pts), boolean chains 2, loops 1 (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.
  • xai_grok_agent::plugins::discovery::discover_plugins (cognitive 42) crates/codegen/xai-grok-agent/src/plugins/discovery.rs:256 — xai_grok_agent::plugins::discovery::discover_plugins has cognitive complexity 42 (threshold 15). Drivers by points: if/else 11 (24 pts), loops 10 (18 pts) (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • xai_grok_agent::prompt::agents_md::read_agents_config_with_roots (cognitive 40) crates/codegen/xai-grok-agent/src/prompt/agents_md.rs:225 — xai_grok_agent::prompt::agents_md::read_agents_config_with_roots has cognitive complexity 40 (threshold 15). Drivers by points: if/else 14 (28 pts), loops 5 (8 pts), boolean chains 4 (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.
  • xai_grok_agent::plugins::git_install::parse_install_source (cognitive 33) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:43 — xai_grok_agent::plugins::git_install::parse_install_source has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (26 pts), match/switch 3 (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.
  • xai_grok_agent::discovery::by_name_in_cwd_with_plugins_and_home (cognitive 28) crates/codegen/xai-grok-agent/src/discovery.rs:435 — xai_grok_agent::discovery::by_name_in_cwd_with_plugins_and_home has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 3 (8 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.
  • xai_grok_agent::plugins::marketplace::installed_plugin_keys (cognitive 22) crates/codegen/xai-grok-agent/src/plugins/marketplace.rs:221 — xai_grok_agent::plugins::marketplace::installed_plugin_keys has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 2 (5 pts), loops 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.
  • xai_grok_agent::discovery::plugin_agents (cognitive 21) crates/codegen/xai-grok-agent/src/discovery.rs:332 — xai_grok_agent::discovery::plugin_agents has cognitive complexity 21 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 3 (6 pts), match/switch 1 (4 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.
  • xai_grok_agent::plugins::git_install::discover_plugins_in_dir (cognitive 21) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:539 — xai_grok_agent::plugins::git_install::discover_plugins_in_dir has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 2 (5 pts), loops 1 (2 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.
  • xai_grok_agent::plugins::marketplace::resolve_known_marketplaces_in (cognitive 21) crates/codegen/xai-grok-agent/src/plugins/marketplace.rs:164 — xai_grok_agent::plugins::marketplace::resolve_known_marketplaces_in has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 3 (6 pts), loops 2 (4 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.
  • xai_grok_agent::prompt::user_message::format_rules_section (cognitive 21) crates/codegen/xai-grok-agent/src/prompt/user_message.rs:43 — xai_grok_agent::prompt::user_message::format_rules_section has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 2 (4 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.
  • xai_grok_agent::discovery::merge_subagents (cognitive 20) crates/codegen/xai-grok-agent/src/discovery.rs:83 — xai_grok_agent::discovery::merge_subagents has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 2 (4 pts), boolean chains 1, loops 1 (nesting depth added 10). Of this number, 19 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_agent::plugins::marketplace::resolve (cognitive 18) crates/codegen/xai-grok-agent/src/plugins/marketplace.rs:19 — xai_grok_agent::plugins::marketplace::resolve has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (3 pts), match/switch 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.
  • xai_grok_agent::prompt::skills::collect_skill_config_dirs_from_sources (cognitive 18) crates/codegen/xai-grok-agent/src/prompt/skills.rs:158 — xai_grok_agent::prompt::skills::collect_skill_config_dirs_from_sources has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 3 (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.
  • xai_grok_agent::plugins::registry::plugin_mcp_server_names (cognitive 17) crates/codegen/xai-grok-agent/src/plugins/registry.rs:494 — xai_grok_agent::plugins::registry::plugin_mcp_server_names has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (5 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.
D2 · Cognitive Complexity · xai_grok_sandbox · ×14
  • xai_grok_sandbox::command::violation::coarse::decode_coarse (cognitive 37) crates/codegen/xai-grok-sandbox/src/command/violation/coarse.rs:122 — xai_grok_sandbox::command::violation::coarse::decode_coarse has cognitive complexity 37 (threshold 15). Drivers by points: if/else 16 (25 pts), boolean chains 7, match/switch 2 (4 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.
  • xai_grok_sandbox::deny::glob::validate_deny_glob (cognitive 32) crates/codegen/xai-grok-sandbox/src/deny/glob.rs:69 — xai_grok_sandbox::deny::glob::validate_deny_glob has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (25 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.
  • xai_grok_sandbox::deny::glob::glob_tail_to_regex (cognitive 32) crates/codegen/xai-grok-sandbox/src/deny/glob.rs:168 — xai_grok_sandbox::deny::glob::glob_tail_to_regex has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (26 pts), loops 2 (4 pts), match/switch 1 (2 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.
  • xai_grok_sandbox::command::git_config::git_entries_in (cognitive 27) crates/codegen/xai-grok-sandbox/src/command/git_config.rs:204 — xai_grok_sandbox::command::git_config::git_entries_in has cognitive complexity 27 (threshold 15). Drivers by points: loops 7 (16 pts), if/else 4 (10 pts), match/switch 1 (nesting depth added 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.
  • xai_grok_sandbox::deny::glob::expand_deny_globs (cognitive 26) crates/codegen/xai-grok-sandbox/src/deny/glob.rs:393 — xai_grok_sandbox::deny::glob::expand_deny_globs has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (18 pts), match/switch 2 (4 pts), boolean chains 2, 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.
  • xai_grok_sandbox::deny::apply_write_deny_paths_to_capability_set (cognitive 24) crates/codegen/xai-grok-sandbox/src/deny/mod.rs:160 — xai_grok_sandbox::deny::apply_write_deny_paths_to_capability_set has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 4 (8 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.
  • xai_grok_sandbox::command::git_config::present_matches (cognitive 22) crates/codegen/xai-grok-sandbox/src/command/git_config.rs:611 — xai_grok_sandbox::command::git_config::present_matches has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 2 (5 pts), boolean chains 4, 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.
  • xai_grok_sandbox::command::protected::walk (cognitive 20) crates/codegen/xai-grok-sandbox/src/command/protected.rs:1379 — xai_grok_sandbox::command::protected::walk has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (12 pts), match/switch 2 (5 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.
  • xai_grok_sandbox::read_deny_verify::unescape_mountinfo_field (cognitive 19) crates/codegen/xai-grok-sandbox/src/read_deny_verify.rs:196 — xai_grok_sandbox::read_deny_verify::unescape_mountinfo_field 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.
  • xai_grok_sandbox::bwrap_deny_plan (cognitive 18) crates/codegen/xai-grok-sandbox/src/lib.rs:520 — xai_grok_sandbox::bwrap_deny_plan has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), match/switch 3 (6 pts), boolean chains 1 (nesting depth added 5). 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.
  • xai_grok_sandbox::command::violation::propose::propose (cognitive 17) crates/codegen/xai-grok-sandbox/src/command/violation/propose.rs:77 — xai_grok_sandbox::command::violation::propose::propose has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_sandbox::command::git_config::config_value (cognitive 16) crates/codegen/xai-grok-sandbox/src/command/git_config.rs:976 — xai_grok_sandbox::command::git_config::config_value has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 2 (5 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.
  • xai_grok_sandbox::command::violation::coarse::words_with_offsets (cognitive 16) crates/codegen/xai-grok-sandbox/src/command/violation/coarse.rs:412 — xai_grok_sandbox::command::violation::coarse::words_with_offsets has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), loops 3 (6 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.
  • xai_grok_sandbox::hook_write_deny::revalidate_plan (cognitive 16) crates/codegen/xai-grok-sandbox/src/hook_write_deny.rs:315 — xai_grok_sandbox::hook_write_deny::revalidate_plan has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 4 (5 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.
D30 · Dependency Vulnerabilities · Medium advisory (unmaintained) · ×14
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×14
  • Members sharing a duplicated core (4 members, 50+ identical tokens) crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:134 — crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:134-210 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:213-240 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:249-289 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:294-329 — 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) crates/codegen/xai-file-utils/src/queue.rs:1356 — crates/codegen/xai-file-utils/src/queue.rs:1356-1398 | crates/codegen/xai-file-utils/src/queue.rs:1408-1454 | crates/codegen/xai-file-utils/src/queue.rs:1463-1493 | crates/codegen/xai-file-utils/src/queue.rs:1496-1529 — 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) crates/codegen/xai-file-utils/src/storage_client.rs:1034 — crates/codegen/xai-file-utils/src/storage_client.rs:1034-1124 | crates/codegen/xai-file-utils/src/storage_client.rs:1134-1235 | crates/codegen/xai-file-utils/src/storage_client.rs:1574-1629 | crates/codegen/xai-file-utils/src/storage_client.rs:1639-1683 — 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) crates/codegen/xai-grok-markdown/src/mermaid.rs:2351 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2351-2490 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2499-2633 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2870-2961 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3643-3903 — 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) crates/codegen/xai-grok-markdown/src/mermaid.rs:3103 — crates/codegen/xai-grok-markdown/src/mermaid.rs:3103-3134 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3178-3206 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3208-3235 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3237-3260 — 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) crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:1134 — crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:1134-1338 | crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:650-1329 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:36-108 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:163-269 — 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) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:73 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:73-119 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:117-159 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:100-123 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:93-147 — 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) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1183 — crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1183-1242 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1251-1368 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1377-1501 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1510-1570 — 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) crates/codegen/xai-grok-sampler/src/actor/request_task.rs:922 — crates/codegen/xai-grok-sampler/src/actor/request_task.rs:922-945 | crates/codegen/xai-grok-sampling-types/src/error.rs:382-408 | crates/codegen/xai-grok-sampling-types/src/error.rs:454-490 | crates/codegen/xai-grok-sampling-types/src/error.rs:493-513 — 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) crates/codegen/xai-grok-sampler/src/client.rs:2012 — crates/codegen/xai-grok-sampler/src/client.rs:2012-2043 | crates/codegen/xai-grok-sampler/src/client.rs:2049-2079 | crates/codegen/xai-grok-sampler/src/client.rs:2088-2115 | crates/codegen/xai-grok-sampler/src/client.rs:2121-2147 — 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) crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:109 — crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:109-154 | crates/codegen/xai-grok-shell/src/remote/conversations_client.rs:123-145 | crates/codegen/xai-grok-shell/src/remote/skills_client.rs:394-416 | crates/codegen/xai-grok-shell/src/remote/workspaces_client.rs:78-136 — 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) crates/codegen/xai-grok-tools/src/implementations/grok_build/kill_task/mod.rs:100 — crates/codegen/xai-grok-tools/src/implementations/grok_build/kill_task/mod.rs:100-112 | crates/codegen/xai-grok-tools/src/implementations/grok_build/send_feedback.rs:219-232 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs:821-833 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/wait_tasks.rs:58-70 — 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) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:297 — crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:297-408 | crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:528-780 | crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs:277-360 | crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs:371-508 — 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) crates/codegen/xai-grok-test-support/src/sse.rs:389 — crates/codegen/xai-grok-test-support/src/sse.rs:389-465 | crates/codegen/xai-grok-test-support/src/sse.rs:566-634 | crates/codegen/xai-grok-test-support/src/sse.rs:650-752 | crates/codegen/xai-grok-test-support/src/sse.rs:983-1071 — 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.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×14
  • Duplicated block (16 lines × 2) crates/codegen/ptyctl/src/term.rs:220 — crates/codegen/ptyctl/src/term.rs:220-235 | crates/codegen/ptyctl/src/term.rs:358-373 — both copies are in the same file, so extract the 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) crates/codegen/xai-codebase-graph/src/manager/builder.rs:431 — crates/codegen/xai-codebase-graph/src/manager/builder.rs:431-446 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:609-624 — before extracting anything, compare `crates/codegen/xai-codebase-graph/src/manager/builder.rs` and `crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 54 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 (16 lines × 2) crates/codegen/xai-file-utils/src/gcs.rs:433 — crates/codegen/xai-file-utils/src/gcs.rs:433-448 | crates/codegen/xai-file-utils/src/gcs.rs:556-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.
  • Duplicated block (16 lines × 2) crates/codegen/xai-grok-feedback/src/draft_store.rs:328 — crates/codegen/xai-grok-feedback/src/draft_store.rs:328-343 | crates/codegen/xai-grok-feedback/src/draft_store.rs:364-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 (16 lines × 2) crates/codegen/xai-grok-hooks/src/dispatcher.rs:819 — crates/codegen/xai-grok-hooks/src/dispatcher.rs:819-834 | crates/codegen/xai-grok-hooks/src/dispatcher.rs:924-939 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-http/src/lib.rs:116 — crates/codegen/xai-grok-http/src/lib.rs:116-131 | crates/codegen/xai-grok-sampler/src/client.rs:432-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.
  • Duplicated block (16 lines × 2) crates/codegen/xai-grok-markdown/src/latex_delimiters.rs:434 — crates/codegen/xai-grok-markdown/src/latex_delimiters.rs:434-449 | crates/codegen/xai-grok-markdown/src/latex_delimiters.rs:470-485 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:887 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:887-902 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:917-932 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:1481 — crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:1481-1496 | crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:1533-1548 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:669 — crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:669-684 | crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:716-731 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/scrollback/blocks/context_info.rs:547 — crates/codegen/xai-grok-pager/src/scrollback/blocks/context_info.rs:547-562 | crates/codegen/xai-grok-pager/src/scrollback/blocks/system.rs:50-65 — 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) crates/codegen/xai-grok-sampler/src/client.rs:1513 — crates/codegen/xai-grok-sampler/src/client.rs:1513-1528 | crates/codegen/xai-grok-sampler/src/client.rs:1840-1855 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:2031 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:2031-2046 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/turn.rs:2101-2116 — both copies are in the same file, so extract the 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) crates/codegen/xai-file-utils/src/storage_client.rs:1051 — crates/codegen/xai-file-utils/src/storage_client.rs:1051-1066 | crates/codegen/xai-file-utils/src/storage_client.rs:1158-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.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×14
  • Duplicated block (8 lines × 3) crates/codegen/xai-codebase-graph/src/index_manager.rs:1411 — crates/codegen/xai-codebase-graph/src/index_manager.rs:1411-1418 | crates/codegen/xai-codebase-graph/src/manager/builder.rs:431-438 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:609-616 — before extracting anything, compare `crates/codegen/xai-codebase-graph/src/manager/builder.rs` and `crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 54 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 (8 lines × 3) crates/codegen/xai-fast-worktree/src/worktree/execute.rs:807 — crates/codegen/xai-fast-worktree/src/worktree/execute.rs:807-814 | crates/codegen/xai-fast-worktree/src/worktree/execute.rs:971-978 | crates/codegen/xai-fast-worktree/src/worktree/execute.rs:1175-1182 — 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) crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:154 — crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:154-161 | crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:205-212 | crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:760-767 — 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) crates/codegen/xai-grok-pager/src/app/app_view.rs:3674 — crates/codegen/xai-grok-pager/src/app/app_view.rs:3674-3681 | crates/codegen/xai-grok-pager/src/app/app_view.rs:3697-3704 | crates/codegen/xai-grok-pager/src/app/app_view.rs:3737-3744 — 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) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2016 — crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2016-2023 | crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2058-2065 | crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2111-2118 — 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) crates/codegen/xai-grok-sampler/src/client.rs:877 — crates/codegen/xai-grok-sampler/src/client.rs:877-884 | crates/codegen/xai-grok-sampler/src/client.rs:1337-1344 | crates/codegen/xai-grok-sampler/src/client.rs:1694-1701 — 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) crates/codegen/xai-grok-sampler/src/client.rs:961 — crates/codegen/xai-grok-sampler/src/client.rs:961-968 | crates/codegen/xai-grok-sampler/src/client.rs:1329-1336 | crates/codegen/xai-grok-sampler/src/client.rs:1686-1693 — 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) crates/codegen/xai-grok-sampler/src/client.rs:1138 — crates/codegen/xai-grok-sampler/src/client.rs:1138-1145 | crates/codegen/xai-grok-sampler/src/client.rs:1523-1530 | crates/codegen/xai-grok-sampler/src/client.rs:1850-1857 — 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) crates/codegen/xai-grok-active-sessions/src/lib.rs:102 — crates/codegen/xai-grok-active-sessions/src/lib.rs:102-109 | crates/codegen/xai-grok-file-lock/src/lock.rs:30-37 | crates/codegen/xai-grok-shell/src/session/storage/summary_write.rs:444-451 — 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) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1599 — crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1599-1608 | crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:2177-2185 | crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:2215-2222 — 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) crates/codegen/xai-grok-shell/src/config/mod.rs:111 — crates/codegen/xai-grok-shell/src/config/mod.rs:111-118 | crates/codegen/xai-grok-shell/src/config/mod.rs:151-158 | crates/codegen/xai-grok-shell/src/session/mcp_descriptors.rs:197-206 — 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.
  • Duplicated block (8 lines × 3) crates/codegen/xai-grok-sampler/src/client.rs:1129 — crates/codegen/xai-grok-sampler/src/client.rs:1129-1136 | crates/codegen/xai-grok-sampler/src/client.rs:1512-1519 | crates/codegen/xai-grok-sampler/src/client.rs:1839-1846 — 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) crates/codegen/xai-grok-tools/src/implementations/grok_build/image_gen/mod.rs:246 — crates/codegen/xai-grok-tools/src/implementations/grok_build/image_gen/mod.rs:246-253 | crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:369-376 | crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:435-442 — `crates/codegen/xai-grok-tools/src/implementations/grok_build/image_gen/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 37 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (8 lines × 3) crates/codegen/xai-grok-memory/src/v2_capture.rs:1906 — crates/codegen/xai-grok-memory/src/v2_capture.rs:1906-1913 | crates/codegen/xai-grok-memory/src/v2_consolidation.rs:1551-1558 | crates/codegen/xai-grok-memory/src/v2_consolidation.rs:1857-1864 — 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.
D1 · Cyclomatic Complexity · MvpAgent · ×12
  • MvpAgent::spawn_and_register_session (cyclomatic 57) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:4134 — MvpAgent::spawn_and_register_session has cyclomatic complexity 57 (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.
  • MvpAgent::prompt (cyclomatic 43) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1032 — MvpAgent::prompt 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. This is NOT this file's highest cyclomatic complexity: MvpAgent::ext_method (cyclomatic 62) 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.
  • MvpAgent::new_session_inner_impl (cyclomatic 40) crates/codegen/xai-grok-shell/src/agent/mvp_agent/session_setup.rs:388 — MvpAgent::new_session_inner_impl has cyclomatic complexity 40 (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.
  • MvpAgent::ext_notification (cyclomatic 37) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2381 — MvpAgent::ext_notification 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. This is NOT this file's highest cyclomatic complexity: MvpAgent::ext_method (cyclomatic 62) 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.
  • MvpAgent::attach_session (cyclomatic 34) crates/codegen/xai-grok-shell/src/agent/mvp_agent/session_setup.rs:929 — MvpAgent::attach_session has cyclomatic complexity 34 (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.
  • MvpAgent::authenticate (cyclomatic 30) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:635 — MvpAgent::authenticate 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. This is NOT this file's highest cyclomatic complexity: MvpAgent::ext_method (cyclomatic 62) 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.
  • MvpAgent::initialize (cyclomatic 29) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:130 — MvpAgent::initialize 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. This is NOT this file's highest cyclomatic complexity: MvpAgent::ext_method (cyclomatic 62) 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.
  • MvpAgent::forward_raw_replay_line (cyclomatic 19) crates/codegen/xai-grok-shell/src/agent/mvp_agent/replay.rs:79 — MvpAgent::forward_raw_replay_line 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.
  • MvpAgent::resolve_agent_definition (cyclomatic 18) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:3906 — MvpAgent::resolve_agent_definition has cyclomatic complexity 18 (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.
  • MvpAgent::add_local_workspace_mid_session (cyclomatic 17) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:1079 — MvpAgent::add_local_workspace_mid_session 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.
  • MvpAgent::maybe_spawn_interactive_trust_prompt (cyclomatic 16) crates/codegen/xai-grok-shell/src/agent/mvp_agent/folder_trust_prompt.rs:77 — MvpAgent::maybe_spawn_interactive_trust_prompt has cyclomatic complexity 16 (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.
  • MvpAgent::retry_subscription_check (cyclomatic 16) crates/codegen/xai-grok-shell/src/agent/mvp_agent/mod.rs:1494 — MvpAgent::retry_subscription_check 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.
D30 · Dependency Vulnerabilities · Medium advisory (unsound) · ×12
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×12
  • Duplicated block (17 lines × 2) crates/codegen/xai-fast-worktree/src/worktree/execute.rs:864 — crates/codegen/xai-fast-worktree/src/worktree/execute.rs:864-880 | crates/codegen/xai-fast-worktree/src/worktree/execute.rs:1112-1128 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-file-utils/src/gcs.rs:275 — crates/codegen/xai-file-utils/src/gcs.rs:275-291 | crates/codegen/xai-file-utils/src/gcs.rs:353-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.
  • Duplicated block (17 lines × 2) crates/codegen/xai-grok-markdown/src/mermaid.rs:798 — crates/codegen/xai-grok-markdown/src/mermaid.rs:798-814 | crates/codegen/xai-grok-markdown/src/mermaid.rs:1015-1031 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-grok-memory/src/v2.rs:822 — crates/codegen/xai-grok-memory/src/v2.rs:822-838 | crates/codegen/xai-grok-memory/src/v2.rs:1046-1062 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/blocks/context_info.rs:527 — crates/codegen/xai-grok-pager/src/scrollback/blocks/context_info.rs:527-543 | crates/codegen/xai-grok-pager/src/scrollback/blocks/system.rs:30-46 — 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 (17 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:237 — crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:237-253 | crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:985-1001 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2437 — crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2437-2453 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2550-2566 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-grok-pager/src/views/permission_view.rs:1067 — crates/codegen/xai-grok-pager/src/views/permission_view.rs:1067-1083 | crates/codegen/xai-grok-pager/src/views/permission_view.rs:1084-1100 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:2717 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:2717-2733 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/agent_ops.rs:2782-2798 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-grok-shell/src/extensions/review.rs:52 — crates/codegen/xai-grok-shell/src/extensions/review.rs:52-68 | crates/codegen/xai-grok-shell/src/extensions/review.rs:112-128 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:1636 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:1636-1652 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/tool_calls.rs:1685-1701 — both copies are in the same file, so extract the 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 (17 lines × 2) crates/codegen/xai-grok-shell/src/session/storage/jsonl/mod.rs:1602 — crates/codegen/xai-grok-shell/src/session/storage/jsonl/mod.rs:1602-1618 | crates/codegen/xai-grok-shell/src/session/storage/jsonl/mod.rs:1656-1672 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×12
  • Duplicated block (10–11 lines × 2) crates/codegen/xai-codebase-graph/src/manager/builder.rs:453 — crates/codegen/xai-codebase-graph/src/manager/builder.rs:453-462 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:632-642 — before extracting anything, compare `crates/codegen/xai-codebase-graph/src/manager/builder.rs` and `crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 54 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 (10–11 lines × 2) crates/codegen/xai-file-utils/src/storage_client.rs:758 — crates/codegen/xai-file-utils/src/storage_client.rs:758-768 | crates/codegen/xai-file-utils/src/storage_client.rs:876-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.
  • Duplicated block (10–11 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/auth.rs:82 — crates/codegen/xai-grok-pager/src/app/dispatch/auth.rs:82-92 | crates/codegen/xai-grok-pager/src/app/dispatch/auth.rs:219-228 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:829 — crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:829-839 | crates/codegen/xai-grok-pager/src/scrollback/wrappers/entry_renderer.rs:822-831 — 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–11 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1247 — crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1247-1257 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1348-1357 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/overlay_list.rs:90 — crates/codegen/xai-grok-pager/src/views/overlay_list.rs:90-99 | crates/codegen/xai-grok-pager/src/views/rewind.rs:322-332 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/views/overlay_list.rs` and `crates/codegen/xai-grok-pager/src/views/rewind.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 40 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–11 lines × 2) crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:385 — crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:385-395 | crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:413-422 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-sandbox/src/command/git_config.rs:503 — crates/codegen/xai-grok-sandbox/src/command/git_config.rs:503-513 | crates/codegen/xai-grok-sandbox/src/command/git_config.rs:532-541 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/plugin/mod.rs:924 — crates/codegen/xai-grok-shell/src/plugin/mod.rs:924-934 | crates/codegen/xai-grok-shell/src/plugin/mod.rs:969-978 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-tools/src/bridge.rs:635 — crates/codegen/xai-grok-tools/src/bridge.rs:635-644 | crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/delete.rs:94-104 — 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–11 lines × 2) crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/tool.rs:459 — crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/tool.rs:459-468 | crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/tool.rs:535-545 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/mod.rs:352 — crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/mod.rs:352-361 | crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/mod.rs:439-449 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D1 · Cyclomatic Complexity · xai_grok_permission_rules · ×11
  • xai_grok_permission_rules::policy::shell_dash_c_script (cyclomatic 39) crates/codegen/xai-grok-permission-rules/src/policy.rs:420 — xai_grok_permission_rules::policy::shell_dash_c_script 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.
  • xai_grok_permission_rules::bash_command_splitting::env_scan (cyclomatic 29) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:302 — xai_grok_permission_rules::bash_command_splitting::env_scan 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.
  • xai_grok_permission_rules::bash_permission_script::readers_allow (cyclomatic 25) crates/codegen/xai-grok-permission-rules/src/bash_permission_script.rs:219 — xai_grok_permission_rules::bash_permission_script::readers_allow 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.
  • xai_grok_permission_rules::bash_command_splitting::strip_wrapper_command (cyclomatic 21) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:459 — xai_grok_permission_rules::bash_command_splitting::strip_wrapper_command 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.
  • xai_grok_permission_rules::policy::pattern_matches (cyclomatic 19) crates/codegen/xai-grok-permission-rules/src/policy.rs:708 — xai_grok_permission_rules::policy::pattern_matches 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.
  • xai_grok_permission_rules::rules::parse_permission_rule (cyclomatic 18) crates/codegen/xai-grok-permission-rules/src/rules.rs:109 — xai_grok_permission_rules::rules::parse_permission_rule 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.
  • xai_grok_permission_rules::bash_command_splitting::parse_plain_command_from_node (cyclomatic 17) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:921 — xai_grok_permission_rules::bash_command_splitting::parse_plain_command_from_node 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.
  • xai_grok_permission_rules::git_content_filters::read_local_git_config_entries (cyclomatic 16) crates/codegen/xai-grok-permission-rules/src/git_content_filters.rs:61 — xai_grok_permission_rules::git_content_filters::read_local_git_config_entries 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.
  • xai_grok_permission_rules::managed_policy::apply_policy_source (cyclomatic 16) crates/codegen/xai-grok-permission-rules/src/managed_policy/mod.rs:258 — xai_grok_permission_rules::managed_policy::apply_policy_source 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.
  • xai_grok_permission_rules::managed_policy::url_match::warn_on_unmatchable_allow_url (cyclomatic 16) crates/codegen/xai-grok-permission-rules/src/managed_policy/url_match.rs:10 — xai_grok_permission_rules::managed_policy::url_match::warn_on_unmatchable_allow_url 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.
  • xai_grok_permission_rules::resolution::resolve_claude_settings_inner (cyclomatic 16) crates/codegen/xai-grok-permission-rules/src/resolution.rs:596 — xai_grok_permission_rules::resolution::resolve_claude_settings_inner 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.
D1 · Cyclomatic Complexity · xai_fast_worktree · ×11
  • xai_fast_worktree::api::gc::reclaim_expired_worktrees (cyclomatic 24) crates/codegen/xai-fast-worktree/src/api/gc.rs:482 — xai_fast_worktree::api::gc::reclaim_expired_worktrees 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.
  • xai_fast_worktree::discovery::register_nfs_from_union (cyclomatic 23) crates/codegen/xai-fast-worktree/src/discovery.rs:292 — xai_fast_worktree::discovery::register_nfs_from_union 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.
  • xai_fast_worktree::api::try_btrfs_remove_from_metadata_inner (cyclomatic 22) crates/codegen/xai-fast-worktree/src/api.rs:1089 — xai_fast_worktree::api::try_btrfs_remove_from_metadata_inner 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.
  • xai_fast_worktree::api::cleanup_orphaned_btrfs_snapshots_inner (cyclomatic 20) crates/codegen/xai-fast-worktree/src/api.rs:1254 — xai_fast_worktree::api::cleanup_orphaned_btrfs_snapshots_inner 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.
  • xai_fast_worktree::bin::worktree_lifecycle_bench::runtime::run_contained_command_impl (cyclomatic 20) crates/codegen/xai-fast-worktree/src/bin/worktree_lifecycle_bench/runtime.rs:314 — xai_fast_worktree::bin::worktree_lifecycle_bench::runtime::run_contained_command_impl has cyclomatic complexity 20 (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.
  • xai_fast_worktree::copy::engine::copy_parallel (cyclomatic 20) crates/codegen/xai-fast-worktree/src/copy/engine.rs:28 — xai_fast_worktree::copy::engine::copy_parallel has cyclomatic complexity 20 (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.
  • xai_fast_worktree::git::safety::working_tree::find_working_tree_content (cyclomatic 19) crates/codegen/xai-fast-worktree/src/git/safety/working_tree.rs:14 — xai_fast_worktree::git::safety::working_tree::find_working_tree_content 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.
  • xai_fast_worktree::auto_gc::maybe_auto_gc (cyclomatic 18) crates/codegen/xai-fast-worktree/src/auto_gc.rs:365 — xai_fast_worktree::auto_gc::maybe_auto_gc has cyclomatic complexity 18 (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.
  • xai_fast_worktree::git::worktree::remove_stale_worktree_registrations (cyclomatic 17) crates/codegen/xai-fast-worktree/src/git/worktree.rs:45 — xai_fast_worktree::git::worktree::remove_stale_worktree_registrations 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.
  • xai_fast_worktree::sync::apply_porcelain_v2_entries (cyclomatic 17) crates/codegen/xai-fast-worktree/src/sync.rs:298 — xai_fast_worktree::sync::apply_porcelain_v2_entries 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.
  • xai_fast_worktree::copy::standalone::rewrite_origin_fetch_in_config (cyclomatic 16) crates/codegen/xai-fast-worktree/src/copy/standalone.rs:362 — xai_fast_worktree::copy::standalone::rewrite_origin_fetch_in_config 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.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×10
  • Duplicated block (12 lines × 3) crates/codegen/xai-grok-markdown/src/mermaid.rs:2383 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2383-2394 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2545-2556 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2942-2953 — 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 (12 lines × 3) crates/codegen/xai-grok-memory/src/v2_capture.rs:338 — crates/codegen/xai-grok-memory/src/v2_capture.rs:338-349 | crates/codegen/xai-grok-memory/src/v2_maintenance.rs:461-472 | crates/codegen/xai-grok-memory/src/v2_maintenance.rs:614-625 — 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.
  • Duplicated block (12 lines × 3) crates/codegen/xai-grok-pager/src/app/acp_handler/background.rs:284 — crates/codegen/xai-grok-pager/src/app/acp_handler/background.rs:284-295 | crates/codegen/xai-grok-pager/src/app/acp_handler/background.rs:338-349 | crates/codegen/xai-grok-pager/src/app/acp_handler/background.rs:389-400 — 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 (12 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:179 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:179-190 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1269-1280 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1165-1176 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 74 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 (12 lines × 3) crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:235 — crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:235-246 | crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:293-304 | crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:859-870 — 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 (12 lines × 3) crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:308 — crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:308-319 | crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:698-709 | crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:825-836 — 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 (12 lines × 3) crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:84 — crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:84-95 | crates/codegen/xai-grok-sampler/src/stream/messages.rs:131-142 | crates/codegen/xai-grok-sampler/src/stream/responses.rs:261-272 — before extracting anything, compare `crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs` and `crates/codegen/xai-grok-sampler/src/stream/messages.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 64 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 (12 lines × 3) crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:91 — crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:91-102 | crates/codegen/xai-grok-shell/src/remote/conversations_client.rs:98-109 | crates/codegen/xai-grok-shell/src/remote/skills_client.rs:375-386 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs` and `crates/codegen/xai-grok-shell/src/remote/conversations_client.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 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 (12 lines × 3) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/mod.rs:249 — crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/mod.rs:249-260 | crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/grep.rs:185-196 | crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/read_file.rs:126-137 — 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 (12 lines × 3) crates/codegen/xai-grok-shell/src/upload/trace.rs:697 — crates/codegen/xai-grok-shell/src/upload/trace.rs:697-708 | crates/codegen/xai-grok-shell/src/upload/trace.rs:731-742 | crates/codegen/xai-grok-shell/src/upload/trace.rs:862-873 — 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 · Duplicated block (9 lines × 3) · ×10
  • Duplicated block (9 lines × 3) crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:142 — crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:142-150 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:215-223 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:250-258 — 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) crates/codegen/xai-grok-pager-render/src/syntax.rs:99 — crates/codegen/xai-grok-pager-render/src/syntax.rs:99-107 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:311-319 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:48-56 — 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 (9 lines × 3) crates/codegen/xai-grok-pager-render/src/theme/grokday.rs:92 — crates/codegen/xai-grok-pager-render/src/theme/grokday.rs:92-100 | crates/codegen/xai-grok-pager-render/src/theme/groknight.rs:94-102 | crates/codegen/xai-grok-pager-render/src/theme/tokyonight.rs:187-195 — before extracting anything, compare `crates/codegen/xai-grok-pager-render/src/theme/grokday.rs` and `crates/codegen/xai-grok-pager-render/src/theme/groknight.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 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 (9 lines × 3) crates/codegen/xai-grok-pager/src/app/acp_handler/settings.rs:287 — crates/codegen/xai-grok-pager/src/app/acp_handler/settings.rs:287-295 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/setters.rs:511-519 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/setters.rs:552-560 — 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.
  • Duplicated block (9 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/permissions.rs:115 — crates/codegen/xai-grok-pager/src/app/dispatch/permissions.rs:115-123 | crates/codegen/xai-grok-pager/src/app/dispatch/permissions.rs:185-193 | crates/codegen/xai-grok-pager/src/app/dispatch/permissions.rs:238-246 — 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) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:123 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:123-131 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:163-171 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:152-160 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 142 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 (9 lines × 3) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1665 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1665-1673 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1687-1695 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1710-1718 — 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) crates/codegen/xai-grok-sampler/src/client.rs:1110 — crates/codegen/xai-grok-sampler/src/client.rs:1110-1118 | crates/codegen/xai-grok-sampler/src/client.rs:1496-1504 | crates/codegen/xai-grok-sampler/src/client.rs:1823-1831 — 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) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:396 — crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:396-404 | crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:768-776 | crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs:496-504 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs` as WHOLE FILES: this scan already matched 7 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. 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 (9 lines × 3) crates/codegen/xai-grok-shell/src/extensions/worktree.rs:497 — crates/codegen/xai-grok-shell/src/extensions/worktree.rs:497-505 | crates/codegen/xai-grok-shell/src/extensions/worktree.rs:518-526 | crates/codegen/xai-grok-shell/src/extensions/worktree.rs:538-546 — 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.
D2 · Cognitive Complexity · xai_grok_memory · ×9
  • xai_grok_memory::v2::render_manifest_from_source (cognitive 62) crates/codegen/xai-grok-memory/src/v2.rs:469 — xai_grok_memory::v2::render_manifest_from_source has cognitive complexity 62 (threshold 15). Drivers by points: if/else 23 (46 pts), loops 3 (6 pts), match/switch 2 (6 pts), boolean chains 4 (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.
  • xai_grok_memory::storage_v2::list_memory_files_with_caps (cognitive 44) crates/codegen/xai-grok-memory/src/storage_v2.rs:28 — xai_grok_memory::storage_v2::list_memory_files_with_caps has cognitive complexity 44 (threshold 15). Drivers by points: if/else 10 (30 pts), loops 3 (6 pts), match/switch 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.
  • xai_grok_memory::dream::build_dream_user_message (cognitive 28) crates/codegen/xai-grok-memory/src/dream.rs:155 — xai_grok_memory::dream::build_dream_user_message has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 2 (5 pts), boolean chains 3 (nesting depth added 14). 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.
  • xai_grok_memory::batch_dream_plan::reject_conflicts (cognitive 26) crates/codegen/xai-grok-memory/src/batch_dream_plan.rs:615 — xai_grok_memory::batch_dream_plan::reject_conflicts has cognitive complexity 26 (threshold 15). Drivers by points: match/switch 3 (11 pts), loops 5 (8 pts), if/else 1 (4 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.
  • xai_grok_memory::batch_dream_commit::validate_budgets (cognitive 25) crates/codegen/xai-grok-memory/src/batch_dream_commit.rs:557 — xai_grok_memory::batch_dream_commit::validate_budgets has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 5, loops 2 (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.
  • xai_grok_memory::mmr::mmr_rerank (cognitive 19) crates/codegen/xai-grok-memory/src/mmr.rs:46 — xai_grok_memory::mmr::mmr_rerank has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 3, 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.
  • xai_grok_memory::v2::collect_entries_from (cognitive 18) crates/codegen/xai-grok-memory/src/v2.rs:680 — xai_grok_memory::v2::collect_entries_from has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (5 pts), loops 2, 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.
  • xai_grok_memory::v2_capture::safe_session_name (cognitive 17) crates/codegen/xai-grok-memory/src/v2_capture.rs:1502 — xai_grok_memory::v2_capture::safe_session_name has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_memory::batch_dream_outline::scan_lines (cognitive 16) crates/codegen/xai-grok-memory/src/batch_dream_outline.rs:26 — xai_grok_memory::batch_dream_outline::scan_lines has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 2 (3 pts), match/switch 1 (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.
D4 · Code Duplication · Duplicated block (12–13 lines × 2) · ×9
  • Duplicated block (12–13 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/queue.rs:955 — crates/codegen/xai-grok-pager/src/app/dispatch/queue.rs:955-966 | crates/codegen/xai-grok-pager/src/app/dispatch/queue.rs:1043-1055 — both copies are in the same file, so extract the 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–13 lines × 2) crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2879 — crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2879-2891 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3026-3037 — both copies are in the same file, so extract the 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–13 lines × 2) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2087 — crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2087-2098 | crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2120-2132 — both copies are in the same file, so extract the 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–13 lines × 2) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:891 — crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:891-902 | crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:3461-3473 — 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 (12–13 lines × 2) crates/codegen/xai-grok-shell/src/session/acp_session_impl/memory_dream.rs:888 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/memory_dream.rs:888-900 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/recap.rs:668-679 — 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–13 lines × 2) crates/codegen/xai-grok-shell/src/session/storage/search_content.rs:218 — crates/codegen/xai-grok-shell/src/session/storage/search_content.rs:218-229 | crates/codegen/xai-grok-shell/src/session/storage/search_content.rs:233-245 — both copies are in the same file, so extract the 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–13 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:215 — crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:215-227 | crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/grep.rs:122-133 — 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 (12–13 lines × 2) crates/codegen/xai-grok-tools/src/implementations/memory/get_tool.rs:80 — crates/codegen/xai-grok-tools/src/implementations/memory/get_tool.rs:80-91 | crates/codegen/xai-grok-tools/src/implementations/memory/search_tool.rs:67-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 both call sites, so a change lands once.
  • Duplicated block (12–13 lines × 2) crates/codegen/xai-grok-test-support/src/sse.rs:89 — crates/codegen/xai-grok-test-support/src/sse.rs:89-100 | crates/codegen/xai-grok-test-support/src/sse.rs:133-145 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×9
  • Duplicated block (7 lines × 3) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1481 — crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1481-1487 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1501-1507 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1541-1547 — 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 (7 lines × 3) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:1784 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:1784-1790 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3287-3293 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3853-3859 — 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 (7 lines × 3) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1677 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1677-1683 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1699-1705 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1722-1728 — 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 (7 lines × 3) crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:324 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:324-330 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:566-572 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/notification_drain.rs:376-382 — 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.
  • Duplicated block (7 lines × 3) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:324 — crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:324-330 | crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:712-718 | crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs:294-300 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs` as WHOLE FILES: this scan already matched 7 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. 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) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/active_message.rs:715 — crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/active_message.rs:715-721 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/active_message.rs:727-733 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/active_message.rs:751-757 — 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 (7 lines × 3) crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:160 — crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:160-166 | crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:236-242 | crates/codegen/xai-fast-worktree/src/bin/pool_perf_bench.rs:284-290 — 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 (7 lines × 3) crates/codegen/xai-grok-shell/src/session/compaction.rs:1390 — crates/codegen/xai-grok-shell/src/session/compaction.rs:1390-1396 | crates/codegen/xai-grok-shell/src/session/compaction.rs:1604-1610 | crates/codegen/xai-grok-shell/src/session/compaction.rs:1634-1640 — 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 (7 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:127 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:127-133 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:225-231 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:280-286 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 74 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.
D2 · Cognitive Complexity · DashboardState · ×8
  • DashboardState::handle_peek_key (cognitive 122) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2522 — DashboardState::handle_peek_key has cognitive complexity 122 (threshold 15). Drivers by points: if/else 43 (85 pts), boolean chains 27, match/switch 6 (10 pts) (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.
  • DashboardState::handle_mouse (cognitive 117) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3365 — DashboardState::handle_mouse has cognitive complexity 117 (threshold 15). Drivers by points: if/else 44 (94 pts), boolean chains 21, match/switch 1 (2 pts) (nesting depth added 51). 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.
  • DashboardState::handle_key (cognitive 113) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2982 — DashboardState::handle_key has cognitive complexity 113 (threshold 15). Drivers by points: if/else 50 (77 pts), boolean chains 25, match/switch 6 (11 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.
  • DashboardState::complete_clipboard_attachment_paste (cognitive 31) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2373 — DashboardState::complete_clipboard_attachment_paste has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 4, loops 1 (2 pts), match/switch 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.
  • DashboardState::handle_bracketed_paste (cognitive 30) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2084 — DashboardState::handle_bracketed_paste has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 4, loops 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.
  • DashboardState::handle_paste_key_deferred (cognitive 28) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2293 — DashboardState::handle_paste_key_deferred has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (22 pts), boolean chains 3, loops 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.
  • DashboardState::handle_input_with_paste_provenance (cognitive 23) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2000 — DashboardState::handle_input_with_paste_provenance has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (17 pts), match/switch 3 (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.
  • DashboardState::handle_location_picker_mouse (cognitive 17) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3832 — DashboardState::handle_location_picker_mouse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (4 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.
D2 · Cognitive Complexity · xai_grok_pager_minimal · ×8
  • xai_grok_pager_minimal::panel::render_mcps (cognitive 99) crates/codegen/xai-grok-pager-minimal/src/panel.rs:310 — xai_grok_pager_minimal::panel::render_mcps has cognitive complexity 99 (threshold 15). Drivers by points: if/else 23 (95 pts), loops 1 (2 pts), boolean chains 1, match/switch 1 (nesting depth added 73). 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.
  • xai_grok_pager_minimal::live::draw_live (cognitive 36) crates/codegen/xai-grok-pager-minimal/src/live.rs:82 — xai_grok_pager_minimal::live::draw_live has cognitive complexity 36 (threshold 15). Drivers by points: if/else 29 (33 pts), boolean chains 2, match/switch 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, 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.
  • xai_grok_pager_minimal::live::render_prompt_info (cognitive 22) crates/codegen/xai-grok-pager-minimal/src/live.rs:647 — xai_grok_pager_minimal::live::render_prompt_info has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (17 pts), match/switch 1 (3 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.
  • xai_grok_pager_minimal::full_view::trim_trailing_pads (cognitive 18) crates/codegen/xai-grok-pager-minimal/src/full_view.rs:193 — xai_grok_pager_minimal::full_view::trim_trailing_pads has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (14 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.
  • xai_grok_pager_minimal::overlay::render_question (cognitive 18) crates/codegen/xai-grok-pager-minimal/src/overlay.rs:576 — xai_grok_pager_minimal::overlay::render_question has cognitive complexity 18 (threshold 15). Drivers by points: if/else 13 (18 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.
  • xai_grok_pager_minimal::commit::expand_pending (cognitive 17) crates/codegen/xai-grok-pager-minimal/src/commit.rs:401 — xai_grok_pager_minimal::commit::expand_pending has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 pts), 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.
  • xai_grok_pager_minimal::live::draw_tail (cognitive 16) crates/codegen/xai-grok-pager-minimal/src/live.rs:447 — xai_grok_pager_minimal::live::draw_tail 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.
  • xai_grok_pager_minimal::reprint::reprint_committed (cognitive 16) crates/codegen/xai-grok-pager-minimal/src/reprint.rs:75 — xai_grok_pager_minimal::reprint::reprint_committed has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (14 pts), 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.
D2 · Cognitive Complexity · xai_grok_sampling_types · ×8
  • xai_grok_sampling_types::conversation::messages::build_messages_request (cognitive 66) crates/codegen/xai-grok-sampling-types/src/conversation/messages.rs:75 — xai_grok_sampling_types::conversation::messages::build_messages_request has cognitive complexity 66 (threshold 15). Drivers by points: if/else 25 (49 pts), loops 3 (8 pts), boolean chains 5, match/switch 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.
  • xai_grok_sampling_types::conversation::transform_conversation_cwd (cognitive 51) crates/codegen/xai-grok-sampling-types/src/conversation.rs:1861 — xai_grok_sampling_types::conversation::transform_conversation_cwd has cognitive complexity 51 (threshold 15). Drivers by points: if/else 8 (30 pts), loops 5 (14 pts), match/switch 2 (6 pts), boolean chains 1 (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.
  • xai_grok_sampling_types::conversation::dedup_duplicate_tool_results (cognitive 34) crates/codegen/xai-grok-sampling-types/src/conversation.rs:2064 — xai_grok_sampling_types::conversation::dedup_duplicate_tool_results has cognitive complexity 34 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 4 (13 pts), boolean chains 2 (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.
  • xai_grok_sampling_types::conversation::chat_completions::conversation_item_to_chat_message (cognitive 20) crates/codegen/xai-grok-sampling-types/src/conversation/chat_completions.rs:70 — xai_grok_sampling_types::conversation::chat_completions::conversation_item_to_chat_message has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 3 (7 pts), loops 1 (3 pts) (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.
  • xai_grok_sampling_types::conversation::upgrade_legacy_reasoning (cognitive 18) crates/codegen/xai-grok-sampling-types/src/conversation.rs:1482 — xai_grok_sampling_types::conversation::upgrade_legacy_reasoning has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 3, match/switch 1 (3 pts), loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_sampling_types::conversation::conversation_truncate_progressive (cognitive 18) crates/codegen/xai-grok-sampling-types/src/conversation.rs:1816 — xai_grok_sampling_types::conversation::conversation_truncate_progressive has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 1 (3 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.
  • xai_grok_sampling_types::conversation::repair_dangling_tool_calls_with (cognitive 16) crates/codegen/xai-grok-sampling-types/src/conversation.rs:1957 — xai_grok_sampling_types::conversation::repair_dangling_tool_calls_with has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (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.
  • xai_grok_sampling_types::conversation::responses::response_to_conversation_items (cognitive 16) crates/codegen/xai-grok-sampling-types/src/conversation/responses.rs:5 — xai_grok_sampling_types::conversation::responses::response_to_conversation_items has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 2 (4 pts), 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.
D2 · Cognitive Complexity · SubagentCoordinator · ×8
  • SubagentCoordinator::resolve_agent_target (cognitive 52) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/agent_targets.rs:38 — SubagentCoordinator::resolve_agent_target has cognitive complexity 52 (threshold 15). Drivers by points: if/else 23 (45 pts), match/switch 3 (4 pts), boolean chains 3 (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.
  • SubagentCoordinator::handle_internal (cognitive 34) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator.rs:698 — SubagentCoordinator::handle_internal has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (30 pts), boolean chains 3, 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.
  • SubagentCoordinator::handle_command (cognitive 23) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator.rs:400 — SubagentCoordinator::handle_command has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 5, match/switch 2 (3 pts) (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.
  • SubagentCoordinator::process_deadlines (cognitive 20) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator.rs:1650 — SubagentCoordinator::process_deadlines has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 6 (7 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.
  • SubagentCoordinator::finish_child (cognitive 19) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator.rs:1134 — SubagentCoordinator::finish_child has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 4, match/switch 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.
  • SubagentCoordinator::resolve_address_send (cognitive 18) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/active_message.rs:668 — SubagentCoordinator::resolve_address_send has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (15 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, 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.
  • SubagentCoordinator::handle_query (cognitive 18) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/query.rs:33 — SubagentCoordinator::handle_query has cognitive complexity 18 (threshold 15). Drivers by points: if/else 13 (18 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.
  • SubagentCoordinator::handle_spawn (cognitive 16) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/spawn.rs:16 — SubagentCoordinator::handle_spawn has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), match/switch 4 (5 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, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · HunkTrackerActor · ×8
  • HunkTrackerActor::refresh_all_baselines_except (cognitive 48) crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:438 — HunkTrackerActor::refresh_all_baselines_except has cognitive complexity 48 (threshold 15). Drivers by points: if/else 13 (24 pts), loops 6 (12 pts), match/switch 4 (7 pts), boolean chains 5 (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.
  • HunkTrackerActor::process_file_change (cognitive 37) crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:186 — HunkTrackerActor::process_file_change has cognitive complexity 37 (threshold 15). Drivers by points: if/else 15 (26 pts), match/switch 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.
  • HunkTrackerActor::handle_command (cognitive 35) crates/codegen/xai-hunk-tracker/src/actor/mod.rs:332 — HunkTrackerActor::handle_command has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (34 pts), match/switch 1 (nesting depth added 17). 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.
  • HunkTrackerActor::handle_coalesced_batch (cognitive 26) crates/codegen/xai-hunk-tracker/src/actor/mod.rs:237 — HunkTrackerActor::handle_coalesced_batch has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 2 (6 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.
  • HunkTrackerActor::recompute_hunks (cognitive 25) crates/codegen/xai-hunk-tracker/src/actor/hunks.rs:21 — HunkTrackerActor::recompute_hunks has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 3, boolean chains 2, 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.
  • HunkTrackerActor::refresh_git_dirty_cache (cognitive 23) crates/codegen/xai-hunk-tracker/src/actor/git.rs:78 — HunkTrackerActor::refresh_git_dirty_cache has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (16 pts), match/switch 3 (4 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.
  • HunkTrackerActor::reject_hunks_batch (cognitive 21) crates/codegen/xai-hunk-tracker/src/actor/actions.rs:500 — HunkTrackerActor::reject_hunks_batch has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (12 pts), loops 4 (6 pts), boolean chains 2, 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.
  • HunkTrackerActor::set_mode (cognitive 19) crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:640 — HunkTrackerActor::set_mode has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 2 (6 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.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×8
  • Duplicated block (9–10 lines × 2) crates/codegen/xai-codebase-graph/src/bin/bench_index.rs:46 — crates/codegen/xai-codebase-graph/src/bin/bench_index.rs:46-54 | crates/codegen/xai-codebase-graph/src/bin/code_graph.rs:195-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.
  • Duplicated block (9–10 lines × 2) crates/codegen/xai-fast-worktree/src/worktree/execute.rs:507 — crates/codegen/xai-fast-worktree/src/worktree/execute.rs:507-516 | crates/codegen/xai-fast-worktree/src/worktree/execute.rs:731-739 — both copies are in the same file, so extract the 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–10 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3095 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3095-3104 | crates/codegen/xai-grok-pager/src/views/file_search/dropdown.rs:158-166 — 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–10 lines × 2) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1790 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:1790-1798 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:4267-4276 — 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–10 lines × 2) crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:1079 — crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:1079-1088 | crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:1309-1317 — both copies are in the same file, so extract the 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–10 lines × 2) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1222 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:1222-1231 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/mod.rs:2104-2112 — 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–10 lines × 2) crates/codegen/xai-grok-shell/src/extensions/pr.rs:82 — crates/codegen/xai-grok-shell/src/extensions/pr.rs:82-91 | crates/codegen/xai-grok-shell/src/extensions/pr.rs:135-143 — both copies are in the same file, so extract the 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–10 lines × 2) crates/codegen/xai-grok-test-support/src/counting_server.rs:19 — crates/codegen/xai-grok-test-support/src/counting_server.rs:19-27 | crates/codegen/xai-grok-test-support/src/counting_server.rs:39-48 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D1 · Cyclomatic Complexity · DashboardState · ×7
  • DashboardState::handle_key (cyclomatic 91) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2982 — DashboardState::handle_key has cyclomatic complexity 91 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • DashboardState::handle_peek_key (cyclomatic 87) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2522 — DashboardState::handle_peek_key has cyclomatic complexity 87 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • DashboardState::handle_mouse (cyclomatic 62) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3365 — DashboardState::handle_mouse 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.
  • DashboardState::complete_clipboard_attachment_paste (cyclomatic 21) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2373 — DashboardState::complete_clipboard_attachment_paste 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.
  • DashboardState::handle_bracketed_paste (cyclomatic 18) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2084 — DashboardState::handle_bracketed_paste 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.
  • DashboardState::handle_shortcuts_modal_input (cyclomatic 18) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3933 — DashboardState::handle_shortcuts_modal_input has cyclomatic complexity 18 (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.
  • DashboardState::handle_paste_key_deferred (cyclomatic 16) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2293 — DashboardState::handle_paste_key_deferred 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.
D1 · Cyclomatic Complexity · HunkTrackerActor · ×7
  • HunkTrackerActor::handle_command (cyclomatic 44) crates/codegen/xai-hunk-tracker/src/actor/mod.rs:332 — HunkTrackerActor::handle_command 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.
  • HunkTrackerActor::refresh_all_baselines_except (cyclomatic 31) crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:438 — HunkTrackerActor::refresh_all_baselines_except has cyclomatic complexity 31 (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.
  • HunkTrackerActor::process_file_change (cyclomatic 28) crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:186 — HunkTrackerActor::process_file_change 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.
  • HunkTrackerActor::recompute_hunks (cyclomatic 19) crates/codegen/xai-hunk-tracker/src/actor/hunks.rs:21 — HunkTrackerActor::recompute_hunks 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.
  • HunkTrackerActor::reject_hunks_batch (cyclomatic 17) crates/codegen/xai-hunk-tracker/src/actor/actions.rs:500 — HunkTrackerActor::reject_hunks_batch 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.
  • HunkTrackerActor::reject_hunk (cyclomatic 16) crates/codegen/xai-hunk-tracker/src/actor/actions.rs:170 — HunkTrackerActor::reject_hunk 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.
  • HunkTrackerActor::refresh_git_dirty_cache (cyclomatic 16) crates/codegen/xai-hunk-tracker/src/actor/git.rs:78 — HunkTrackerActor::refresh_git_dirty_cache 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.
D1 · Cyclomatic Complexity · xai_grok_pager_render · ×7
  • xai_grok_pager_render::render::osc8::scan_logical_line (cyclomatic 35) crates/codegen/xai-grok-pager-render/src/render/osc8.rs:489 — xai_grok_pager_render::render::osc8::scan_logical_line 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.
  • xai_grok_pager_render::location_path::shorten_location_path (cyclomatic 34) crates/codegen/xai-grok-pager-render/src/location_path.rs:12 — xai_grok_pager_render::location_path::shorten_location_path has cyclomatic complexity 34 (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.
  • xai_grok_pager_render::terminal::detect_terminal_brand_from_env (cyclomatic 27) crates/codegen/xai-grok-pager-render/src/terminal/mod.rs:659 — xai_grok_pager_render::terminal::detect_terminal_brand_from_env has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • xai_grok_pager_render::render::highlight::paint_match_highlights (cyclomatic 22) crates/codegen/xai-grok-pager-render/src/render/highlight.rs:14 — xai_grok_pager_render::render::highlight::paint_match_highlights 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.
  • xai_grok_pager_render::render::bidi::logical_slice_for_visual_cols (cyclomatic 20) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:199 — xai_grok_pager_render::render::bidi::logical_slice_for_visual_cols has cyclomatic complexity 20 (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.
  • xai_grok_pager_render::render::image_overlay::render_image_overlay_inner (cyclomatic 18) crates/codegen/xai-grok-pager-render/src/render/image_overlay.rs:55 — xai_grok_pager_render::render::image_overlay::render_image_overlay_inner 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.
  • xai_grok_pager_render::render::tool_paths::shorten_path (cyclomatic 18) crates/codegen/xai-grok-pager-render/src/render/tool_paths.rs:124 — xai_grok_pager_render::render::tool_paths::shorten_path 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.
D2 · Cognitive Complexity · PromptWidget · ×7
  • PromptWidget::draw (cognitive 174) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2979 — PromptWidget::draw has cognitive complexity 174 (threshold 15). Drivers by points: if/else 68 (123 pts), boolean chains 23, loops 9 (23 pts), match/switch 2 (5 pts) (nesting depth added 72). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • PromptWidget::handle_key_inner (cognitive 42) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:1754 — PromptWidget::handle_key_inner has cognitive complexity 42 (threshold 15). Drivers by points: if/else 20 (30 pts), boolean chains 10, 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.
  • PromptWidget::render_info_line (cognitive 34) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:3521 — PromptWidget::render_info_line has cognitive complexity 34 (threshold 15). Drivers by points: if/else 23 (30 pts), match/switch 1 (3 pts), loops 1 (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.
  • PromptWidget::accept_slash_completion (cognitive 26) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:1344 — PromptWidget::accept_slash_completion has cognitive complexity 26 (threshold 15). Drivers by points: if/else 15 (22 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.
  • PromptWidget::handle_file_search_key (cognitive 25) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:1954 — PromptWidget::handle_file_search_key has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (18 pts), boolean chains 7 (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.
  • PromptWidget::rechip_orphan_image_placeholders (cognitive 19) crates/codegen/xai-grok-pager/src/views/prompt_widget/image_state.rs:28 — PromptWidget::rechip_orphan_image_placeholders has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 2 (4 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.
  • PromptWidget::sync_images_with_textarea (cognitive 18) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2415 — PromptWidget::sync_images_with_textarea has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), loops 4 (5 pts), match/switch 2 (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.
D2 · Cognitive Complexity · xai_grok_sampler · ×7
  • xai_grok_sampler::stream::messages::stream_messages (cognitive 132) crates/codegen/xai-grok-sampler/src/stream/messages.rs:60 — xai_grok_sampler::stream::messages::stream_messages has cognitive complexity 132 (threshold 15). Drivers by points: if/else 34 (108 pts), match/switch 7 (20 pts), boolean chains 3, loops 1 (nesting depth added 87). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_sampler::stream::chat_completions::stream_chat_completions (cognitive 67) crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:23 — xai_grok_sampler::stream::chat_completions::stream_chat_completions has cognitive complexity 67 (threshold 15). Drivers by points: if/else 21 (52 pts), match/switch 3 (7 pts), loops 3 (6 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.
  • xai_grok_sampler::stream::responses::stream_responses_tracked (cognitive 67) crates/codegen/xai-grok-sampler/src/stream/responses.rs:210 — xai_grok_sampler::stream::responses::stream_responses_tracked has cognitive complexity 67 (threshold 15). Drivers by points: if/else 22 (46 pts), match/switch 9 (18 pts), boolean chains 2, 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.
  • xai_grok_sampler::actor::request_task::run_request_task (cognitive 48) crates/codegen/xai-grok-sampler/src/actor/request_task.rs:78 — xai_grok_sampler::actor::request_task::run_request_task has cognitive complexity 48 (threshold 15). Drivers by points: if/else 15 (38 pts), match/switch 3 (7 pts), boolean chains 2, loops 1 (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.
  • xai_grok_sampler::actor::request_task::drive_l2 (cognitive 37) crates/codegen/xai-grok-sampler/src/actor/request_task.rs:651 — xai_grok_sampler::actor::request_task::drive_l2 has cognitive complexity 37 (threshold 15). Drivers by points: if/else 7 (26 pts), match/switch 3 (9 pts), boolean chains 1, 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.
  • xai_grok_sampler::actor::request_task::apply_retry_decision (cognitive 29) crates/codegen/xai-grok-sampler/src/actor/request_task.rs:352 — xai_grok_sampler::actor::request_task::apply_retry_decision has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (21 pts), match/switch 3 (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.
  • xai_grok_sampler::retry::classify_error (cognitive 19) crates/codegen/xai-grok-sampler/src/retry.rs:95 — xai_grok_sampler::retry::classify_error has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (15 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · MarkdownParser · ×7
  • MarkdownParser::on_start (cognitive 118) crates/codegen/xai-grok-markdown/src/parse.rs:870 — MarkdownParser::on_start has cognitive complexity 118 (threshold 15). Drivers by points: if/else 41 (94 pts), loops 4 (11 pts), boolean chains 7, match/switch 4 (6 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.
  • MarkdownParser::on_event (cognitive 104) crates/codegen/xai-grok-markdown/src/parse.rs:553 — MarkdownParser::on_event has cognitive complexity 104 (threshold 15). Drivers by points: if/else 41 (78 pts), match/switch 8 (20 pts), boolean chains 5, loops 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.
  • MarkdownParser::format_table (cognitive 88) crates/codegen/xai-grok-markdown/src/parse.rs:1588 — MarkdownParser::format_table has cognitive complexity 88 (threshold 15). Drivers by points: if/else 16 (50 pts), loops 12 (33 pts), boolean chains 5 (nesting depth added 55). 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.
  • MarkdownParser::format_styled_content_lines (cognitive 59) crates/codegen/xai-grok-markdown/src/parse.rs:1917 — MarkdownParser::format_styled_content_lines has cognitive complexity 59 (threshold 15). Drivers by points: if/else 12 (46 pts), loops 4 (9 pts), match/switch 1 (3 pts), boolean chains 1 (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.
  • MarkdownParser::on_end (cognitive 40) crates/codegen/xai-grok-markdown/src/parse.rs:1218 — MarkdownParser::on_end has cognitive complexity 40 (threshold 15). Drivers by points: if/else 16 (31 pts), boolean chains 5, match/switch 3 (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.
  • MarkdownParser::wrap_cell_text_joins (cognitive 21) crates/codegen/xai-grok-markdown/src/parse.rs:1869 — MarkdownParser::wrap_cell_text_joins has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (5 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.
  • MarkdownParser::scan_inline_html_entities (cognitive 20) crates/codegen/xai-grok-markdown/src/parse.rs:1472 — MarkdownParser::scan_inline_html_entities has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (3 pts), match/switch 1 (3 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.
D2 · Cognitive Complexity · ListPaneState · ×7
  • ListPaneState::handle_key_event (cognitive 104) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:1387 — ListPaneState::handle_key_event has cognitive complexity 104 (threshold 15). Drivers by points: if/else 42 (78 pts), boolean chains 26 (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.
  • ListPaneState::prepare_layout (cognitive 51) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:555 — ListPaneState::prepare_layout has cognitive complexity 51 (threshold 15). Drivers by points: if/else 22 (27 pts), boolean chains 14, match/switch 7 (8 pts), loops 1 (2 pts) (nesting depth added 7). 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.
  • ListPaneState::apply_goto_line_live (cognitive 28) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:1778 — ListPaneState::apply_goto_line_live has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (25 pts), boolean chains 2, 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.
  • ListPaneState::scroll_lines (cognitive 19) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:975 — ListPaneState::scroll_lines has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 3, match/switch 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.
  • ListPaneState::copy_selected (cognitive 17) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:363 — ListPaneState::copy_selected has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ListPaneState::select_nearest_at_y (cognitive 17) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:894 — ListPaneState::select_nearest_at_y has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 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.
  • ListPaneState::handle_nav_key (cognitive 17) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:1623 — ListPaneState::handle_nav_key has cognitive complexity 17 (threshold 15). Drivers by points: if/else 14, boolean chains 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.
D2 · Cognitive Complexity · xai_grok_config · ×7
  • xai_grok_config::fs_atomic::resolve_destination (cognitive 55) crates/codegen/xai-grok-config/src/fs_atomic.rs:41 — xai_grok_config::fs_atomic::resolve_destination has cognitive complexity 55 (threshold 15). Drivers by points: if/else 17 (42 pts), boolean chains 7, loops 2 (4 pts), match/switch 1 (2 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_config::global_hook_sources::resolve_global_hook_sources (cognitive 31) crates/codegen/xai-grok-config/src/global_hook_sources.rs:455 — xai_grok_config::global_hook_sources::resolve_global_hook_sources has cognitive complexity 31 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 2 (6 pts), boolean chains 2, match/switch 1 (2 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.
  • xai_grok_config::managed_text::format::parse_block (cognitive 31) crates/codegen/xai-grok-config/src/managed_text/format.rs:266 — xai_grok_config::managed_text::format::parse_block has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 6, match/switch 2 (3 pts), loops 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.
  • xai_grok_config::mcp_servers::server_list::non_toml_definitions (cognitive 25) crates/codegen/xai-grok-config/src/mcp_servers/server_list.rs:329 — xai_grok_config::mcp_servers::server_list::non_toml_definitions has cognitive complexity 25 (threshold 15). Drivers by points: if/else 2 (10 pts), match/switch 2 (9 pts), loops 3 (6 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.
  • xai_grok_config::loader::hook_config_layers_at (cognitive 21) crates/codegen/xai-grok-config/src/loader.rs:384 — xai_grok_config::loader::hook_config_layers_at has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 2 (4 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.
  • xai_grok_config::config_override::apply_patches (cognitive 19) crates/codegen/xai-grok-config/src/config_override.rs:160 — xai_grok_config::config_override::apply_patches has cognitive complexity 19 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 4 (8 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.
  • xai_grok_config::fs_atomic::read_followable_link_target (cognitive 16) crates/codegen/xai-grok-config/src/fs_atomic.rs:319 — xai_grok_config::fs_atomic::read_followable_link_target has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), 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.
D2 · Cognitive Complexity · ScopeGraphIndex · ×7
  • ScopeGraphIndex::find_references (cognitive 40) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1024 — ScopeGraphIndex::find_references has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 4 (14 pts), boolean chains 1 (nesting depth added 27). 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. This shape REPEATS in the file: one other method here (ScopeGraphIndex::find_references_with_names) 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.
  • ScopeGraphIndex::find_references_with_names (cognitive 40) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1066 — ScopeGraphIndex::find_references_with_names has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 4 (14 pts), boolean chains 1 (nesting depth added 27). 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. This shape REPEATS in the file: one other method here (ScopeGraphIndex::find_references) 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.
  • ScopeGraphIndex::rename_file (cognitive 33) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:930 — ScopeGraphIndex::rename_file has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (21 pts), loops 4 (12 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.
  • ScopeGraphIndex::find_definitions_smart (cognitive 33) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1111 — ScopeGraphIndex::find_definitions_smart has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 2 (6 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ScopeGraphIndex::remove_file (cognitive 21) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:890 — ScopeGraphIndex::remove_file has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 2 (4 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.
  • ScopeGraphIndex::read_from (cognitive 21) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1440 — ScopeGraphIndex::read_from has cognitive complexity 21 (threshold 15). Drivers by points: loops 11 (15 pts), if/else 4, match/switch 1 (2 pts) (nesting depth added 5). 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.
  • ScopeGraphIndex::find_definitions (cognitive 20) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:995 — ScopeGraphIndex::find_definitions has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (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.
D3 · God Classes · FileTooLong · ×7
  • FileTooLong: src/connection.rs crates/common/xai-computer-hub-sdk/src/connection.rs — FileTooLong — 1640 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 40 free functions. The bar is 500 significant lines; this is 1140 over it, 3.28× 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: src/server.rs crates/common/xai-computer-hub-sdk/src/server.rs — FileTooLong — 1416 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 916 over it, 2.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: src/harness.rs crates/common/xai-computer-hub-sdk/src/harness.rs — FileTooLong — 1372 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 872 over it, 2.74× 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: src/feedback_types.rs prod/mc/cli-chat-proxy-types/src/feedback_types.rs — FileTooLong — 1067 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 567 over it, 2.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: src/task.rs crates/common/xai-tool-types/src/task.rs — FileTooLong — 912 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 412 over it, 1.82× 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: src/frames.rs crates/common/xai-tool-protocol/src/frames.rs — FileTooLong — 641 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 141 over it, 1.28× 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: src/bot_relay.rs crates/common/xai-tool-protocol/src/bot_relay.rs — FileTooLong — 634 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 134 over it, 1.27× 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.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×7
  • Duplicated block (18 lines × 2) crates/codegen/xai-grok-markdown/src/mermaid.rs:2678 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2678-2695 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2815-2832 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/app/dispatch/modes.rs:374 — crates/codegen/xai-grok-pager/src/app/dispatch/modes.rs:374-391 | crates/codegen/xai-grok-pager/src/app/dispatch/modes.rs:438-455 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:982 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:982-999 | crates/codegen/xai-grok-pager/src/views/feedback_modal/enum_picker.rs:177-194 — 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 × 2) crates/codegen/xai-grok-sampler/src/client.rs:2018 — crates/codegen/xai-grok-sampler/src/client.rs:2018-2035 | crates/codegen/xai-grok-sampler/src/client.rs:2055-2072 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/session/acp_session/hooks.rs:386 — crates/codegen/xai-grok-shell/src/session/acp_session/hooks.rs:386-403 | crates/codegen/xai-grok-shell/src/session/acp_session/hooks.rs:469-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.
  • Duplicated block (18 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/todo/mod.rs:46 — crates/codegen/xai-grok-tools/src/implementations/grok_build/todo/mod.rs:46-63 | crates/codegen/xai-grok-tools/src/implementations/grok_build/todo/mod.rs:74-91 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-memory/src/v2_maintenance.rs:189 — crates/codegen/xai-grok-memory/src/v2_maintenance.rs:189-206 | crates/codegen/xai-grok-memory/src/v2_maintenance.rs:216-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.
D4 · Code Duplication · Duplicated block (8–9 lines × 2) · ×7
  • Duplicated block (8–9 lines × 2) crates/codegen/xai-grok-agent/src/plugins/marketplace.rs:227 — crates/codegen/xai-grok-agent/src/plugins/marketplace.rs:227-234 | crates/codegen/xai-grok-plugin-marketplace/src/config.rs:225-233 — 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 (8–9 lines × 2) crates/codegen/xai-grok-cloud-config/src/settings_fetch.rs:69 — crates/codegen/xai-grok-cloud-config/src/settings_fetch.rs:69-76 | crates/codegen/xai-grok-shell/src/remote/agent.rs:57-65 — 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 (8–9 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2412 — crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2412-2419 | crates/codegen/xai-grok-pager/src/app/dispatch/permissions.rs:191-199 — 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 (8–9 lines × 2) crates/codegen/xai-grok-pager/src/views/picker.rs:1125 — crates/codegen/xai-grok-pager/src/views/picker.rs:1125-1132 | crates/codegen/xai-grok-pager/src/views/picker.rs:1148-1156 — both copies are in the same file, so extract the 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–9 lines × 2) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:602 — crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:602-610 | crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:616-623 — both copies are in the same file, so extract the 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–9 lines × 2) crates/codegen/xai-grok-shell/src/agent/handlers/session.rs:219 — crates/codegen/xai-grok-shell/src/agent/handlers/session.rs:219-227 | crates/codegen/xai-grok-shell/src/extensions/review.rs:142-149 — 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 (8–9 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/kill_task/mod.rs:193 — crates/codegen/xai-grok-tools/src/implementations/grok_build/kill_task/mod.rs:193-201 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs:207-214 — 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.
D1 · Cyclomatic Complexity · xai_grok_sampler · ×6
  • xai_grok_sampler::stream::messages::stream_messages (cyclomatic 61) crates/codegen/xai-grok-sampler/src/stream/messages.rs:60 — xai_grok_sampler::stream::messages::stream_messages 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.
  • xai_grok_sampler::stream::responses::stream_responses_tracked (cyclomatic 55) crates/codegen/xai-grok-sampler/src/stream/responses.rs:210 — xai_grok_sampler::stream::responses::stream_responses_tracked has cyclomatic complexity 55 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • xai_grok_sampler::stream::chat_completions::stream_chat_completions (cyclomatic 30) crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:23 — xai_grok_sampler::stream::chat_completions::stream_chat_completions 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.
  • xai_grok_sampler::retry::format_sampling_error (cyclomatic 25) crates/codegen/xai-grok-sampler/src/retry.rs:165 — xai_grok_sampler::retry::format_sampling_error 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.
  • xai_grok_sampler::actor::request_task::run_request_task (cyclomatic 23) crates/codegen/xai-grok-sampler/src/actor/request_task.rs:78 — xai_grok_sampler::actor::request_task::run_request_task 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.
  • xai_grok_sampler::actor::request_task::apply_retry_decision (cyclomatic 20) crates/codegen/xai-grok-sampler/src/actor/request_task.rs:352 — xai_grok_sampler::actor::request_task::apply_retry_decision 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.
D2 · Cognitive Complexity · TextArea · ×6
  • TextArea::handle_mouse (cognitive 119) crates/codegen/xai-ratatui-textarea/src/textarea.rs:1076 — TextArea::handle_mouse has cognitive complexity 119 (threshold 15). Drivers by points: if/else 49 (103 pts), boolean chains 8, match/switch 4 (8 pts) (nesting depth added 58). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextArea::input (cognitive 49) crates/codegen/xai-ratatui-textarea/src/textarea.rs:1870 — TextArea::input has cognitive complexity 49 (threshold 15). Drivers by points: if/else 16 (34 pts), match/switch 4 (8 pts), boolean chains 7 (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.
  • TextArea::render_lines (cognitive 48) crates/codegen/xai-ratatui-textarea/src/textarea.rs:3225 — TextArea::render_lines has cognitive complexity 48 (threshold 15). Drivers by points: if/else 11 (34 pts), loops 4 (12 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.
  • TextArea::display_col_to_buffer_pos (cognitive 33) crates/codegen/xai-ratatui-textarea/src/textarea.rs:1718 — TextArea::display_col_to_buffer_pos has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (31 pts), boolean chains 1, loops 1 (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.
  • TextArea::greedy_wrap_segment (cognitive 33) crates/codegen/xai-ratatui-textarea/src/textarea.rs:2968 — TextArea::greedy_wrap_segment has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 3 (8 pts), boolean chains 6 (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.
  • TextArea::display_width_of_range (cognitive 22) crates/codegen/xai-ratatui-textarea/src/textarea.rs:1623 — TextArea::display_width_of_range has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (21 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.
D2 · Cognitive Complexity · xai_computer_hub_sdk · ×6
  • xai_computer_hub_sdk::connection::run_writer (cognitive 111) crates/common/xai-computer-hub-sdk/src/connection.rs:1533 — xai_computer_hub_sdk::connection::run_writer has cognitive complexity 111 (threshold 15). Drivers by points: match/switch 15 (44 pts), loops 9 (33 pts), if/else 9 (31 pts), boolean chains 3 (nesting depth added 75). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_computer_hub_sdk::connection::run_reader_actor (cognitive 46) crates/common/xai-computer-hub-sdk/src/connection.rs:1973 — xai_computer_hub_sdk::connection::run_reader_actor has cognitive complexity 46 (threshold 15). Drivers by points: if/else 8 (24 pts), match/switch 5 (17 pts), loops 2 (4 pts), boolean chains 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.
  • xai_computer_hub_sdk::server::handle_notification (cognitive 28) crates/common/xai-computer-hub-sdk/src/server.rs:2127 — xai_computer_hub_sdk::server::handle_notification has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 3 (7 pts), loops 2 (5 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.
  • xai_computer_hub_sdk::connection::run_reader_phase (cognitive 22) crates/common/xai-computer-hub-sdk/src/connection.rs:2206 — xai_computer_hub_sdk::connection::run_reader_phase has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 4 (14 pts), if/else 1 (6 pts), boolean chains 1, loops 1 (nesting depth added 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. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • xai_computer_hub_sdk::server::execute_call (cognitive 20) crates/common/xai-computer-hub-sdk/src/server.rs:2278 — xai_computer_hub_sdk::server::execute_call has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 9 (11 pts), if/else 6 (8 pts), loops 1 (nesting depth added 4). 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.
  • xai_computer_hub_sdk::metric_donate::convert_text_exposition (cognitive 16) crates/common/xai-computer-hub-sdk/src/metric_donate.rs:129 — xai_computer_hub_sdk::metric_donate::convert_text_exposition has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 2 (4 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.
D2 · Cognitive Complexity · WorkspaceHandle · ×6
  • WorkspaceHandle::session_bind_resolver (cognitive 98) crates/codegen/xai-grok-workspace/src/handle.rs:3217 — WorkspaceHandle::session_bind_resolver has cognitive complexity 98 (threshold 15). Drivers by points: if/else 40 (82 pts), boolean chains 9, match/switch 5 (7 pts) (nesting depth added 44). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • WorkspaceHandle::connect_hub (cognitive 79) crates/codegen/xai-grok-workspace/src/handle.rs:3835 — WorkspaceHandle::connect_hub has cognitive complexity 79 (threshold 15). Drivers by points: if/else 27 (55 pts), match/switch 7 (10 pts), loops 6 (8 pts), boolean chains 6 (nesting depth added 33). Of this number, 76 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • WorkspaceHandle::on_turn_boundary (cognitive 55) crates/codegen/xai-grok-workspace/src/session/checkpoint.rs:208 — WorkspaceHandle::on_turn_boundary has cognitive complexity 55 (threshold 15). Drivers by points: if/else 15 (47 pts), match/switch 2 (4 pts), loops 1 (3 pts), boolean chains 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.
  • WorkspaceHandle::resolve_path_within_root (cognitive 39) crates/codegen/xai-grok-workspace/src/handle.rs:1801 — WorkspaceHandle::resolve_path_within_root has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (26 pts), match/switch 3 (7 pts), boolean chains 4, loops 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.
  • WorkspaceHandle::get_single_file (cognitive 24) crates/codegen/xai-grok-workspace/src/handle.rs:2021 — WorkspaceHandle::get_single_file has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 6 (12 pts), if/else 4 (8 pts), boolean chains 4 (nesting depth added 10). 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.
  • WorkspaceHandle::rewind_to (cognitive 17) crates/codegen/xai-grok-workspace/src/session/checkpoint.rs:350 — WorkspaceHandle::rewind_to has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 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.
D2 · Cognitive Complexity · LocalTerminalActor · ×6
  • LocalTerminalActor::poll_process (cognitive 44) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1828 — LocalTerminalActor::poll_process has cognitive complexity 44 (threshold 15). Drivers by points: if/else 15 (26 pts), match/switch 5 (11 pts), loops 2 (4 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.
  • LocalTerminalActor::handle_command (cognitive 37) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1003 — LocalTerminalActor::handle_command has cognitive complexity 37 (threshold 15). Drivers by points: if/else 15 (28 pts), loops 2 (4 pts), match/switch 2 (3 pts), boolean chains 2 (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.
  • LocalTerminalActor::expire_timed_out_waiters (cognitive 27) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1673 — LocalTerminalActor::expire_timed_out_waiters has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 4 (9 pts), boolean chains 2, match/switch 1 (2 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.
  • LocalTerminalActor::handle_kill (cognitive 23) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1293 — LocalTerminalActor::handle_kill has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 1 (3 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.
  • LocalTerminalActor::collect_shell_state_dumps (cognitive 22) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1611 — LocalTerminalActor::collect_shell_state_dumps has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (15 pts), match/switch 1 (4 pts), loops 1 (2 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.
  • LocalTerminalActor::notify_completion_waiters (cognitive 18) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1644 — LocalTerminalActor::notify_completion_waiters has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 2 (4 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D3 · God Classes · FunctionTooLong · ×6
  • FunctionTooLong: xai_computer_hub_sdk::connection::run_writer crates/common/xai-computer-hub-sdk/src/connection.rs:1533 — FunctionTooLong — xai_computer_hub_sdk::connection::run_writer runs 198 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) 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.
  • FunctionTooLong: xai_computer_hub_core::bot_tools::grok_bot_tool_arguments_schema crates/common/xai-computer-hub-core/src/bot_tools.rs:146 — FunctionTooLong — xai_computer_hub_core::bot_tools::grok_bot_tool_arguments_schema runs 182 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 82 over it, 1.82× 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: xai_computer_hub_sdk::connection::run_reader_actor crates/common/xai-computer-hub-sdk/src/connection.rs:1973 — FunctionTooLong — xai_computer_hub_sdk::connection::run_reader_actor runs 175 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 75 over it, 1.75× 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: xai_grok_compaction::intra_compaction::fit::fit_turns_for_summarizer crates/common/xai-grok-compaction/src/intra_compaction/fit.rs:198 — FunctionTooLong — xai_grok_compaction::intra_compaction::fit::fit_turns_for_summarizer runs 153 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 53 over it, 1.53× 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: xai_computer_hub_sdk::server::execute_call crates/common/xai-computer-hub-sdk/src/server.rs:2278 — FunctionTooLong — xai_computer_hub_sdk::server::execute_call runs 152 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 52 over it, 1.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: xai_grok_compaction::inter_compaction::compact::sample_compaction_chunked crates/common/xai-grok-compaction/src/inter_compaction/compact.rs:81 — FunctionTooLong — xai_grok_compaction::inter_compaction::compact::sample_compaction_chunked runs 104 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 4 over it, 1.04× 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.
D30 · Dependency Vulnerabilities · Medium vulnerability · ×6
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (24 lines × 2) · ×6
  • Duplicated block (24 lines × 2) crates/codegen/xai-grok-markdown/src/mermaid.rs:1773 — crates/codegen/xai-grok-markdown/src/mermaid.rs:1773-1796 | crates/codegen/xai-grok-markdown/src/mermaid.rs:1799-1822 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (24 lines × 2) crates/codegen/xai-grok-markdown/src/parse.rs:73 — crates/codegen/xai-grok-markdown/src/parse.rs:73-96 | crates/codegen/xai-grok-markdown/src/render.rs:69-92 — 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 (24 lines × 2) crates/codegen/xai-grok-sampling-types/src/types.rs:116 — crates/codegen/xai-grok-sampling-types/src/types.rs:116-139 | crates/codegen/xai-grok-sampling-types/src/types.rs:144-167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (24 lines × 2) crates/codegen/xai-grok-shell/src/agent/config.rs:4533 — crates/codegen/xai-grok-shell/src/agent/config.rs:4533-4556 | crates/codegen/xai-grok-shell/src/agent/config.rs:4767-4790 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (24 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:360 — crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:360-383 | crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:405-428 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (24 lines × 2) crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs:119 — crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs:119-142 | crates/codegen/xai-grok-shell/src/test_support/lsp_runtime.rs:101-124 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs` and `crates/codegen/xai-grok-shell/src/test_support/lsp_runtime.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 81 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.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×6
  • Duplicated block (11–12 lines × 2) crates/codegen/xai-fast-worktree/src/discovery.rs:349 — crates/codegen/xai-fast-worktree/src/discovery.rs:349-359 | crates/codegen/xai-fast-worktree/src/discovery.rs:361-372 — both copies are in the same file, so extract the 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–12 lines × 2) crates/codegen/xai-grok-pager/src/acp/mod.rs:577 — crates/codegen/xai-grok-pager/src/acp/mod.rs:577-587 | crates/codegen/xai-grok-pager/src/acp/mod.rs:601-612 — both copies are in the same file, so extract the 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–12 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:454 — crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:454-465 | crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:788-798 — both copies are in the same file, so extract the 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–12 lines × 2) crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:90 — crates/codegen/xai-grok-pager/src/views/completion_dropdown.rs:90-100 | crates/codegen/xai-grok-pager/src/views/file_search/dropdown.rs:47-58 — 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 (11–12 lines × 2) crates/codegen/xai-grok-pager/src/views/picker.rs:2779 — crates/codegen/xai-grok-pager/src/views/picker.rs:2779-2789 | crates/codegen/xai-grok-pager/src/views/picker.rs:2882-2893 — both copies are in the same file, so extract the 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–12 lines × 2) crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/completion.rs:230 — crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/completion.rs:230-241 | crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/recovery.rs:266-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.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×6
  • Duplicated block (5 lines × 3) crates/codegen/xai-grok-gboom/src/assets.rs:133 — crates/codegen/xai-grok-gboom/src/assets.rs:133-137 | crates/codegen/xai-grok-gboom/src/assets.rs:158-162 | crates/codegen/xai-grok-gboom/src/assets.rs:188-192 — 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 (5 lines × 3) crates/codegen/xai-grok-pager-pty-harness/src/scripted.rs:1320 — crates/codegen/xai-grok-pager-pty-harness/src/scripted.rs:1320-1324 | crates/codegen/xai-grok-pager-pty-harness/src/scripted.rs:1330-1334 | crates/codegen/xai-grok-pager-pty-harness/src/scripted.rs:1340-1344 — 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 (5 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2339 — crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2339-2343 | crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2389-2393 | crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:2452-2456 — 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 (5 lines × 3) crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:294 — crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:294-298 | crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:420-424 | crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:545-549 — 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 (5 lines × 3) crates/codegen/xai-grok-shell/src/session/storage/jsonl/copy.rs:650 — crates/codegen/xai-grok-shell/src/session/storage/jsonl/copy.rs:650-654 | crates/codegen/xai-grok-shell/src/session/storage/jsonl/copy.rs:675-679 | crates/codegen/xai-grok-shell/src/session/storage/jsonl/copy.rs:703-707 — 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 (5 lines × 3) crates/codegen/xai-grok-test-support/src/otel_decode.rs:68 — crates/codegen/xai-grok-test-support/src/otel_decode.rs:68-72 | crates/codegen/xai-grok-test-support/src/otel_decode.rs:109-113 | crates/codegen/xai-grok-test-support/src/otel_decode.rs:140-144 — 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.
X15 · Unvalidated length from an untrusted reader · Length read from the parsed input is spent without ever being bounded · ×6
  • Length read from the parsed input is spent without ever being bounded crates/codegen/xai-grok-workspace/src/file_system/index.rs:835 — `n_segs` is read from the bytes being parsed at line 829 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 835 — and nowhere in its scope is `n_segs` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `n_segs` against the bytes actually remaining and a maximum the format allows before allocating.
  • Length read from the parsed input is spent without ever being bounded crates/codegen/xai-grok-workspace/src/file_system/index.rs:846 — `n_entries` is read from the bytes being parsed at line 831 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 846 — and nowhere in its scope is `n_entries` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `n_entries` against the bytes actually remaining and a maximum the format allows before allocating.
  • Length read from the parsed input is spent without ever being bounded crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1463 — `arena_len` is read from the bytes being parsed at line 1462 (`u32::from_le_bytes`), then used to size a `vec![…; n]` at line 1463 — and nowhere in its scope is `arena_len` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `arena_len` against the bytes actually remaining and a maximum the format allows before allocating.
  • Length read from the parsed input is spent without ever being bounded crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1469 — `num_offsets` is read from the bytes being parsed at line 1468 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 1469 — and nowhere in its scope is `num_offsets` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `num_offsets` against the bytes actually remaining and a maximum the format allows before allocating.
  • Length read from the parsed input is spent without ever being bounded crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1489 — `num_locations` is read from the bytes being parsed at line 1488 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 1489 — and nowhere in its scope is `num_locations` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `num_locations` against the bytes actually remaining and a maximum the format allows before allocating.
  • Length read from the parsed input is spent without ever being bounded crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1509 — `num_locations` is read from the bytes being parsed at line 1508 (`u32::from_le_bytes`), then used to size a `Vec::with_capacity` at line 1509 — and nowhere in its scope is `num_locations` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `num_locations` against the bytes actually remaining and a maximum the format allows before allocating.
D1 · Cyclomatic Complexity · MarkdownParser · ×5
  • MarkdownParser::on_start (cyclomatic 63) crates/codegen/xai-grok-markdown/src/parse.rs:870 — MarkdownParser::on_start 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.
  • MarkdownParser::on_event (cyclomatic 59) crates/codegen/xai-grok-markdown/src/parse.rs:553 — MarkdownParser::on_event 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.
  • MarkdownParser::on_end (cyclomatic 38) crates/codegen/xai-grok-markdown/src/parse.rs:1218 — MarkdownParser::on_end 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.
  • MarkdownParser::format_table (cyclomatic 33) crates/codegen/xai-grok-markdown/src/parse.rs:1588 — MarkdownParser::format_table 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.
  • MarkdownParser::format_styled_content_lines (cyclomatic 19) crates/codegen/xai-grok-markdown/src/parse.rs:1917 — MarkdownParser::format_styled_content_lines 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.
D1 · Cyclomatic Complexity · ScrollbackState · ×5
  • ScrollbackState::prepare_layout (cyclomatic 41) crates/codegen/xai-grok-pager/src/scrollback/state/mod.rs:1318 — ScrollbackState::prepare_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.
  • ScrollbackState::finish_running_with_time (cyclomatic 26) crates/codegen/xai-grok-pager/src/scrollback/state/mod.rs:1108 — ScrollbackState::finish_running_with_time 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.
  • ScrollbackState::ensure_selected_visible (cyclomatic 25) crates/codegen/xai-grok-pager/src/scrollback/state/nav.rs:592 — ScrollbackState::ensure_selected_visible 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.
  • ScrollbackState::measure_window_exact (cyclomatic 18) crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:662 — ScrollbackState::measure_window_exact 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.
  • ScrollbackState::patch_virtual_y_for_dirty (cyclomatic 17) crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:1085 — ScrollbackState::patch_virtual_y_for_dirty 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.
D1 · Cyclomatic Complexity · SubagentCoordinator · ×5
  • SubagentCoordinator::resolve_agent_target (cyclomatic 33) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator/agent_targets.rs:38 — SubagentCoordinator::resolve_agent_target 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.
  • SubagentCoordinator::handle_command (cyclomatic 33) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator.rs:400 — SubagentCoordinator::handle_command has cyclomatic complexity 33 (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.
  • SubagentCoordinator::handle_internal (cyclomatic 23) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator.rs:698 — SubagentCoordinator::handle_internal 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.
  • SubagentCoordinator::finish_child (cyclomatic 18) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator.rs:1134 — SubagentCoordinator::finish_child 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.
  • SubagentCoordinator::run (cyclomatic 17) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/coordinator.rs:308 — SubagentCoordinator::run 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.
D1 · Cyclomatic Complexity · FeedbackModalState · ×5
  • FeedbackModalState::handle_drafts_key (cyclomatic 31) crates/codegen/xai-grok-pager/src/views/feedback_modal/drafts.rs:571 — FeedbackModalState::handle_drafts_key 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.
  • FeedbackModalState::handle_key (cyclomatic 25) crates/codegen/xai-grok-pager/src/views/feedback_modal/mod.rs:729 — FeedbackModalState::handle_key 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.
  • FeedbackModalState::render_drafts (cyclomatic 19) crates/codegen/xai-grok-pager/src/views/feedback_modal/render.rs:98 — FeedbackModalState::render_drafts 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.
  • FeedbackModalState::handle_mouse (cyclomatic 18) crates/codegen/xai-grok-pager/src/views/feedback_modal/mod.rs:974 — FeedbackModalState::handle_mouse 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.
  • FeedbackModalState::render (cyclomatic 16) crates/codegen/xai-grok-pager/src/views/feedback_modal/render.rs:15 — FeedbackModalState::render has cyclomatic complexity 16 (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.
D2 · Cognitive Complexity · xai_grok_hooks · ×5
  • xai_grok_hooks::runner::command::find_local_shell_assignments (cognitive 70) crates/codegen/xai-grok-hooks/src/runner/command.rs:572 — xai_grok_hooks::runner::command::find_local_shell_assignments has cognitive complexity 70 (threshold 15). Drivers by points: if/else 15 (41 pts), loops 7 (19 pts), boolean chains 10 (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.
  • xai_grok_hooks::runner::command::run_command_hook (cognitive 39) crates/codegen/xai-grok-hooks/src/runner/command.rs:103 — xai_grok_hooks::runner::command::run_command_hook has cognitive complexity 39 (threshold 15). Drivers by points: if/else 21 (31 pts), match/switch 4 (5 pts), boolean chains 3 (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.
  • xai_grok_hooks::runner::http::is_blocked_ip (cognitive 21) crates/codegen/xai-grok-hooks/src/runner/http.rs:36 — xai_grok_hooks::runner::http::is_blocked_ip has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 4, match/switch 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.
  • xai_grok_hooks::dispatcher::dispatch_sequential_gate (cognitive 18) crates/codegen/xai-grok-hooks/src/dispatcher.rs:93 — xai_grok_hooks::dispatcher::dispatch_sequential_gate has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (15 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.
  • xai_grok_hooks::discovery::load_hooks_from_directory (cognitive 16) crates/codegen/xai-grok-hooks/src/discovery.rs:454 — xai_grok_hooks::discovery::load_hooks_from_directory has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (6 pts), match/switch 3 (5 pts), loops 3 (4 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.
D2 · Cognitive Complexity · xai_file_utils · ×5
  • xai_file_utils::queue::upload_with_retries (cognitive 63) crates/codegen/xai-file-utils/src/queue.rs:1875 — xai_file_utils::queue::upload_with_retries has cognitive complexity 63 (threshold 15). Drivers by points: if/else 12 (50 pts), loops 2 (5 pts), match/switch 2 (5 pts), boolean chains 3 (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.
  • xai_file_utils::queue::cleanup_queue_dir (cognitive 20) crates/codegen/xai-file-utils/src/queue.rs:2174 — xai_file_utils::queue::cleanup_queue_dir has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 2, loops 1, match/switch 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.
  • xai_file_utils::storage_client::create_read_at_stream (cognitive 20) crates/codegen/xai-file-utils/src/storage_client.rs:1947 — xai_file_utils::storage_client::create_read_at_stream has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 3 (5 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.
  • xai_file_utils::queue::upload_worker (cognitive 19) crates/codegen/xai-file-utils/src/queue.rs:1627 — xai_file_utils::queue::upload_worker has cognitive complexity 19 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 3 (6 pts), match/switch 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.
  • xai_file_utils::storage_client::upload_part_direct (cognitive 17) crates/codegen/xai-file-utils/src/storage_client.rs:1870 — xai_file_utils::storage_client::upload_part_direct has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 1 (2 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.
D2 · Cognitive Complexity · ScrollbackPane · ×5
  • ScrollbackPane::render_content (cognitive 58) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:869 — ScrollbackPane::render_content has cognitive complexity 58 (threshold 15). Drivers by points: if/else 15 (35 pts), boolean chains 13, loops 2 (10 pts) (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.
  • ScrollbackPane::render_entry_with_ctx_static (cognitive 49) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:712 — ScrollbackPane::render_entry_with_ctx_static has cognitive complexity 49 (threshold 15). Drivers by points: if/else 16 (31 pts), loops 6 (13 pts), boolean chains 4, match/switch 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.
  • ScrollbackPane::render_tool_call_hover (cognitive 25) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:196 — ScrollbackPane::render_tool_call_hover has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 2 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ScrollbackPane::render_with_sticky_headers (cognitive 25) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:294 — ScrollbackPane::render_with_sticky_headers has cognitive complexity 25 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 7 (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.
  • ScrollbackPane::render_sticky_header (cognitive 23) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:563 — ScrollbackPane::render_sticky_header has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 2 (5 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.
D2 · Cognitive Complexity · Renderer · ×5
  • Renderer::draw_walls (cognitive 48) crates/codegen/xai-grok-gboom/src/engine.rs:271 — Renderer::draw_walls has cognitive complexity 48 (threshold 15). Drivers by points: if/else 23 (40 pts), loops 3 (5 pts), boolean chains 3 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Renderer::draw_imps (cognitive 32) crates/codegen/xai-grok-gboom/src/engine.rs:379 — Renderer::draw_imps has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 3 (6 pts), match/switch 1 (2 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.
  • Renderer::draw_floor_ceiling (cognitive 19) crates/codegen/xai-grok-gboom/src/engine.rs:216 — Renderer::draw_floor_ceiling has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (15 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.
  • Renderer::draw_gun (cognitive 18) crates/codegen/xai-grok-gboom/src/engine.rs:472 — Renderer::draw_gun has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 3 (4 pts), boolean chains 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.
  • Renderer::render_game (cognitive 17) crates/codegen/xai-grok-gboom/src/engine.rs:172 — Renderer::render_game has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D3 · God Classes · TooManyFields · ×5
  • TooManyFields: SessionSignalsUpdate prod/mc/cli-chat-proxy-types/src/feedback_types.rs:833 — TooManyFields — 61 stored fields. The bar is 30 stored fields; this is 31 over it, 2.03× 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: SessionTurnDelta prod/mc/cli-chat-proxy-types/src/feedback_types.rs:1715 — TooManyFields — 52 stored fields. The bar is 30 stored fields; this is 22 over it, 1.73× 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: FeedbackSubmission prod/mc/cli-chat-proxy-types/src/feedback_types.rs:381 — TooManyFields — 40 stored fields beside 3 methods. The bar is 30 stored fields; this is 10 over it, 1.33× 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: SessionSignals prod/mc/cli-chat-proxy-types/src/feedback_types.rs:1048 — TooManyFields — 35 stored fields. 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: HubConnectionInner crates/common/xai-computer-hub-sdk/src/connection.rs:652 — TooManyFields — 33 stored fields beside 7 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 · Duplicated block (22 lines × 2) · ×5
  • Duplicated block (22 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1786 — crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1786-1807 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1861-1882 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:340 — crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:340-361 | crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:746-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.
  • Duplicated block (22 lines × 2) crates/codegen/xai-grok-shell/src/util/config/mcp.rs:574 — crates/codegen/xai-grok-shell/src/util/config/mcp.rs:574-595 | crates/codegen/xai-grok-shell/src/util/config/mcp.rs:612-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.
  • Duplicated block (22 lines × 2) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1880 — crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1880-1901 | crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1903-1924 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs:92 — crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs:92-113 | crates/codegen/xai-grok-shell/src/test_support/lsp_runtime.rs:74-95 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs` and `crates/codegen/xai-grok-shell/src/test_support/lsp_runtime.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 81 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.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×5
  • Duplicated block (19 lines × 2) crates/codegen/xai-file-utils/src/gcs.rs:139 — crates/codegen/xai-file-utils/src/gcs.rs:139-157 | crates/codegen/xai-file-utils/src/gcs.rs:308-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.
  • Duplicated block (19 lines × 2) crates/codegen/xai-file-utils/src/storage_client.rs:1606 — crates/codegen/xai-file-utils/src/storage_client.rs:1606-1624 | crates/codegen/xai-file-utils/src/storage_client.rs:1660-1678 — both copies are in the same file, so extract the 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 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:2211 — crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:2211-2229 | crates/codegen/xai-grok-tools/src/implementations/opencode/bash/mod.rs:425-443 — 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 (19 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:1226 — crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:1226-1244 | crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:1394-1412 — both copies are in the same file, so extract the 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 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/scheme.rs:358 — crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/scheme.rs:358-376 | crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/scheme.rs:490-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.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×5
  • Duplicated block (17–18 lines × 2) crates/codegen/xai-grok-pager-render/src/prompt_images.rs:1639 — crates/codegen/xai-grok-pager-render/src/prompt_images.rs:1639-1655 | crates/codegen/xai-grok-pager-render/src/prompt_images.rs:1721-1738 — both copies are in the same file, so extract the 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 (17–18 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:1055 — crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:1055-1072 | crates/codegen/xai-grok-pager/src/scrollback/state/layout.rs:1318-1334 — both copies are in the same file, so extract the 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 (17–18 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2416 — crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2416-2433 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:2525-2541 — both copies are in the same file, so extract the 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 (17–18 lines × 2) crates/codegen/xai-grok-shell/src/session/compaction.rs:1327 — crates/codegen/xai-grok-shell/src/session/compaction.rs:1327-1343 | crates/codegen/xai-grok-shell/src/session/compaction.rs:2042-2059 — both copies are in the same file, so extract the 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 (17–18 lines × 2) crates/codegen/xai-grok-test-support/src/sse.rs:449 — crates/codegen/xai-grok-test-support/src/sse.rs:449-465 | crates/codegen/xai-grok-test-support/src/sse.rs:735-752 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×5
  • Duplicated block (10 lines × 3) crates/codegen/xai-grok-hooks/src/env_expand.rs:216 — crates/codegen/xai-grok-hooks/src/env_expand.rs:216-225 | crates/codegen/xai-grok-hooks/src/runner/command.rs:605-614 | crates/codegen/xai-grok-hooks/src/runner/command.rs:647-656 — 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.
  • Duplicated block (10 lines × 3) crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:378 — crates/codegen/xai-grok-pager/src/app/agent_view/interactions.rs:378-387 | crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:855-864 | crates/codegen/xai-grok-pager/src/app/agent_view/plan.rs:1086-1095 — 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.
  • Duplicated block (10 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1239 — crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1239-1248 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:216-225 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1144-1153 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 80 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 × 3) crates/codegen/xai-grok-sampling-types/src/error.rs:399 — crates/codegen/xai-grok-sampling-types/src/error.rs:399-408 | crates/codegen/xai-grok-sampling-types/src/error.rs:481-490 | crates/codegen/xai-grok-sampling-types/src/error.rs:504-513 — 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) crates/codegen/xai-grok-shell/src/agent/mvp_agent/folder_trust_prompt.rs:299 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/folder_trust_prompt.rs:299-308 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:802-811 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/hooks_plugins.rs:881-890 — 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.
D4 · Code Duplication · Duplicated block (7–8 lines × 2) · ×5
  • Duplicated block (7–8 lines × 2) crates/codegen/xai-grok-egress-proxy/src/http.rs:243 — crates/codegen/xai-grok-egress-proxy/src/http.rs:243-249 | crates/codegen/xai-grok-egress-proxy/src/request.rs:77-84 — 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–8 lines × 2) crates/codegen/xai-grok-markdown/src/colors.rs:268 — crates/codegen/xai-grok-markdown/src/colors.rs:268-274 | crates/codegen/xai-grok-pager-render/src/render/color.rs:27-34 — 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–8 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/workflows_overlay.rs:91 — crates/codegen/xai-grok-pager/src/app/agent_view/workflows_overlay.rs:91-97 | crates/codegen/xai-grok-pager/src/app/agent_view/workflows_overlay.rs:186-193 — both copies are in the same file, so extract the 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–8 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/blocks/user.rs:57 — crates/codegen/xai-grok-pager/src/scrollback/blocks/user.rs:57-64 | crates/codegen/xai-grok-pager/src/scrollback/blocks/user.rs:66-72 — both copies are in the same file, so extract the 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–8 lines × 2) crates/codegen/xai-grok-shell/src/extensions/session_admin.rs:507 — crates/codegen/xai-grok-shell/src/extensions/session_admin.rs:507-514 | crates/codegen/xai-grok-shell/src/extensions/session_admin.rs:567-573 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D1 · Cyclomatic Complexity · PromptWidget · ×4
  • PromptWidget::draw (cyclomatic 90) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:2979 — PromptWidget::draw has cyclomatic complexity 90 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • PromptWidget::handle_key_inner (cyclomatic 34) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:1754 — PromptWidget::handle_key_inner 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.
  • PromptWidget::handle_file_search_key (cyclomatic 19) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:1954 — PromptWidget::handle_file_search_key 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.
  • PromptWidget::render_info_line (cyclomatic 19) crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs:3521 — PromptWidget::render_info_line 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.
D1 · Cyclomatic Complexity · ListPaneState · ×4
  • ListPaneState::handle_key_event (cyclomatic 67) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:1387 — ListPaneState::handle_key_event 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.
  • ListPaneState::prepare_layout (cyclomatic 42) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:555 — ListPaneState::prepare_layout has cyclomatic complexity 42 (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.
  • ListPaneState::handle_nav_key (cyclomatic 18) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:1623 — ListPaneState::handle_nav_key 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.
  • ListPaneState::apply_goto_line_live (cyclomatic 17) crates/codegen/xai-grok-pager/src/views/list_pane/state/methods.rs:1778 — ListPaneState::apply_goto_line_live 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.
D1 · Cyclomatic Complexity · TextArea · ×4
  • TextArea::handle_mouse (cyclomatic 58) crates/codegen/xai-ratatui-textarea/src/textarea.rs:1076 — TextArea::handle_mouse 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.
  • TextArea::input (cyclomatic 37) crates/codegen/xai-ratatui-textarea/src/textarea.rs:1870 — TextArea::input 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.
  • TextArea::greedy_wrap_segment (cyclomatic 18) crates/codegen/xai-ratatui-textarea/src/textarea.rs:2968 — TextArea::greedy_wrap_segment 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.
  • TextArea::render_lines (cyclomatic 17) crates/codegen/xai-ratatui-textarea/src/textarea.rs:3225 — TextArea::render_lines 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.
D1 · Cyclomatic Complexity · xai_computer_hub_sdk · ×4
  • xai_computer_hub_sdk::connection::run_writer (cyclomatic 56) crates/common/xai-computer-hub-sdk/src/connection.rs:1533 — xai_computer_hub_sdk::connection::run_writer has cyclomatic complexity 56 (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.
  • xai_computer_hub_sdk::connection::run_reader_actor (cyclomatic 20) crates/common/xai-computer-hub-sdk/src/connection.rs:1973 — xai_computer_hub_sdk::connection::run_reader_actor 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.
  • xai_computer_hub_sdk::server::execute_call (cyclomatic 19) crates/common/xai-computer-hub-sdk/src/server.rs:2278 — xai_computer_hub_sdk::server::execute_call 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.
  • xai_computer_hub_sdk::connection::run_reader_phase (cyclomatic 17) crates/common/xai-computer-hub-sdk/src/connection.rs:2206 — xai_computer_hub_sdk::connection::run_reader_phase 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.
D1 · Cyclomatic Complexity · WorkspaceHandle · ×4
  • WorkspaceHandle::session_bind_resolver (cyclomatic 50) crates/codegen/xai-grok-workspace/src/handle.rs:3217 — WorkspaceHandle::session_bind_resolver 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.
  • WorkspaceHandle::connect_hub (cyclomatic 44) crates/codegen/xai-grok-workspace/src/handle.rs:3835 — WorkspaceHandle::connect_hub has cyclomatic complexity 44 (threshold 15). Of this number, 41 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • WorkspaceHandle::on_turn_boundary (cyclomatic 22) crates/codegen/xai-grok-workspace/src/session/checkpoint.rs:208 — WorkspaceHandle::on_turn_boundary 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.
  • WorkspaceHandle::resolve_path_within_root (cyclomatic 21) crates/codegen/xai-grok-workspace/src/handle.rs:1801 — WorkspaceHandle::resolve_path_within_root 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.
D1 · Cyclomatic Complexity · xai_grok_sandbox · ×4
  • xai_grok_sandbox::command::violation::coarse::decode_coarse (cyclomatic 26) crates/codegen/xai-grok-sandbox/src/command/violation/coarse.rs:122 — xai_grok_sandbox::command::violation::coarse::decode_coarse 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.
  • xai_grok_sandbox::deny::glob::validate_deny_glob (cyclomatic 19) crates/codegen/xai-grok-sandbox/src/deny/glob.rs:69 — xai_grok_sandbox::deny::glob::validate_deny_glob 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.
  • xai_grok_sandbox::deny::glob::expand_deny_globs (cyclomatic 17) crates/codegen/xai-grok-sandbox/src/deny/glob.rs:393 — xai_grok_sandbox::deny::glob::expand_deny_globs 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.
  • xai_grok_sandbox::command::git_config::present_matches (cyclomatic 16) crates/codegen/xai-grok-sandbox/src/command/git_config.rs:611 — xai_grok_sandbox::command::git_config::present_matches has cyclomatic complexity 16 (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.
D2 · Cognitive Complexity · AcpUpdateTracker · ×4
  • AcpUpdateTracker::handle_tool_call_update (cognitive 111) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1290 — AcpUpdateTracker::handle_tool_call_update has cognitive complexity 111 (threshold 15). Drivers by points: if/else 35 (102 pts), boolean chains 7, match/switch 1 (2 pts) (nesting depth added 68). 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.
  • AcpUpdateTracker::handle_user_message (cognitive 59) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1488 — AcpUpdateTracker::handle_user_message has cognitive complexity 59 (threshold 15). Drivers by points: if/else 29 (43 pts), boolean chains 7, loops 3 (6 pts), match/switch 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.
  • AcpUpdateTracker::handle_update (cognitive 24) crates/codegen/xai-grok-pager/src/acp/tracker.rs:941 — AcpUpdateTracker::handle_update has cognitive complexity 24 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 4, 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.
  • AcpUpdateTracker::handle_tool_call (cognitive 22) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1191 — AcpUpdateTracker::handle_tool_call has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (20 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.
D2 · Cognitive Complexity · xai_grok_update · ×4
  • xai_grok_update::auto_update::run_update_if_available (cognitive 52) crates/codegen/xai-grok-update/src/auto_update.rs:711 — xai_grok_update::auto_update::run_update_if_available has cognitive complexity 52 (threshold 15). Drivers by points: if/else 29 (48 pts), boolean chains 3, 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.
  • xai_grok_update::auto_update::run_update (cognitive 40) crates/codegen/xai-grok-update/src/auto_update.rs:2561 — xai_grok_update::auto_update::run_update has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (23 pts), match/switch 6 (11 pts), boolean chains 6 (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.
  • xai_grok_update::cleanup_downloads::cleanup_old_downloads_with (cognitive 33) crates/codegen/xai-grok-update/src/cleanup_downloads.rs:12 — xai_grok_update::cleanup_downloads::cleanup_old_downloads_with has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 3 (5 pts), boolean chains 2, 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.
  • xai_grok_update::auto_update::replace_managed_bins (cognitive 20) crates/codegen/xai-grok-update/src/auto_update.rs:1825 — xai_grok_update::auto_update::replace_managed_bins has cognitive complexity 20 (threshold 15). Drivers by points: loops 6 (12 pts), if/else 1 (4 pts), match/switch 2 (4 pts) (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · JsonlStorageAdapter · ×4
  • JsonlStorageAdapter::copy_session_data_sync (cognitive 40) crates/codegen/xai-grok-shell/src/session/storage/jsonl/copy.rs:270 — JsonlStorageAdapter::copy_session_data_sync has cognitive complexity 40 (threshold 15). Drivers by points: if/else 21 (28 pts), boolean chains 5, loops 3 (5 pts), 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.
  • JsonlStorageAdapter::read_chat_history_sync_bounded (cognitive 33) crates/codegen/xai-grok-shell/src/session/storage/jsonl/mod.rs:964 — JsonlStorageAdapter::read_chat_history_sync_bounded has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (19 pts), match/switch 3 (7 pts), boolean chains 4, 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.
  • JsonlStorageAdapter::load_workflow_runs_sync (cognitive 29) crates/codegen/xai-grok-shell/src/session/storage/jsonl/mod.rs:806 — JsonlStorageAdapter::load_workflow_runs_sync has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 6 (12 pts), boolean chains 4, 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.
  • JsonlStorageAdapter::list_sessions_recent_sync (cognitive 18) crates/codegen/xai-grok-shell/src/session/storage/jsonl/mod.rs:322 — JsonlStorageAdapter::list_sessions_recent_sync has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (11 pts), boolean chains 3, loops 2, match/switch 1 (2 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.
D2 · Cognitive Complexity · xai_grok_voice · ×4
  • xai_grok_voice::pipeline::start_capture_session (cognitive 38) crates/codegen/xai-grok-voice/src/pipeline.rs:317 — xai_grok_voice::pipeline::start_capture_session has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (29 pts), match/switch 5 (8 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.
  • xai_grok_voice::pipeline::forward_pcm (cognitive 19) crates/codegen/xai-grok-voice/src/pipeline.rs:265 — xai_grok_voice::pipeline::forward_pcm has cognitive complexity 19 (threshold 15). Drivers by points: if/else 3 (8 pts), match/switch 3 (8 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.
  • xai_grok_voice::pipeline::run_voice_pipeline (cognitive 16) crates/codegen/xai-grok-voice/src/pipeline.rs:137 — xai_grok_voice::pipeline::run_voice_pipeline has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), match/switch 2 (5 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.
  • xai_grok_voice::probe::run_streaming_probe (cognitive 16) crates/codegen/xai-grok-voice/src/probe.rs:39 — xai_grok_voice::probe::run_streaming_probe has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), match/switch 2 (4 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.
D2 · Cognitive Complexity · AuthManager · ×4
  • AuthManager::apply_refresh_outcome (cognitive 37) crates/codegen/xai-grok-login/src/manager.rs:1409 — AuthManager::apply_refresh_outcome has cognitive complexity 37 (threshold 15). Drivers by points: if/else 9 (22 pts), match/switch 5 (13 pts), boolean chains 2 (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.
  • AuthManager::refresh_chain (cognitive 32) crates/codegen/xai-grok-login/src/manager/refresh_chain.rs:59 — AuthManager::refresh_chain has cognitive complexity 32 (threshold 15). Drivers by points: match/switch 7 (21 pts), if/else 5 (8 pts), boolean chains 2, loops 1 (nesting depth added 17). 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.
  • AuthManager::start_proactive_refresh (cognitive 22) crates/codegen/xai-grok-login/src/manager.rs:1763 — AuthManager::start_proactive_refresh has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 2 (4 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.
  • AuthManager::auth_dispatch (cognitive 19) crates/codegen/xai-grok-login/src/manager.rs:1335 — AuthManager::auth_dispatch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 3, match/switch 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.
D2 · Cognitive Complexity · BatchDreamSession · ×4
  • BatchDreamSession::resolve (cognitive 36) crates/codegen/xai-grok-memory/src/batch_dream_plan.rs:351 — BatchDreamSession::resolve has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (26 pts), boolean chains 5, match/switch 4 (5 pts) (nesting depth added 15). 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.
  • BatchDreamSession::settle_outcomes (cognitive 32) crates/codegen/xai-grok-memory/src/batch_dream_plan.rs:220 — BatchDreamSession::settle_outcomes has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 4 (11 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.
  • BatchDreamSession::search (cognitive 22) crates/codegen/xai-grok-memory/src/batch_dream_session.rs:294 — BatchDreamSession::search has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 2 (3 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.
  • BatchDreamSession::check (cognitive 16) crates/codegen/xai-grok-memory/src/batch_dream_plan.rs:154 — BatchDreamSession::check has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (8 pts), loops 3 (4 pts), boolean chains 2, match/switch 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.
D2 · Cognitive Complexity · ExecuteToolCallBlock · ×4
  • ExecuteToolCallBlock::push_header_lines (cognitive 36) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:383 — ExecuteToolCallBlock::push_header_lines has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (25 pts), loops 4 (9 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ExecuteToolCallBlock::render_with_truncation (cognitive 30) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:471 — ExecuteToolCallBlock::render_with_truncation has cognitive complexity 30 (threshold 15). Drivers by points: loops 5 (17 pts), if/else 7 (11 pts), boolean chains 2 (nesting depth added 16). 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.
  • ExecuteToolCallBlock::header_lines (cognitive 22) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:319 — ExecuteToolCallBlock::header_lines has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 4 (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.
  • ExecuteToolCallBlock::push_command_soft_wrap (cognitive 16) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:212 — ExecuteToolCallBlock::push_command_soft_wrap has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 1, 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, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · FeedbackModalState · ×4
  • FeedbackModalState::render_drafts (cognitive 35) crates/codegen/xai-grok-pager/src/views/feedback_modal/render.rs:98 — FeedbackModalState::render_drafts has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (29 pts), boolean chains 3, loops 1 (2 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.
  • FeedbackModalState::handle_drafts_key (cognitive 32) crates/codegen/xai-grok-pager/src/views/feedback_modal/drafts.rs:571 — FeedbackModalState::handle_drafts_key has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (23 pts), match/switch 4 (7 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.
  • FeedbackModalState::handle_mouse (cognitive 25) crates/codegen/xai-grok-pager/src/views/feedback_modal/mod.rs:974 — FeedbackModalState::handle_mouse has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 5, 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.
  • FeedbackModalState::handle_key (cognitive 24) crates/codegen/xai-grok-pager/src/views/feedback_modal/mod.rs:729 — FeedbackModalState::handle_key has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (14 pts), match/switch 5 (6 pts), boolean chains 4 (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.
D2 · Cognitive Complexity · xai_grok_shell_terminal · ×4
  • xai_grok_shell_terminal::pty_session::run_pty_output_loop (cognitive 30) crates/codegen/xai-grok-shell-terminal/src/pty_session.rs:395 — xai_grok_shell_terminal::pty_session::run_pty_output_loop has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (20 pts), match/switch 3 (7 pts), 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.
  • xai_grok_shell_terminal::exit_watcher::watch_for_exit (cognitive 24) crates/codegen/xai-grok-shell-terminal/src/exit_watcher.rs:75 — xai_grok_shell_terminal::exit_watcher::watch_for_exit has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (12 pts), match/switch 5 (11 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.
  • xai_grok_shell_terminal::streaming_local_terminal::run_output_collector (cognitive 24) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:1049 — xai_grok_shell_terminal::streaming_local_terminal::run_output_collector has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 5 (12 pts), if/else 3 (10 pts), boolean chains 1, loops 1 (nesting depth added 14). 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.
  • xai_grok_shell_terminal::output_recorder::largest_overlap (cognitive 20) crates/codegen/xai-grok-shell-terminal/src/output_recorder.rs:103 — xai_grok_shell_terminal::output_recorder::largest_overlap has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (5 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.
D2 · Cognitive Complexity · xai_grok_telemetry · ×4
  • xai_grok_telemetry::external::emit::emit_record (cognitive 29) crates/codegen/xai-grok-telemetry/src/external/emit.rs:65 — xai_grok_telemetry::external::emit::emit_record has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 4 (6 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_telemetry::spans::instrumentation::generate_chrome_trace (cognitive 26) crates/codegen/xai-grok-telemetry/src/spans/instrumentation.rs:379 — xai_grok_telemetry::spans::instrumentation::generate_chrome_trace has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), match/switch 5 (10 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.
  • xai_grok_telemetry::sentry::before_send (cognitive 25) crates/codegen/xai-grok-telemetry/src/sentry.rs:201 — xai_grok_telemetry::sentry::before_send has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 6 (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.
  • xai_grok_telemetry::client::track (cognitive 16) crates/codegen/xai-grok-telemetry/src/client.rs:275 — xai_grok_telemetry::client::track has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (11 pts), match/switch 2 (3 pts), loops 1 (2 pts) (nesting depth added 4). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · TasksPane · ×4
  • TasksPane::sync (cognitive 28) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:698 — TasksPane::sync has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 6, loops 5 (6 pts), 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.
  • TasksPane::render_agent_overlay (cognitive 19) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1369 — TasksPane::render_agent_overlay has cognitive complexity 19 (threshold 15). Drivers by points: if/else 18 (19 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • TasksPane::render (cognitive 16) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1020 — TasksPane::render has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 5 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TasksPane::render_bg_task_overlay (cognitive 16) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1243 — TasksPane::render_bg_task_overlay has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (14 pts), match/switch 1 (2 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · xai_grok_plugin_marketplace · ×4
  • xai_grok_plugin_marketplace::installer::update_from_marketplace_entry_transactional (cognitive 21) crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:185 — xai_grok_plugin_marketplace::installer::update_from_marketplace_entry_transactional has cognitive complexity 21 (threshold 15). Drivers by points: if/else 15 (19 pts), boolean chains 1, match/switch 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, 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.
  • xai_grok_plugin_marketplace::installer::discover_plugins_in_dir (cognitive 21) crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:581 — xai_grok_plugin_marketplace::installer::discover_plugins_in_dir has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 2 (5 pts), loops 1 (2 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.
  • xai_grok_plugin_marketplace::scanner::scan_marketplace (cognitive 21) crates/codegen/xai-grok-plugin-marketplace/src/scanner.rs:14 — xai_grok_plugin_marketplace::scanner::scan_marketplace has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (12 pts), match/switch 3 (7 pts), loops 1 (2 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.
  • xai_grok_plugin_marketplace::config::load_extra_sources_from_settings_in (cognitive 19) crates/codegen/xai-grok-plugin-marketplace/src/config.rs:202 — xai_grok_plugin_marketplace::config::load_extra_sources_from_settings_in has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 5 (10 pts), if/else 2 (5 pts), loops 3 (4 pts) (nesting depth added 9). 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.
D30 · Dependency Vulnerabilities · Medium CVE · ×4
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×4
  • Members sharing a duplicated core (6 members, 50+ identical tokens) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:243 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:243-255 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs:315-328 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:258-270 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:233-245 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:279-291 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:320-332 — 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) crates/codegen/xai-grok-pager/src/views/elicitation_view/render.rs:189 — crates/codegen/xai-grok-pager/src/views/elicitation_view/render.rs:189-384 | crates/codegen/xai-grok-pager/src/views/modal.rs:876-963 | crates/codegen/xai-grok-pager/src/views/overlay_list.rs:89-156 | crates/codegen/xai-grok-pager/src/views/permission_view.rs:432-714 | crates/codegen/xai-grok-pager/src/views/question_view.rs:1541-1689 | crates/codegen/xai-grok-pager/src/views/rewind.rs:321-546 — 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) crates/codegen/xai-grok-sampler/src/client.rs:924 — crates/codegen/xai-grok-sampler/src/client.rs:924-971 | crates/codegen/xai-grok-sampler/src/client.rs:1065-1225 | crates/codegen/xai-grok-sampler/src/client.rs:1280-1384 | crates/codegen/xai-grok-sampler/src/client.rs:1423-1615 | crates/codegen/xai-grok-sampler/src/client.rs:1648-1742 | crates/codegen/xai-grok-sampler/src/client.rs:1775-1940 — 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) crates/codegen/xai-grok-shell/src/remote/client.rs:81 — crates/codegen/xai-grok-shell/src/remote/client.rs:81-111 | crates/codegen/xai-grok-shell/src/remote/client.rs:468-490 | crates/codegen/xai-grok-shell/src/remote/client.rs:497-514 | crates/codegen/xai-grok-shell/src/remote/client.rs:516-532 | crates/codegen/xai-grok-shell/src/remote/client.rs:560-571 | crates/codegen/xai-grok-shell/src/remote/client.rs:573-585 — 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.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×4
  • Duplicated block (25 lines × 2) crates/codegen/xai-grok-markdown/src/render.rs:697 — crates/codegen/xai-grok-markdown/src/render.rs:697-721 | crates/codegen/xai-grok-markdown/src/render.rs:994-1018 — both copies are in the same file, so extract the 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 (25 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:97 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:97-121 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:195-219 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 74 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 (25 lines × 2) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:561 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:561-585 | crates/codegen/xai-grok-shell/src/extensions/bundle.rs:264-288 — 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 (25 lines × 2) crates/codegen/xai-grok-test-support/src/sse.rs:390 — crates/codegen/xai-grok-test-support/src/sse.rs:390-414 | crates/codegen/xai-grok-test-support/src/sse.rs:651-675 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×4
  • Duplicated block (20 lines × 2) crates/codegen/xai-grok-markdown/src/mermaid.rs:2471 — crates/codegen/xai-grok-markdown/src/mermaid.rs:2471-2490 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2614-2633 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager-minimal/src/overlay.rs:715 — crates/codegen/xai-grok-pager-minimal/src/overlay.rs:715-734 | crates/codegen/xai-grok-pager-minimal/src/plan.rs:197-216 — 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 (20 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:898 — crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:898-917 | crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1282-1301 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-shell/src/session/acp_session_impl/reminders.rs:258 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/reminders.rs:258-277 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/reminders.rs:401-420 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (13–14 lines × 2) · ×4
  • Duplicated block (13–14 lines × 2) crates/codegen/xai-grok-pager/src/app/event_loop.rs:2022 — crates/codegen/xai-grok-pager/src/app/event_loop.rs:2022-2034 | crates/codegen/xai-grok-pager/src/app/event_loop.rs:2048-2061 — both copies are in the same file, so extract the 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–14 lines × 2) crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:229 — crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:229-241 | crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:280-293 — both copies are in the same file, so extract the 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–14 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/image_edit/mod.rs:120 — crates/codegen/xai-grok-tools/src/implementations/grok_build/image_edit/mod.rs:120-132 | crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:888-901 — 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 (13–14 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:764 — crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:764-776 | crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs:491-504 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs` as WHOLE FILES: this scan already matched 7 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. 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.
D4 · Code Duplication · Duplicated block (11 lines × 4) · ×4
  • Duplicated block (11 lines × 4) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:74 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:74-84 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:118-128 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:101-111 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:94-104 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 142 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 (11 lines × 4) crates/codegen/xai-grok-tools/src/implementations/grok_build/kill_task/mod.rs:102 — crates/codegen/xai-grok-tools/src/implementations/grok_build/kill_task/mod.rs:102-112 | crates/codegen/xai-grok-tools/src/implementations/grok_build/send_feedback.rs:222-232 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs:823-833 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/wait_tasks.rs:60-70 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/wait_tasks.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 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 (11 lines × 4) crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2840 — crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2840-2865 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2872-2882 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2913-2923 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:3091-3101 — 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 (11 lines × 4) crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:204 — crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:204-214 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:233-243 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:263-273 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:293-303 — 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.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×4
  • Duplicated block (9 lines × 4) crates/codegen/xai-grok-pager-minimal/src/panel.rs:161 — crates/codegen/xai-grok-pager-minimal/src/panel.rs:161-169 | crates/codegen/xai-grok-pager-minimal/src/panel.rs:212-220 | crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:2353-2361 | crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:2434-2442 — 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.
  • Duplicated block (9 lines × 4) crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:1142 — crates/codegen/xai-grok-pager/src/app/dispatch/dashboard.rs:1142-1150 | crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:726-734 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:50-58 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:192-200 — 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.
  • Duplicated block (9 lines × 4) crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:408 — crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:408-416 | crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:444-452 | crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:475-483 | crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:506-514 — 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 (9 lines × 4) crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:177 — crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:177-185 | crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:232-240 | crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:316-324 | crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:469-477 — 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.
D4 · Code Duplication · Duplicated block (8 lines × 4) · ×4
  • Duplicated block (8 lines × 4) crates/codegen/xai-grok-agent/src/config.rs:261 — crates/codegen/xai-grok-agent/src/config.rs:261-268 | crates/codegen/xai-grok-agent/src/config.rs:392-399 | crates/codegen/xai-grok-agent/src/config.rs:471-478 | crates/codegen/xai-grok-agent/src/config.rs:499-506 — 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) crates/codegen/xai-grok-sampler/src/actor/request_task.rs:935 — crates/codegen/xai-grok-sampler/src/actor/request_task.rs:935-942 | crates/codegen/xai-grok-sampling-types/src/error.rs:398-405 | crates/codegen/xai-grok-sampling-types/src/error.rs:479-487 | crates/codegen/xai-grok-sampling-types/src/error.rs:502-510 — 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.
  • Duplicated block (8 lines × 4) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:1388 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:1388-1396 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs:195-202 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:402-409 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search.rs:501-508 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 33 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 (8 lines × 4) crates/codegen/xai-grok-pager/src/app/app_view.rs:97 — crates/codegen/xai-grok-pager/src/app/app_view.rs:97-104 | crates/codegen/xai-grok-pager/src/views/agents_modal.rs:2066-2073 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:4246-4253 | crates/codegen/xai-grok-pager/src/views/persona_detail.rs:853-860 — 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.
D4 · Code Duplication · Duplicated block (7 lines × 4) · ×4
  • Duplicated block (7 lines × 4) crates/codegen/xai-grok-agent/src/config.rs:271 — crates/codegen/xai-grok-agent/src/config.rs:271-277 | crates/codegen/xai-grok-agent/src/config.rs:401-407 | crates/codegen/xai-grok-agent/src/config.rs:479-485 | crates/codegen/xai-grok-agent/src/config.rs:509-515 — 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 (7 lines × 4) crates/codegen/xai-grok-sampler/src/client.rs:2013 — crates/codegen/xai-grok-sampler/src/client.rs:2013-2019 | crates/codegen/xai-grok-sampler/src/client.rs:2050-2056 | crates/codegen/xai-grok-sampler/src/client.rs:2089-2095 | crates/codegen/xai-grok-sampler/src/client.rs:2122-2128 — 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 (7 lines × 4) crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2066 — crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2066-2072 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2123-2129 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2180-2186 | crates/codegen/xai-grok-shell/src/agent/mvp_agent/acp_agent.rs:2240-2246 — 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 (7 lines × 4) crates/codegen/xai-grok-shell/src/util/config/resolve/auto_mode.rs:149 — crates/codegen/xai-grok-shell/src/util/config/resolve/auto_mode.rs:149-155 | crates/codegen/xai-grok-shell/src/util/config/resolve/prompt_suggest.rs:147-153 | crates/codegen/xai-grok-shell/src/util/config/resolve/tool_approvals.rs:93-99 | crates/codegen/xai-grok-shell/src/util/config/resolve/toolset.rs:81-87 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/util/config/resolve/auto_mode.rs` and `crates/codegen/xai-grok-shell/src/util/config/resolve/prompt_suggest.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 34 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.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×4
  • Duplicated block (6 lines × 3) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1246 — crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1246-1251 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1323-1328 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1347-1352 — 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 (6 lines × 3) crates/codegen/xai-grok-shell/src/extensions/mcp.rs:1587 — crates/codegen/xai-grok-shell/src/extensions/mcp.rs:1587-1592 | crates/codegen/xai-grok-shell/src/extensions/mcp.rs:1655-1660 | crates/codegen/xai-grok-shell/src/extensions/mcp.rs:2164-2169 — 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 (6 lines × 3) crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/seek_sequence.rs:57 — crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/seek_sequence.rs:57-62 | crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/seek_sequence.rs:75-80 | crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/seek_sequence.rs:115-120 — 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 (6 lines × 3) crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/completion.rs:135 — crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/completion.rs:135-140 | crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/recovery.rs:154-159 | crates/codegen/xai-grok-shell/src/agent/subagent/attempt_store/rewind.rs:126-131 — 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.
P7 · Outbound HTTP resilience · Outbound HTTP without resilience · ×4
  • Outbound HTTP without resilience crates/codegen/xai-grok-extra-ca/src/lib.rs:59 — `reqwest::Client::builder(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience crates/codegen/xai-grok-extra-ca/src/lib.rs:75 — `reqwest::blocking::Client::builder(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience crates/codegen/xai-grok-shell/src/session/agent_rebuild.rs:303 — `AgentBuilder::new(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience crates/common/xai-tracing/src/http_client.rs:24 — `reqwest::Client::new(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
PF3 · Async & latency hygiene · Sync-over-async blocking · ×4
  • Sync-over-async blocking crates/codegen/xai-grok-pager/src/acp/spawn.rs:365 — `spawn_agent_thread_direct` is async and calls block_on — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs.
  • Sync-over-async blocking crates/codegen/xai-grok-pager/src/headless/signals.rs:114 — `spawn_watcher` is async and calls block_on — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs.
  • Sync-over-async blocking crates/codegen/xai-grok-pager-pty-harness/src/scroll_matrix/runner.rs:138 — `run_cell_inner` is async and calls thread::sleep — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs.
  • Sync-over-async blocking crates/codegen/xai-grok-shell/src/session/acp_session_impl/spawn.rs:2549 — `spawn_session_on_thread` is async and calls block_on — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs.
D1 · Cyclomatic Complexity · AcpUpdateTracker · ×3
  • AcpUpdateTracker::handle_user_message (cyclomatic 40) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1488 — AcpUpdateTracker::handle_user_message 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.
  • AcpUpdateTracker::handle_tool_call_update (cyclomatic 39) crates/codegen/xai-grok-pager/src/acp/tracker.rs:1290 — AcpUpdateTracker::handle_tool_call_update 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.
  • AcpUpdateTracker::handle_update (cyclomatic 24) crates/codegen/xai-grok-pager/src/acp/tracker.rs:941 — AcpUpdateTracker::handle_update 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.
D1 · Cyclomatic Complexity · xai_grok_sampling_types · ×3
  • xai_grok_sampling_types::conversation::messages::build_messages_request (cyclomatic 34) crates/codegen/xai-grok-sampling-types/src/conversation/messages.rs:75 — xai_grok_sampling_types::conversation::messages::build_messages_request 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.
  • xai_grok_sampling_types::conversation::transform_conversation_cwd (cyclomatic 20) crates/codegen/xai-grok-sampling-types/src/conversation.rs:1861 — xai_grok_sampling_types::conversation::transform_conversation_cwd 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.
  • xai_grok_sampling_types::conversation::upgrade_legacy_reasoning (cyclomatic 16) crates/codegen/xai-grok-sampling-types/src/conversation.rs:1482 — xai_grok_sampling_types::conversation::upgrade_legacy_reasoning 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.
D1 · Cyclomatic Complexity · xai_grok_hooks · ×3
  • xai_grok_hooks::runner::command::find_local_shell_assignments (cyclomatic 33) crates/codegen/xai-grok-hooks/src/runner/command.rs:572 — xai_grok_hooks::runner::command::find_local_shell_assignments 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.
  • xai_grok_hooks::runner::command::run_command_hook (cyclomatic 28) crates/codegen/xai-grok-hooks/src/runner/command.rs:103 — xai_grok_hooks::runner::command::run_command_hook 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.
  • xai_grok_hooks::runner::http::is_blocked_ip (cyclomatic 18) crates/codegen/xai-grok-hooks/src/runner/http.rs:36 — xai_grok_hooks::runner::http::is_blocked_ip 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.
D1 · Cyclomatic Complexity · ScrollbackPane · ×3
  • ScrollbackPane::render_content (cyclomatic 29) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:869 — ScrollbackPane::render_content 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.
  • ScrollbackPane::render_entry_with_ctx_static (cyclomatic 26) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:712 — ScrollbackPane::render_entry_with_ctx_static 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.
  • ScrollbackPane::render_with_sticky_headers (cyclomatic 19) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:294 — ScrollbackPane::render_with_sticky_headers 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.
D1 · Cyclomatic Complexity · xai_grok_update · ×3
  • xai_grok_update::auto_update::run_update (cyclomatic 29) crates/codegen/xai-grok-update/src/auto_update.rs:2561 — xai_grok_update::auto_update::run_update 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.
  • xai_grok_update::auto_update::run_update_if_available (cyclomatic 28) crates/codegen/xai-grok-update/src/auto_update.rs:711 — xai_grok_update::auto_update::run_update_if_available 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.
  • xai_grok_update::cleanup_downloads::cleanup_old_downloads_with (cyclomatic 19) crates/codegen/xai-grok-update/src/cleanup_downloads.rs:12 — xai_grok_update::cleanup_downloads::cleanup_old_downloads_with 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.
D1 · Cyclomatic Complexity · JsonlStorageAdapter · ×3
  • JsonlStorageAdapter::copy_session_data_sync (cyclomatic 28) crates/codegen/xai-grok-shell/src/session/storage/jsonl/copy.rs:270 — JsonlStorageAdapter::copy_session_data_sync 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.
  • JsonlStorageAdapter::read_chat_history_sync_bounded (cyclomatic 24) crates/codegen/xai-grok-shell/src/session/storage/jsonl/mod.rs:964 — JsonlStorageAdapter::read_chat_history_sync_bounded 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.
  • JsonlStorageAdapter::load_workflow_runs_sync (cyclomatic 22) crates/codegen/xai-grok-shell/src/session/storage/jsonl/mod.rs:806 — JsonlStorageAdapter::load_workflow_runs_sync has cyclomatic complexity 22 (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.
D1 · Cyclomatic Complexity · SchedulerActor · ×3
  • SchedulerActor::fire_next_task (cyclomatic 28) crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:295 — SchedulerActor::fire_next_task has cyclomatic complexity 28 (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.
  • SchedulerActor::fire_as_loop_subagent (cyclomatic 27) crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:572 — SchedulerActor::fire_as_loop_subagent has cyclomatic complexity 27 (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.
  • SchedulerActor::handle_command (cyclomatic 17) crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:885 — SchedulerActor::handle_command 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.
D17 · Explicit Debt · HackComment · ×3
  • HackComment crates/codegen/xai-ratatui-inline/src/terminal.rs:314 — // HACK — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment crates/codegen/xai-ratatui-inline/src/terminal.rs:1232 — /// HACK: this is added — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment crates/codegen/xai-ratatui-inline/src/terminal.rs:1308 — /// HACK: this is made pub — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
D2 · Cognitive Complexity · ParsedMarkdown · ×3
  • ParsedMarkdown::render_ratatui (cognitive 304) crates/codegen/xai-grok-markdown/src/render.rs:530 — ParsedMarkdown::render_ratatui has cognitive complexity 304 (threshold 15). Drivers by points: if/else 63 (227 pts), loops 13 (52 pts), boolean chains 22, match/switch 2 (3 pts) (nesting depth added 204). 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.
  • ParsedMarkdown::render_ansi (cognitive 86) crates/codegen/xai-grok-markdown/src/render.rs:272 — ParsedMarkdown::render_ansi has cognitive complexity 86 (threshold 15). Drivers by points: if/else 26 (58 pts), boolean chains 15, loops 4 (11 pts), match/switch 1 (2 pts) (nesting depth added 40). Of this number, 78 points are the body's own statements and 8 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ParsedMarkdown::apply_transforms (cognitive 18) crates/codegen/xai-grok-markdown/src/render.rs:142 — ParsedMarkdown::apply_transforms has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 5, 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.
D2 · Cognitive Complexity · xai_grok_pager_bin · ×3
  • xai_grok_pager_bin::run_agent_command (cognitive 112) crates/codegen/xai-grok-pager-bin/src/main.rs:1227 — xai_grok_pager_bin::run_agent_command has cognitive complexity 112 (threshold 15). Drivers by points: if/else 27 (53 pts), match/switch 13 (42 pts), loops 3 (9 pts), boolean chains 8 (nesting depth added 61). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • xai_grok_pager_bin::async_main (cognitive 50) crates/codegen/xai-grok-pager-bin/src/main.rs:2133 — xai_grok_pager_bin::async_main has cognitive complexity 50 (threshold 15). Drivers by points: if/else 23 (37 pts), match/switch 5 (8 pts), boolean chains 5 (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.
  • xai_grok_pager_bin::kill_leaders (cognitive 17) crates/codegen/xai-grok-pager-bin/src/main.rs:382 — xai_grok_pager_bin::kill_leaders has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (16 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.
D2 · Cognitive Complexity · BashTool · ×3
  • BashTool::execute (cognitive 59) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:1725 — BashTool::execute has cognitive complexity 59 (threshold 15). Drivers by points: if/else 10 (38 pts), match/switch 3 (10 pts), loops 3 (9 pts), boolean chains 2 (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.
  • BashTool::run (cognitive 49) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:1868 — BashTool::run has cognitive complexity 49 (threshold 15). Drivers by points: if/else 22 (37 pts), match/switch 4 (7 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.
  • BashTool::exported_input_schema (cognitive 29) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:1365 — BashTool::exported_input_schema has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (26 pts), boolean chains 3 (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · CompiledPolicy · ×3
  • CompiledPolicy::evaluate_shell_file_access_inner (cognitive 57) crates/codegen/xai-grok-permission-rules/src/shell_access.rs:40 — CompiledPolicy::evaluate_shell_file_access_inner has cognitive complexity 57 (threshold 15). Drivers by points: if/else 15 (33 pts), loops 6 (12 pts), boolean chains 8, match/switch 2 (4 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.
  • CompiledPolicy::evaluate_rules_with_base (cognitive 19) crates/codegen/xai-grok-permission-rules/src/policy.rs:275 — CompiledPolicy::evaluate_rules_with_base has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (9 pts), match/switch 3 (8 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.
  • CompiledPolicy::bash_chain_fully_allowed (cognitive 16) crates/codegen/xai-grok-permission-rules/src/policy/bash_commands.rs:58 — CompiledPolicy::bash_chain_fully_allowed has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 1 (2 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.
D2 · Cognitive Complexity · BlockViewerPane · ×3
  • BlockViewerPane::render_text_drag_overlay (cognitive 50) crates/codegen/xai-grok-pager/src/views/block_viewer/selection.rs:477 — BlockViewerPane::render_text_drag_overlay has cognitive complexity 50 (threshold 15). Drivers by points: if/else 18 (37 pts), loops 4 (10 pts), boolean chains 3 (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.
  • BlockViewerPane::handle_mouse (cognitive 44) crates/codegen/xai-grok-pager/src/views/block_viewer/selection.rs:221 — BlockViewerPane::handle_mouse has cognitive complexity 44 (threshold 15). Drivers by points: if/else 15 (34 pts), boolean chains 5, match/switch 3 (5 pts) (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.
  • BlockViewerPane::process_pending_copy (cognitive 16) crates/codegen/xai-grok-pager/src/views/block_viewer/mod.rs:1283 — BlockViewerPane::process_pending_copy has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 2 (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.
D2 · Cognitive Complexity · xai_ratatui_inline · ×3
  • xai_ratatui_inline::segment::split_into_line_segments (cognitive 47) crates/codegen/xai-ratatui-inline/src/segment.rs:84 — xai_ratatui_inline::segment::split_into_line_segments has cognitive complexity 47 (threshold 15). Drivers by points: if/else 16 (42 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 27). 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.
  • xai_ratatui_inline::resize::resize_viewport_height (cognitive 17) crates/codegen/xai-ratatui-inline/src/resize.rs:68 — xai_ratatui_inline::resize::resize_viewport_height has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 1 (3 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.
  • xai_ratatui_inline::terminal::emit_frame_with_links (cognitive 16) crates/codegen/xai-ratatui-inline/src/terminal.rs:1126 — xai_ratatui_inline::terminal::emit_frame_with_links has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts) (nesting depth added 8). 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.
D2 · Cognitive Complexity · xai_grok_external_agent_migration · ×3
  • xai_grok_external_agent_migration::reporting::format_item_summary (cognitive 38) crates/codegen/xai-grok-external-agent-migration/src/reporting.rs:31 — xai_grok_external_agent_migration::reporting::format_item_summary has cognitive complexity 38 (threshold 15). Drivers by points: loops 7 (14 pts), match/switch 10 (14 pts), if/else 9 (10 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.
  • xai_grok_external_agent_migration::hooks_cla::extract_hooks_from_settings_file (cognitive 22) crates/codegen/xai-grok-external-agent-migration/src/hooks_cla.rs:8 — xai_grok_external_agent_migration::hooks_cla::extract_hooks_from_settings_file has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (16 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.
  • xai_grok_external_agent_migration::hooks_cla::refresh_existing_hook_timeout (cognitive 18) crates/codegen/xai-grok-external-agent-migration/src/hooks_cla.rs:181 — xai_grok_external_agent_migration::hooks_cla::refresh_existing_hook_timeout has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (10 pts), match/switch 1 (4 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.
D2 · Cognitive Complexity · SchedulerActor · ×3
  • SchedulerActor::fire_next_task (cognitive 38) crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:295 — SchedulerActor::fire_next_task has cognitive complexity 38 (threshold 15). Drivers by points: if/else 17 (22 pts), match/switch 6 (13 pts), boolean chains 3 (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.
  • SchedulerActor::fire_as_loop_subagent (cognitive 35) crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:572 — SchedulerActor::fire_as_loop_subagent has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (17 pts), match/switch 7 (15 pts), boolean chains 3 (nesting depth added 11). 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.
  • SchedulerActor::handle_command (cognitive 29) crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:885 — SchedulerActor::handle_command has cognitive complexity 29 (threshold 15). Drivers by points: if/else 13 (28 pts), match/switch 1 (nesting depth added 15). 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.
D2 · Cognitive Complexity · SearchToolCallBlock · ×3
  • SearchToolCallBlock::output (cognitive 37) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search.rs:370 — SearchToolCallBlock::output has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 4 (13 pts), boolean chains 1, 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.
  • SearchToolCallBlock::header_line (cognitive 23) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search.rs:203 — SearchToolCallBlock::header_line has cognitive complexity 23 (threshold 15). Drivers by points: if/else 19 (22 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.
  • SearchToolCallBlock::output (cognitive 19) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:175 — SearchToolCallBlock::output has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 1 (3 pts), 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.
D2 · Cognitive Complexity · V2ConsolidationStore · ×3
  • V2ConsolidationStore::prepare_changes (cognitive 31) crates/codegen/xai-grok-memory/src/v2_consolidation.rs:1318 — V2ConsolidationStore::prepare_changes has cognitive complexity 31 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 4 (10 pts), match/switch 1 (2 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.
  • V2ConsolidationStore::manual_inbox_notes (cognitive 20) crates/codegen/xai-grok-memory/src/v2_consolidation.rs:713 — V2ConsolidationStore::manual_inbox_notes has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 2 (3 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.
  • V2ConsolidationStore::claim_with_visibility (cognitive 18) crates/codegen/xai-grok-memory/src/v2_consolidation.rs:253 — V2ConsolidationStore::claim_with_visibility has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 3, loops 2 (3 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.
D2 · Cognitive Complexity · xai_codebase_graph · ×3
  • xai_codebase_graph::index_manager::intern_symbols_directly (cognitive 30) crates/codegen/xai-codebase-graph/src/index_manager.rs:1380 — xai_codebase_graph::index_manager::intern_symbols_directly has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (25 pts), loops 3 (4 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.
  • xai_codebase_graph::manager::builder::extract_symbols_fast_inline (cognitive 23) crates/codegen/xai-codebase-graph/src/manager/builder.rs:392 — xai_codebase_graph::manager::builder::extract_symbols_fast_inline 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.
  • xai_codebase_graph::scope_graph::graph::extract_symbols_fast (cognitive 23) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:575 — xai_codebase_graph::scope_graph::graph::extract_symbols_fast 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.
D2 · Cognitive Complexity · xai_grok_login · ×3
  • xai_grok_login::flow::run_auth_flow_steps (cognitive 30) crates/codegen/xai-grok-login/src/flow.rs:448 — xai_grok_login::flow::run_auth_flow_steps has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (17 pts), match/switch 3 (7 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.
  • xai_grok_login::oidc::login::run_login_flow_with_config (cognitive 21) crates/codegen/xai-grok-login/src/oidc/login.rs:358 — xai_grok_login::oidc::login::run_login_flow_with_config has cognitive complexity 21 (threshold 15). Drivers by points: if/else 16 (19 pts), boolean chains 1, 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, 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.
  • xai_grok_login::oidc::refresh::oidc_token_exchange (cognitive 21) crates/codegen/xai-grok-login/src/oidc/refresh.rs:81 — xai_grok_login::oidc::refresh::oidc_token_exchange has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 3 (4 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · xai_grok_compaction · ×3
  • xai_grok_compaction::intra_compaction::fit::fit_turns_for_summarizer (cognitive 30) crates/common/xai-grok-compaction/src/intra_compaction/fit.rs:198 — xai_grok_compaction::intra_compaction::fit::fit_turns_for_summarizer has cognitive complexity 30 (threshold 15). Drivers by points: if/else 21 (28 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.
  • xai_grok_compaction::history::filter::split_prior_compaction_text (cognitive 26) crates/common/xai-grok-compaction/src/history/filter.rs:90 — xai_grok_compaction::history::filter::split_prior_compaction_text has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (25 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.
  • xai_grok_compaction::code_compaction::sample::sample_summary_with_retries (cognitive 24) crates/common/xai-grok-compaction/src/code_compaction/sample.rs:88 — xai_grok_compaction::code_compaction::sample::sample_summary_with_retries has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (17 pts), boolean chains 4, match/switch 1 (2 pts), 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.
D2 · Cognitive Complexity · ptyctl · ×3
  • ptyctl::styled::extract_styled_line (cognitive 27) crates/codegen/ptyctl/src/styled.rs:91 — ptyctl::styled::extract_styled_line has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (5 pts), boolean chains 4 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ptyctl::styled::render_html (cognitive 25) crates/codegen/ptyctl/src/styled.rs:166 — ptyctl::styled::render_html 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.
  • ptyctl::server::handle_ws_connection (cognitive 17) crates/codegen/ptyctl/src/server.rs:294 — ptyctl::server::handle_ws_connection has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 4 (9 pts), if/else 2 (6 pts), loops 2 (nesting depth added 9). 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.
D2 · Cognitive Complexity · Canvas · ×3
  • Canvas::to_lines (cognitive 27) crates/codegen/xai-grok-markdown/src/mermaid.rs:1671 — Canvas::to_lines has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 3 (5 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.
  • Canvas::flip_horizontal (cognitive 24) crates/codegen/xai-grok-markdown/src/mermaid.rs:1637 — Canvas::flip_horizontal has cognitive complexity 24 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 6 (11 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.
  • Canvas::blit (cognitive 22) crates/codegen/xai-grok-markdown/src/mermaid.rs:1523 — Canvas::blit has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (18 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.
D2 · Cognitive Complexity · BatchDreamStore · ×3
  • BatchDreamStore::persist_plan_as (cognitive 27) crates/codegen/xai-grok-memory/src/batch_dream_commit.rs:78 — BatchDreamStore::persist_plan_as has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 6, match/switch 3 (6 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.
  • BatchDreamStore::apply_planned (cognitive 24) crates/codegen/xai-grok-memory/src/batch_dream_commit.rs:222 — BatchDreamStore::apply_planned has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 4, boolean chains 2, 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.
  • BatchDreamStore::sync_queue (cognitive 18) crates/codegen/xai-grok-memory/src/batch_dream.rs:391 — BatchDreamStore::sync_queue has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), match/switch 2 (4 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.
D2 · Cognitive Complexity · xai_grok_foreign_sessions · ×3
  • xai_grok_foreign_sessions::claude::first_prompt (cognitive 26) crates/codegen/xai-grok-foreign-sessions/src/claude.rs:428 — xai_grok_foreign_sessions::claude::first_prompt has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (20 pts), loops 2 (3 pts), match/switch 1 (2 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.
  • xai_grok_foreign_sessions::claude::collect_candidates (cognitive 18) crates/codegen/xai-grok-foreign-sessions/src/claude.rs:274 — xai_grok_foreign_sessions::claude::collect_candidates has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 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.
  • xai_grok_foreign_sessions::claude::projects::scoped_project_dirs (cognitive 16) crates/codegen/xai-grok-foreign-sessions/src/claude/projects.rs:7 — xai_grok_foreign_sessions::claude::projects::scoped_project_dirs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 1 (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.
D2 · Cognitive Complexity · Terminal · ×3
  • Terminal::screen_content (cognitive 25) crates/codegen/ptyctl/src/term.rs:245 — Terminal::screen_content has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 5 (11 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.
  • Terminal::write_semantic_rows (cognitive 20) crates/codegen/xai-ratatui-inline/src/terminal.rs:864 — Terminal::write_semantic_rows has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 3, loops 1 (nesting depth added 8). 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.
  • Terminal::native_copy_text (cognitive 17) crates/codegen/ptyctl/src/term.rs:344 — Terminal::native_copy_text has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (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.
D2 · Cognitive Complexity · Watcher · ×3
  • Watcher::serve (cognitive 20) crates/codegen/xai-fsnotify/src/watcher.rs:317 — Watcher::serve has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 2 (6 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.
  • Watcher::arm (cognitive 19) crates/codegen/xai-fsnotify/src/watcher.rs:191 — Watcher::arm has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (11 pts), loops 2 (4 pts), match/switch 2 (4 pts) (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
  • Watcher::event_sink (cognitive 16) crates/codegen/xai-fsnotify/src/watcher.rs:127 — Watcher::event_sink has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 2 (3 pts), match/switch 2 (3 pts), boolean chains 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.
D2 · Cognitive Complexity · SamplingClient · ×3
  • SamplingClient::new (cognitive 19) crates/codegen/xai-grok-sampler/src/client.rs:510 — SamplingClient::new has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11, boolean chains 4, match/switch 2 (3 pts), 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.
  • SamplingClient::create_response_stream_inner (cognitive 19) crates/codegen/xai-grok-sampler/src/client.rs:1415 — SamplingClient::create_response_stream_inner has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (15 pts), match/switch 2 (3 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.
  • SamplingClient::post (cognitive 17) crates/codegen/xai-grok-sampler/src/client.rs:691 — SamplingClient::post has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 1 (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.
D2 · Cognitive Complexity · xai_grok_subagent_resolution · ×3
  • xai_grok_subagent_resolution::context::normalize_forked_context (cognitive 17) crates/codegen/xai-grok-subagent-resolution/src/context.rs:30 — xai_grok_subagent_resolution::context::normalize_forked_context has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 3 (8 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.
  • xai_grok_subagent_resolution::context::strip_xml_block (cognitive 16) crates/codegen/xai-grok-subagent-resolution/src/context.rs:177 — xai_grok_subagent_resolution::context::strip_xml_block 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.
  • xai_grok_subagent_resolution::context::render_item_to_background (cognitive 16) crates/codegen/xai-grok-subagent-resolution/src/context.rs:274 — xai_grok_subagent_resolution::context::render_item_to_background has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), match/switch 2 (3 pts), 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.
D3 · God Classes · MethodTooLong · ×3
  • MethodTooLong: ToolServer.run crates/common/xai-computer-hub-sdk/src/server.rs:1532 — MethodTooLong — run runs 202 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) 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: HubConnection.connect crates/common/xai-computer-hub-sdk/src/connection.rs:733 — MethodTooLong — connect runs 186 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 86 over it, 1.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.
  • MethodTooLong: ToolErrorWire.from crates/common/xai-tool-runtime/src/error.rs:296 — MethodTooLong — from runs 124 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 24 over it, 1.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.
D3 · God Classes · TooManyMethods · ×3
  • TooManyMethods: ToolHarness crates/common/xai-computer-hub-sdk/src/harness.rs:601 — TooManyMethods — 47 methods. The bar is 30 methods; this is 17 over it, 1.57× 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: ToolServerBuilder crates/common/xai-computer-hub-sdk/src/server.rs:213 — TooManyMethods — 33 methods. The bar is 30 methods; this is 3 over it, 1.10× 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: ToolServer crates/common/xai-computer-hub-sdk/src/server.rs:681 — TooManyMethods — 32 methods, declared across 4 files: src/server.rs (29), src/log_donate.rs (1), src/metric_donate.rs (1), src/trace_donate.rs (1). The bar is 30 methods; this is 2 over it, 1.07× 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.
D4 · Code Duplication · Duplicated block (23 lines × 2) · ×3
  • Duplicated block (23 lines × 2) crates/codegen/xai-file-utils/src/storage_client.rs:1844 — crates/codegen/xai-file-utils/src/storage_client.rs:1844-1866 | crates/codegen/xai-file-utils/src/storage_client.rs:1921-1943 — both copies are in the same file, so extract the 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 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:184 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:184-206 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:261-283 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 98 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 (23 lines × 2) crates/codegen/xai-grok-shell/src/session/goal_orchestrator.rs:81 — crates/codegen/xai-grok-shell/src/session/goal_orchestrator.rs:81-103 | crates/codegen/xai-grok-shell/src/session/workflow/notify.rs:72-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.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×3
  • Duplicated block (17–19 lines × 2) crates/codegen/xai-grok-pager-render/src/render/osc8.rs:573 — crates/codegen/xai-grok-pager-render/src/render/osc8.rs:573-589 | crates/codegen/xai-grok-pager-render/src/render/osc8.rs:622-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.
  • Duplicated block (17–19 lines × 2) crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:360 — crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:360-378 | crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:398-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.
  • Duplicated block (17–19 lines × 2) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:587 — crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:587-605 | crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:1083-1099 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (18–19 lines × 2) · ×3
  • Duplicated block (18–19 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:991 — crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:991-1009 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1782-1799 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-test-support/src/env.rs:188 — crates/codegen/xai-grok-test-support/src/env.rs:188-206 | crates/codegen/xai-grok-test-support/src/env.rs:301-318 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-test-support/src/sse.rs:598 — crates/codegen/xai-grok-test-support/src/sse.rs:598-615 | crates/codegen/xai-grok-test-support/src/sse.rs:709-727 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×3
  • Duplicated block (15 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1451 — crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1451-1465 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1589-1603 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1324-1338 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 80 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 (15 lines × 3) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:227 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:227-241 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:242-256 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:217-231 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 142 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 (15 lines × 3) crates/codegen/xai-grok-shell/src/agent/config.rs:3783 — crates/codegen/xai-grok-shell/src/agent/config.rs:3783-3797 | crates/codegen/xai-grok-shell/src/agent/config.rs:4541-4555 | crates/codegen/xai-grok-shell/src/agent/config.rs:4775-4789 — 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 · Duplicated block (14–15 lines × 2) · ×3
  • Duplicated block (14–15 lines × 2) crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:326 — crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:326-339 | crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:536-550 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:553 — crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:553-566 | crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:708-722 — both copies are in the same file, so extract the 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) crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:950 — crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:950-964 | crates/codegen/xai-grok-pager/src/views/settings_modal/input.rs:1024-1037 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (13 lines × 4) · ×3
  • Duplicated block (13 lines × 4) crates/codegen/xai-file-utils/src/storage_client.rs:1103 — crates/codegen/xai-file-utils/src/storage_client.rs:1103-1115 | crates/codegen/xai-file-utils/src/storage_client.rs:1214-1226 | crates/codegen/xai-file-utils/src/storage_client.rs:1608-1620 | crates/codegen/xai-file-utils/src/storage_client.rs:1662-1674 — 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) crates/codegen/xai-grok-pager/src/app/effects/mod.rs:1308 — crates/codegen/xai-grok-pager/src/app/effects/mod.rs:1308-1320 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:1360-1372 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:1486-1498 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:1742-1754 — 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) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1218 — crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1218-1230 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1316-1328 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1443-1455 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1529-1541 — 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.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×3
  • Duplicated block (13 lines × 3) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1337 — crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1337-1349 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1464-1476 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:1550-1562 — 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 (13 lines × 3) crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:128 — crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:128-140 | crates/codegen/xai-grok-shell/src/remote/conversations_client.rs:131-143 | crates/codegen/xai-grok-shell/src/remote/workspaces_client.rs:106-118 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs` and `crates/codegen/xai-grok-shell/src/remote/conversations_client.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 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 (13 lines × 3) crates/codegen/xai-grok-pager/src/app/acp_handler/interactions.rs:26 — crates/codegen/xai-grok-pager/src/app/acp_handler/interactions.rs:26-38 | crates/codegen/xai-grok-pager/src/app/acp_handler/interactions.rs:109-125 | crates/codegen/xai-grok-pager/src/app/acp_handler/interactions.rs:236-253 — 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 · Duplicated block (11 lines × 3) · ×3
  • Duplicated block (11 lines × 3) crates/codegen/xai-grok-markdown/src/mermaid.rs:1429 — crates/codegen/xai-grok-markdown/src/mermaid.rs:1429-1439 | crates/codegen/xai-grok-markdown/src/mermaid.rs:1850-1860 | crates/codegen/xai-grok-markdown/src/mermaid.rs:2144-2154 — 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) crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:219 — crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:219-229 | crates/codegen/xai-grok-sampler/src/stream/messages.rs:491-501 | crates/codegen/xai-grok-sampler/src/stream/responses.rs:575-585 — before extracting anything, compare `crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs` and `crates/codegen/xai-grok-sampler/src/stream/messages.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 64 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 (11 lines × 3) crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:328 — crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:328-338 | crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:362-372 | crates/codegen/xai-grok-tools/src/implementations/grok_build/grep/card.rs:407-417 — 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 · Duplicated block (8–10 lines × 2) · ×3
  • Duplicated block (8–10 lines × 2) crates/codegen/xai-grok-pager/src/app/acp_handler/settings.rs:286 — crates/codegen/xai-grok-pager/src/app/acp_handler/settings.rs:286-293 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/setters.rs:549-558 — 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 (8–10 lines × 2) crates/codegen/xai-grok-pager/src/app/app_view.rs:3694 — crates/codegen/xai-grok-pager/src/app/app_view.rs:3694-3703 | crates/codegen/xai-grok-pager/src/app/app_view.rs:3736-3743 — both copies are in the same file, so extract the 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–10 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3620 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3620-3627 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:3713-3722 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (8–9 lines × 3) · ×3
  • Duplicated block (8–9 lines × 3) crates/codegen/xai-file-utils/src/gcs.rs:435 — crates/codegen/xai-file-utils/src/gcs.rs:435-442 | crates/codegen/xai-file-utils/src/gcs.rs:558-565 | crates/codegen/xai-file-utils/src/gcs.rs:585-593 — 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–9 lines × 3) crates/codegen/xai-grok-shell/src/remote/client.rs:483 — crates/codegen/xai-grok-shell/src/remote/client.rs:483-490 | crates/codegen/xai-grok-shell/src/remote/client.rs:507-514 | crates/codegen/xai-grok-shell/src/remote/client.rs:577-585 — 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–9 lines × 3) crates/codegen/xai-grok-test-support/src/env.rs:137 — crates/codegen/xai-grok-test-support/src/env.rs:137-145 | crates/codegen/xai-grok-test-support/src/env.rs:188-196 | crates/codegen/xai-grok-test-support/src/env.rs:301-308 — 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 · Duplicated block (6 lines × 4) · ×3
  • Duplicated block (6 lines × 4) crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:157 — crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:157-162 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:225-230 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:260-265 | crates/codegen/xai-fast-worktree/src/btrfs/detect.rs:311-316 — 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 (6 lines × 4) crates/codegen/xai-grok-pager/src/slash/commands/context.rs:17 — crates/codegen/xai-grok-pager/src/slash/commands/context.rs:17-23 | crates/codegen/xai-grok-pager/src/slash/commands/queue.rs:21-26 | crates/codegen/xai-grok-pager/src/slash/commands/session_info.rs:17-23 | crates/codegen/xai-grok-pager/src/slash/commands/tasks.rs:20-25 — 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.
  • Duplicated block (6 lines × 4) crates/codegen/xai-grok-shell/src/util/config/resolve/auto_mode.rs:82 — crates/codegen/xai-grok-shell/src/util/config/resolve/auto_mode.rs:82-87 | crates/codegen/xai-grok-shell/src/util/config/resolve/prompt_suggest.rs:79-84 | crates/codegen/xai-grok-shell/src/util/config/resolve/session_recap.rs:103-108 | crates/codegen/xai-grok-shell/src/util/config/resolve/turn_summary.rs:90-95 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/util/config/resolve/auto_mode.rs` and `crates/codegen/xai-grok-shell/src/util/config/resolve/prompt_suggest.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 34 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.
D1 · Cyclomatic Complexity · ParsedMarkdown · ×2
  • ParsedMarkdown::render_ratatui (cyclomatic 94) crates/codegen/xai-grok-markdown/src/render.rs:530 — ParsedMarkdown::render_ratatui has cyclomatic complexity 94 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ParsedMarkdown::render_ansi (cyclomatic 45) crates/codegen/xai-grok-markdown/src/render.rs:272 — ParsedMarkdown::render_ansi has cyclomatic complexity 45 (threshold 15). Of this number, 40 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · xai_grok_pager_bin · ×2
  • xai_grok_pager_bin::run_agent_command (cyclomatic 54) crates/codegen/xai-grok-pager-bin/src/main.rs:1227 — xai_grok_pager_bin::run_agent_command 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.
  • xai_grok_pager_bin::async_main (cyclomatic 52) crates/codegen/xai-grok-pager-bin/src/main.rs:2133 — xai_grok_pager_bin::async_main 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.
D1 · Cyclomatic Complexity · ImportClaudeModalState · ×2
  • ImportClaudeModalState::handle_key (cyclomatic 43) crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:369 — ImportClaudeModalState::handle_key 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.
  • ImportClaudeModalState::handle_mouse (cyclomatic 37) crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:196 — ImportClaudeModalState::handle_mouse 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.
D1 · Cyclomatic Complexity · ToolRegistryBuilder · ×2
  • ToolRegistryBuilder::finalize_with_trunc_config (cyclomatic 36) crates/codegen/xai-grok-tools/src/registry/types.rs:1025 — ToolRegistryBuilder::finalize_with_trunc_config 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.
  • ToolRegistryBuilder::validate_config (cyclomatic 21) crates/codegen/xai-grok-tools/src/registry/types.rs:832 — ToolRegistryBuilder::validate_config 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.
D1 · Cyclomatic Complexity · CompiledPolicy · ×2
  • CompiledPolicy::evaluate_shell_file_access_inner (cyclomatic 35) crates/codegen/xai-grok-permission-rules/src/shell_access.rs:40 — CompiledPolicy::evaluate_shell_file_access_inner 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.
  • CompiledPolicy::evaluate_rules_with_base (cyclomatic 20) crates/codegen/xai-grok-permission-rules/src/policy.rs:275 — CompiledPolicy::evaluate_rules_with_base has cyclomatic complexity 20 (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.
D1 · Cyclomatic Complexity · LocalTerminalActor · ×2
  • LocalTerminalActor::poll_process (cyclomatic 33) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1828 — LocalTerminalActor::poll_process 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.
  • LocalTerminalActor::handle_command (cyclomatic 32) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1003 — LocalTerminalActor::handle_command 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.
D1 · Cyclomatic Complexity · xai_grok_pager_diff · ×2
  • xai_grok_pager_diff::build_diff_hunks (cyclomatic 30) crates/codegen/xai-grok-pager-diff/src/lib.rs:27 — xai_grok_pager_diff::build_diff_hunks 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.
  • xai_grok_pager_diff::stitch_hunk_pair (cyclomatic 19) crates/codegen/xai-grok-pager-diff/src/lib.rs:247 — xai_grok_pager_diff::stitch_hunk_pair 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.
D1 · Cyclomatic Complexity · xai_grok_config · ×2
  • xai_grok_config::fs_atomic::resolve_destination (cyclomatic 29) crates/codegen/xai-grok-config/src/fs_atomic.rs:41 — xai_grok_config::fs_atomic::resolve_destination 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.
  • xai_grok_config::managed_text::format::parse_block (cyclomatic 27) crates/codegen/xai-grok-config/src/managed_text/format.rs:266 — xai_grok_config::managed_text::format::parse_block has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · xai_grok_memory · ×2
  • xai_grok_memory::v2::render_manifest_from_source (cyclomatic 28) crates/codegen/xai-grok-memory/src/v2.rs:469 — xai_grok_memory::v2::render_manifest_from_source 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.
  • xai_grok_memory::storage_v2::list_memory_files_with_caps (cyclomatic 20) crates/codegen/xai-grok-memory/src/storage_v2.rs:28 — xai_grok_memory::storage_v2::list_memory_files_with_caps has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · xai_grok_pager_minimal · ×2
  • xai_grok_pager_minimal::live::draw_live (cyclomatic 27) crates/codegen/xai-grok-pager-minimal/src/live.rs:82 — xai_grok_pager_minimal::live::draw_live has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • xai_grok_pager_minimal::panel::render_mcps (cyclomatic 25) crates/codegen/xai-grok-pager-minimal/src/panel.rs:310 — xai_grok_pager_minimal::panel::render_mcps 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.
D1 · Cyclomatic Complexity · BashTool · ×2
  • BashTool::run (cyclomatic 26) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:1868 — BashTool::run 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.
  • BashTool::execute (cyclomatic 20) crates/codegen/xai-grok-tools/src/implementations/grok_build/bash/mod.rs:1725 — BashTool::execute has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HostService · ×2
  • HostService::spawn_agent (cyclomatic 25) crates/codegen/xai-grok-shell/src/session/workflow/host_service.rs:436 — HostService::spawn_agent 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.
  • HostService::dispatch (cyclomatic 23) crates/codegen/xai-grok-shell/src/session/workflow/host_service.rs:210 — HostService::dispatch 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.
D1 · Cyclomatic Complexity · BlockViewerPane · ×2
  • BlockViewerPane::handle_mouse (cyclomatic 24) crates/codegen/xai-grok-pager/src/views/block_viewer/selection.rs:221 — BlockViewerPane::handle_mouse 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.
  • BlockViewerPane::render_text_drag_overlay (cyclomatic 24) crates/codegen/xai-grok-pager/src/views/block_viewer/selection.rs:477 — BlockViewerPane::render_text_drag_overlay 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.
D1 · Cyclomatic Complexity · AuthManager · ×2
  • AuthManager::refresh_chain (cyclomatic 23) crates/codegen/xai-grok-login/src/manager/refresh_chain.rs:59 — AuthManager::refresh_chain 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.
  • AuthManager::apply_refresh_outcome (cyclomatic 17) crates/codegen/xai-grok-login/src/manager.rs:1409 — AuthManager::apply_refresh_outcome 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.
D1 · Cyclomatic Complexity · Renderer · ×2
  • Renderer::draw_walls (cyclomatic 22) crates/codegen/xai-grok-gboom/src/engine.rs:271 — Renderer::draw_walls 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.
  • Renderer::draw_imps (cyclomatic 17) crates/codegen/xai-grok-gboom/src/engine.rs:379 — Renderer::draw_imps 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.
D1 · Cyclomatic Complexity · xai_grok_agent · ×2
  • xai_grok_agent::prompt::agents_md::read_agents_config_with_roots (cyclomatic 21) crates/codegen/xai-grok-agent/src/prompt/agents_md.rs:225 — xai_grok_agent::prompt::agents_md::read_agents_config_with_roots 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.
  • xai_grok_agent::plugins::discovery::discover_plugins (cyclomatic 20) crates/codegen/xai-grok-agent/src/plugins/discovery.rs:256 — xai_grok_agent::plugins::discovery::discover_plugins has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · xai_grok_login · ×2
  • xai_grok_login::flow::run_auth_flow_steps (cyclomatic 21) crates/codegen/xai-grok-login/src/flow.rs:448 — xai_grok_login::flow::run_auth_flow_steps 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.
  • xai_grok_login::oidc::refresh::oidc_token_exchange (cyclomatic 16) crates/codegen/xai-grok-login/src/oidc/refresh.rs:81 — xai_grok_login::oidc::refresh::oidc_token_exchange 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.
D1 · Cyclomatic Complexity · ProfileName · ×2
  • ProfileName::capability_set_from_profile (cyclomatic 21) crates/codegen/xai-grok-sandbox/src/profiles.rs:256 — ProfileName::capability_set_from_profile 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.
  • ProfileName::resolve (cyclomatic 21) crates/codegen/xai-grok-sandbox/src/profiles.rs:402 — ProfileName::resolve 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.
D1 · Cyclomatic Complexity · BatchDreamStore · ×2
  • BatchDreamStore::persist_plan_as (cyclomatic 19) crates/codegen/xai-grok-memory/src/batch_dream_commit.rs:78 — BatchDreamStore::persist_plan_as has cyclomatic complexity 19 (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.
  • BatchDreamStore::apply_planned (cyclomatic 19) crates/codegen/xai-grok-memory/src/batch_dream_commit.rs:222 — BatchDreamStore::apply_planned 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.
D1 · Cyclomatic Complexity · StorageClient · ×2
  • StorageClient::batch_upload (cyclomatic 17) crates/codegen/xai-file-utils/src/storage_client.rs:696 — StorageClient::batch_upload 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.
  • StorageClient::batch_upload_json (cyclomatic 16) crates/codegen/xai-file-utils/src/storage_client.rs:800 — StorageClient::batch_upload_json has cyclomatic complexity 16 (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.
D2 · Cognitive Complexity · EntryRenderer · ×2
  • EntryRenderer::render (cognitive 137) crates/codegen/xai-grok-pager/src/scrollback/wrappers/entry_renderer.rs:561 — EntryRenderer::render has cognitive complexity 137 (threshold 15). Drivers by points: if/else 52 (91 pts), loops 12 (32 pts), boolean chains 13, match/switch 1 (nesting depth added 59). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • EntryRenderer::row_soft_wraps (cognitive 20) crates/codegen/xai-grok-pager/src/scrollback/wrappers/entry_renderer.rs:455 — EntryRenderer::row_soft_wraps 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.
D2 · Cognitive Complexity · ListPane · ×2
  • ListPane::render_items (cognitive 69) crates/codegen/xai-grok-pager/src/views/list_pane/render.rs:214 — ListPane::render_items has cognitive complexity 69 (threshold 15). Drivers by points: if/else 20 (46 pts), boolean chains 9, loops 3 (8 pts), match/switch 2 (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.
  • ListPane::render_item_framework (cognitive 17) crates/codegen/xai-grok-pager/src/views/list_pane/render.rs:154 — ListPane::render_item_framework has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 1 (2 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.
D2 · Cognitive Complexity · xai_grok_pager_diff · ×2
  • xai_grok_pager_diff::build_diff_hunks (cognitive 64) crates/codegen/xai-grok-pager-diff/src/lib.rs:27 — xai_grok_pager_diff::build_diff_hunks has cognitive complexity 64 (threshold 15). Drivers by points: if/else 16 (34 pts), loops 6 (12 pts), match/switch 3 (11 pts), boolean chains 7 (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.
  • xai_grok_pager_diff::stitch_hunk_pair (cognitive 42) crates/codegen/xai-grok-pager-diff/src/lib.rs:247 — xai_grok_pager_diff::stitch_hunk_pair has cognitive complexity 42 (threshold 15). Drivers by points: if/else 10 (31 pts), match/switch 2 (5 pts), loops 2 (4 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.
D2 · Cognitive Complexity · ImportClaudeModalState · ×2
  • ImportClaudeModalState::handle_key (cognitive 55) crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:369 — ImportClaudeModalState::handle_key has cognitive complexity 55 (threshold 15). Drivers by points: if/else 19 (38 pts), loops 3 (7 pts), boolean chains 5, match/switch 4 (5 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.
  • ImportClaudeModalState::handle_mouse (cognitive 53) crates/codegen/xai-grok-pager/src/views/import_claude_modal.rs:196 — ImportClaudeModalState::handle_mouse has cognitive complexity 53 (threshold 15). Drivers by points: if/else 16 (34 pts), boolean chains 8, match/switch 5 (8 pts), loops 1 (3 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.
D2 · Cognitive Complexity · ToolRegistryBuilder · ×2
  • ToolRegistryBuilder::finalize_with_trunc_config (cognitive 53) crates/codegen/xai-grok-tools/src/registry/types.rs:1025 — ToolRegistryBuilder::finalize_with_trunc_config has cognitive complexity 53 (threshold 15). Drivers by points: if/else 26 (37 pts), loops 6 (8 pts), match/switch 3 (6 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.
  • ToolRegistryBuilder::validate_config (cognitive 29) crates/codegen/xai-grok-tools/src/registry/types.rs:832 — ToolRegistryBuilder::validate_config has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 5, loops 3, match/switch 1 (2 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.
D2 · Cognitive Complexity · QueuePane · ×2
  • QueuePane::render (cognitive 51) crates/codegen/xai-grok-pager/src/views/queue_pane.rs:844 — QueuePane::render has cognitive complexity 51 (threshold 15). Drivers by points: if/else 22 (39 pts), boolean chains 11, 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.
  • QueuePane::sync_from_merged (cognitive 16) crates/codegen/xai-grok-pager/src/views/queue_pane.rs:500 — QueuePane::sync_from_merged has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (7 pts), boolean chains 5, loops 2, match/switch 1 (2 pts) (nesting depth added 2). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkflowManager · ×2
  • WorkflowManager::launch (cognitive 48) crates/codegen/xai-grok-shell/src/session/workflow/manager.rs:150 — WorkflowManager::launch has cognitive complexity 48 (threshold 15). Drivers by points: if/else 26 (41 pts), match/switch 3 (4 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.
  • WorkflowManager::cancel_all_and_drain (cognitive 17) crates/codegen/xai-grok-shell/src/session/workflow/manager.rs:751 — WorkflowManager::cancel_all_and_drain has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 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.
D2 · Cognitive Complexity · xai_grok_session_search · ×2
  • xai_grok_session_search::bootstrap::reindex_all (cognitive 45) crates/codegen/xai-grok-session-search/src/bootstrap.rs:441 — xai_grok_session_search::bootstrap::reindex_all has cognitive complexity 45 (threshold 15). Drivers by points: if/else 15 (25 pts), match/switch 6 (15 pts), loops 3, 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.
  • xai_grok_session_search::bootstrap::bootstrap_with_lease_inner (cognitive 18) crates/codegen/xai-grok-session-search/src/bootstrap.rs:173 — xai_grok_session_search::bootstrap::bootstrap_with_lease_inner has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 3, loops 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.
D2 · Cognitive Complexity · EditToolCallBlock · ×2
  • EditToolCallBlock::rendered_output (cognitive 38) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:1215 — EditToolCallBlock::rendered_output has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 3 (8 pts), match/switch 1 (nesting depth added 22). 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.
  • EditToolCallBlock::header_line (cognitive 16) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:914 — EditToolCallBlock::header_line has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 3, match/switch 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · SlashController · ×2
  • SlashController::command_suggestions (cognitive 37) crates/codegen/xai-grok-pager/src/slash/mod.rs:975 — SlashController::command_suggestions has cognitive complexity 37 (threshold 15). Drivers by points: if/else 15 (28 pts), loops 5 (7 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.
  • SlashController::refresh_mid_text_slash_args (cognitive 17) crates/codegen/xai-grok-pager/src/slash/mod.rs:757 — SlashController::refresh_mid_text_slash_args has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 3, match/switch 1 (2 pts), loops 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.
D2 · Cognitive Complexity · ProfileName · ×2
  • ProfileName::resolve (cognitive 37) crates/codegen/xai-grok-sandbox/src/profiles.rs:402 — ProfileName::resolve has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (27 pts), loops 4 (9 pts), match/switch 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.
  • ProfileName::capability_set_from_profile (cognitive 31) crates/codegen/xai-grok-sandbox/src/profiles.rs:256 — ProfileName::capability_set_from_profile has cognitive complexity 31 (threshold 15). Drivers by points: if/else 13 (23 pts), loops 5 (6 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.
D2 · Cognitive Complexity · HostService · ×2
  • HostService::spawn_agent (cognitive 37) crates/codegen/xai-grok-shell/src/session/workflow/host_service.rs:436 — HostService::spawn_agent has cognitive complexity 37 (threshold 15). Drivers by points: if/else 18 (27 pts), match/switch 5 (7 pts), boolean chains 2, 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.
  • HostService::dispatch (cognitive 30) crates/codegen/xai-grok-shell/src/session/workflow/host_service.rs:210 — HostService::dispatch has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 3 (5 pts), boolean chains 1 (nesting depth added 15). 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.
D2 · Cognitive Complexity · xai_chat_state · ×2
  • xai_chat_state::image_budget::evict_images_to_budget (cognitive 34) crates/codegen/xai-chat-state/src/image_budget.rs:234 — xai_chat_state::image_budget::evict_images_to_budget has cognitive complexity 34 (threshold 15). Drivers by points: if/else 7 (22 pts), loops 4 (8 pts), match/switch 2 (4 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.
  • xai_chat_state::actor::request_builder::prune_conversation (cognitive 18) crates/codegen/xai-chat-state/src/actor/request_builder.rs:134 — xai_chat_state::actor::request_builder::prune_conversation 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.
D2 · Cognitive Complexity · xai_tty_utils · ×2
  • xai_tty_utils::our_children_in_group (cognitive 31) crates/codegen/xai-tty-utils/src/lib.rs:914 — xai_tty_utils::our_children_in_group has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 3 (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.
  • xai_tty_utils::reap_group (cognitive 21) crates/codegen/xai-tty-utils/src/lib.rs:814 — xai_tty_utils::reap_group has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (4 pts), match/switch 1 (2 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.
D2 · Cognitive Complexity · ScopeGraph · ×2
  • ScopeGraph::insert_ref (cognitive 30) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:275 — ScopeGraph::insert_ref has cognitive complexity 30 (threshold 15). Drivers by points: loops 5 (12 pts), if/else 4 (10 pts), match/switch 1 (5 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.
  • ScopeGraph::find_tightest_local_scope (cognitive 18) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:178 — ScopeGraph::find_tightest_local_scope has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 2 (3 pts), boolean chains 1, match/switch 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.
D2 · Cognitive Complexity · xai_grok_mcp · ×2
  • xai_grok_mcp::oauth::authenticate_mcp_server_dedup (cognitive 30) crates/codegen/xai-grok-mcp/src/oauth.rs:61 — xai_grok_mcp::oauth::authenticate_mcp_server_dedup has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (27 pts), loops 1 (3 pts) (nesting depth added 18). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • xai_grok_mcp::servers::start_mcp_server (cognitive 23) crates/codegen/xai-grok-mcp/src/servers.rs:4830 — xai_grok_mcp::servers::start_mcp_server has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (15 pts), match/switch 3 (6 pts), boolean chains 2 (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.
D2 · Cognitive Complexity · xai_grok_image · ×2
  • xai_grok_image::jpeg_reaches_eoi (cognitive 27) crates/codegen/xai-grok-image/src/lib.rs:126 — xai_grok_image::jpeg_reaches_eoi has cognitive complexity 27 (threshold 15). Drivers by points: loops 5 (12 pts), if/else 4 (9 pts), match/switch 2 (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.
  • xai_grok_image::png_structurally_valid (cognitive 20) crates/codegen/xai-grok-image/src/lib.rs:201 — xai_grok_image::png_structurally_valid has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (19 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.
D2 · Cognitive Complexity · StorageClient · ×2
  • StorageClient::batch_upload (cognitive 26) crates/codegen/xai-file-utils/src/storage_client.rs:696 — StorageClient::batch_upload has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 3 (8 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.
  • StorageClient::batch_upload_json (cognitive 19) crates/codegen/xai-file-utils/src/storage_client.rs:800 — StorageClient::batch_upload_json has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 4 (7 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.
D2 · Cognitive Complexity · WebSearchToolCallBlock · ×2
  • WebSearchToolCallBlock::output (cognitive 26) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:211 — WebSearchToolCallBlock::output has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 2 (6 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.
  • WebSearchToolCallBlock::header_line (cognitive 17) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:93 — WebSearchToolCallBlock::header_line has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (16 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.
D2 · Cognitive Complexity · WorkflowsViewState · ×2
  • WorkflowsViewState::normalize (cognitive 26) crates/codegen/xai-grok-pager/src/views/workflows.rs:288 — WorkflowsViewState::normalize has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (22 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.
  • WorkflowsViewState::handle_scroll (cognitive 18) crates/codegen/xai-grok-pager/src/views/workflows.rs:396 — WorkflowsViewState::handle_scroll has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (17 pts), 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.
D2 · Cognitive Complexity · CommandRegistry · ×2
  • CommandRegistry::apply_acp_commands (cognitive 25) crates/codegen/xai-grok-pager/src/slash/registry.rs:417 — CommandRegistry::apply_acp_commands has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 3, 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.
  • CommandRegistry::rebuild_triggers (cognitive 18) crates/codegen/xai-grok-pager/src/slash/registry.rs:512 — CommandRegistry::rebuild_triggers has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (14 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.
D2 · Cognitive Complexity · ptyctl_cli · ×2
  • ptyctl_cli::main (cognitive 24) crates/codegen/ptyctl-cli/src/main.rs:12 — ptyctl_cli::main has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 2 (6 pts), match/switch 3 (5 pts) (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.
  • ptyctl_cli::commands::client::screen (cognitive 18) crates/codegen/ptyctl-cli/src/commands/client.rs:46 — ptyctl_cli::commands::client::screen has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 1 (3 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.
D2 · Cognitive Complexity · xai_crash_handler · ×2
  • xai_crash_handler::handler::imp::write_crash_blob (cognitive 24) crates/codegen/xai-crash-handler/src/handler.rs:315 — xai_crash_handler::handler::imp::write_crash_blob has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 2 (6 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.
  • xai_crash_handler::handler::win::crash_handler (cognitive 18) crates/codegen/xai-crash-handler/src/handler.rs:592 — xai_crash_handler::handler::win::crash_handler has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 4, loops 2 (4 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.
D2 · Cognitive Complexity · xai_fsnotify · ×2
  • xai_fsnotify::install::add_subtree_watches (cognitive 21) crates/codegen/xai-fsnotify/src/install.rs:92 — xai_fsnotify::install::add_subtree_watches has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (16 pts), match/switch 1 (3 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.
  • xai_fsnotify::source::event_loop (cognitive 18) crates/codegen/xai-fsnotify/src/source.rs:242 — xai_fsnotify::source::event_loop has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 2 (4 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.
D2 · Cognitive Complexity · SessionRegistry · ×2
  • SessionRegistry::settle_attach (cognitive 20) crates/codegen/xai-grok-shell/src/agent/mvp_agent/session_registry.rs:947 — SessionRegistry::settle_attach has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), match/switch 4 (7 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.
  • SessionRegistry::resolve_identity_stamp (cognitive 17) crates/codegen/xai-grok-shell/src/agent/mvp_agent/session_registry.rs:649 — SessionRegistry::resolve_identity_stamp has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 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.
D2 · Cognitive Complexity · ReadToolCallBlock · ×2
  • ReadToolCallBlock::collapsed_line (cognitive 17) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:147 — ReadToolCallBlock::collapsed_line has cognitive complexity 17 (threshold 15). Drivers by points: if/else 14, match/switch 1 (2 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.
  • ReadToolCallBlock::render_content_lines (cognitive 17) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:250 — ReadToolCallBlock::render_content_lines has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 5 (6 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.
D2 · Cognitive Complexity · SubagentLifecycleState · ×2
  • SubagentLifecycleState::reduce_spawn (cognitive 16) crates/codegen/xai-grok-pager/src/app/subagent/lifecycle.rs:241 — SubagentLifecycleState::reduce_spawn has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 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.
  • SubagentLifecycleState::reduce_finish (cognitive 16) crates/codegen/xai-grok-pager/src/app/subagent/lifecycle.rs:367 — SubagentLifecycleState::reduce_finish has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 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.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D3 · God Classes · ClassTooLong · ×2
  • ClassTooLong: ToolServer crates/common/xai-computer-hub-sdk/src/server.rs:681 — ClassTooLong — 624 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 32 methods, 5 blocks, lines 681-1963. The bar is 400 significant lines; this is 224 over it, 1.56× 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: ToolHarness crates/common/xai-computer-hub-sdk/src/harness.rs:601 — ClassTooLong — 602 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 47 methods, 5 blocks, lines 601-2209. The bar is 400 significant lines; this is 202 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.
D4 · Code Duplication · Duplicated block (35 lines × 2) · ×2
  • Duplicated block (35 lines × 2) crates/codegen/xai-grok-pager-render/src/theme/grokday.rs:54 — crates/codegen/xai-grok-pager-render/src/theme/grokday.rs:54-88 | crates/codegen/xai-grok-pager-render/src/theme/groknight.rs:56-90 — before extracting anything, compare `crates/codegen/xai-grok-pager-render/src/theme/grokday.rs` and `crates/codegen/xai-grok-pager-render/src/theme/groknight.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 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 (35 lines × 2) crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs:56 — crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs:56-90 | crates/codegen/xai-grok-shell/src/test_support/lsp_runtime.rs:38-72 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs` and `crates/codegen/xai-grok-shell/src/test_support/lsp_runtime.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 81 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.
D4 · Code Duplication · Duplicated block (27–33 lines × 2) · ×2
  • Duplicated block (27–33 lines × 2) crates/codegen/xai-crash-handler/src/handler.rs:153 — crates/codegen/xai-crash-handler/src/handler.rs:153-185 | crates/codegen/xai-crash-handler/src/handler.rs:542-568 — both copies are in the same file, so extract the 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 (27–33 lines × 2) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:2158 — crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:2158-2190 | crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:2201-2227 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (27 lines × 2) · ×2
  • Duplicated block (27 lines × 2) crates/codegen/xai-codebase-graph/src/index_manager.rs:1546 — crates/codegen/xai-codebase-graph/src/index_manager.rs:1546-1572 | crates/codegen/xai-codebase-graph/src/navigation.rs:314-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.
  • Duplicated block (27 lines × 2) crates/codegen/xai-grok-sampler/src/stream/messages.rs:127 — crates/codegen/xai-grok-sampler/src/stream/messages.rs:127-153 | crates/codegen/xai-grok-sampler/src/stream/responses.rs:257-283 — before extracting anything, compare `crates/codegen/xai-grok-sampler/src/stream/messages.rs` and `crates/codegen/xai-grok-sampler/src/stream/responses.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 103 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.
D4 · Code Duplication · Duplicated block (24–26 lines × 2) · ×2
  • Duplicated block (24–26 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1176 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1176-1201 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1563-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 (24–26 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2091 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2091-2116 | crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:2299-2322 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (21–22 lines × 2) · ×2
  • Duplicated block (21–22 lines × 2) crates/codegen/xai-grok-gboom/src/assets.rs:83 — crates/codegen/xai-grok-gboom/src/assets.rs:83-104 | crates/codegen/xai-grok-gboom/src/assets.rs:108-128 — both copies are in the same file, so extract the 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 (21–22 lines × 2) crates/codegen/xai-grok-shell-terminal/src/local_terminal.rs:66 — crates/codegen/xai-grok-shell-terminal/src/local_terminal.rs:66-87 | crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:929-949 — 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.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×2
  • Duplicated block (21 lines × 2) crates/codegen/xai-grok-markdown/src/mermaid.rs:992 — crates/codegen/xai-grok-markdown/src/mermaid.rs:992-1012 | crates/codegen/xai-grok-markdown/src/mermaid.rs:1269-1289 — both copies are in the same file, so extract the 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 (21 lines × 2) crates/codegen/xai-grok-pager-render/src/theme/grokday.rs:112 — crates/codegen/xai-grok-pager-render/src/theme/grokday.rs:112-132 | crates/codegen/xai-grok-pager-render/src/theme/groknight.rs:114-134 — before extracting anything, compare `crates/codegen/xai-grok-pager-render/src/theme/grokday.rs` and `crates/codegen/xai-grok-pager-render/src/theme/groknight.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 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.
D4 · Code Duplication · Duplicated block (19 lines × 3) · ×2
  • Duplicated block (19 lines × 3) crates/codegen/xai-codebase-graph/src/index_manager.rs:1391 — crates/codegen/xai-codebase-graph/src/index_manager.rs:1391-1409 | crates/codegen/xai-codebase-graph/src/manager/builder.rs:406-424 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:584-602 — before extracting anything, compare `crates/codegen/xai-codebase-graph/src/manager/builder.rs` and `crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 54 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 (19 lines × 3) crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:275 — crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:275-293 | crates/codegen/xai-grok-sampler/src/stream/messages.rs:551-569 | crates/codegen/xai-grok-sampler/src/stream/responses.rs:715-733 — before extracting anything, compare `crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs` and `crates/codegen/xai-grok-sampler/src/stream/messages.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 64 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.
D4 · Code Duplication · Duplicated block (16–18 lines × 2) · ×2
  • Duplicated block (16–18 lines × 2) crates/codegen/xai-grok-pager/src/app/acp_handler/background.rs:463 — crates/codegen/xai-grok-pager/src/app/acp_handler/background.rs:463-480 | crates/codegen/xai-grok-pager/src/app/acp_handler/background.rs:485-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.
  • Duplicated block (16–18 lines × 2) crates/codegen/xai-grok-pager/src/app/turn_completion.rs:540 — crates/codegen/xai-grok-pager/src/app/turn_completion.rs:540-557 | crates/codegen/xai-grok-pager/src/app/turn_completion.rs:644-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.
D4 · Code Duplication · Duplicated block (15–17 lines × 2) · ×2
  • Duplicated block (15–17 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/layout.rs:377 — crates/codegen/xai-grok-pager/src/views/dashboard/layout.rs:377-393 | crates/codegen/xai-grok-pager/src/views/dashboard/layout.rs:395-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.
  • Duplicated block (15–17 lines × 2) crates/codegen/xai-grok-sampler/src/client.rs:1715 — crates/codegen/xai-grok-sampler/src/client.rs:1715-1731 | crates/codegen/xai-grok-sampler/src/client.rs:1854-1868 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (16 lines × 3) · ×2
  • Duplicated block (16 lines × 3) crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:455 — crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:455-470 | crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:486-501 | crates/codegen/xai-grok-shell/src/extensions/hunk_tracker.rs:516-531 — 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 (16 lines × 3) crates/codegen/xai-grok-test-support/src/sse.rs:432 — crates/codegen/xai-grok-test-support/src/sse.rs:432-447 | crates/codegen/xai-grok-test-support/src/sse.rs:597-612 | crates/codegen/xai-grok-test-support/src/sse.rs:708-724 — 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 · Duplicated block (15–16 lines × 2) · ×2
  • Duplicated block (15–16 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:2824 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:2824-2838 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:2968-2983 — both copies are in the same file, so extract the 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–16 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:154 — crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:154-169 | crates/codegen/xai-grok-pager/src/app/agent_view/selection.rs:205-219 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (14–16 lines × 2) · ×2
  • Duplicated block (14–16 lines × 2) crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:67 — crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:67-82 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:150-163 — both copies are in the same file, so extract the 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–16 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:736 — crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:736-749 | crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs:455-470 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs` as WHOLE FILES: this scan already matched 7 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. 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.
D4 · Code Duplication · Duplicated block (13–15 lines × 2) · ×2
  • Duplicated block (13–15 lines × 2) crates/codegen/xai-grok-otel/src/config.rs:40 — crates/codegen/xai-grok-otel/src/config.rs:40-52 | crates/codegen/xai-grok-telemetry/src/external/providers.rs:140-154 — 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 (13–15 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/state/nav.rs:260 — crates/codegen/xai-grok-pager/src/scrollback/state/nav.rs:260-274 | crates/codegen/xai-grok-pager/src/scrollback/state/nav.rs:300-312 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×2
  • Duplicated block (14 lines × 3) crates/codegen/xai-grok-markdown/src/render.rs:842 — crates/codegen/xai-grok-markdown/src/render.rs:842-855 | crates/codegen/xai-grok-markdown/src/render.rs:915-928 | crates/codegen/xai-grok-markdown/src/render.rs:953-966 — 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 (14 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:92 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:92-105 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:190-203 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:247-260 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 74 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.
D4 · Code Duplication · Duplicated block (10–14 lines × 2) · ×2
  • Duplicated block (10–14 lines × 2) crates/codegen/xai-grok-pager/src/app/acp_handler/interactions.rs:24 — crates/codegen/xai-grok-pager/src/app/acp_handler/interactions.rs:24-33 | crates/codegen/xai-grok-pager/src/app/acp_handler/interactions.rs:107-120 — both copies are in the same file, so extract the 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–14 lines × 2) crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:2218 — crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:2218-2231 | crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs:2516-2525 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (11–13 lines × 2) · ×2
  • Duplicated block (11–13 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:177 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:177-187 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:226-238 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 82 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 (11–13 lines × 2) crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:379 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:379-391 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/cancel.rs:897-907 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×2
  • Duplicated block (9–11 lines × 2) crates/codegen/xai-grok-memory/src/dream_lock.rs:48 — crates/codegen/xai-grok-memory/src/dream_lock.rs:48-58 | crates/codegen/xai-grok-shell-base/src/util/mod.rs:189-197 — 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–11 lines × 2) crates/codegen/xai-grok-pager-render/src/syntax.rs:99 — crates/codegen/xai-grok-pager-render/src/syntax.rs:99-107 | crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:48-58 — 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.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×2
  • Duplicated block (10 lines × 4) crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:455 — crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:455-464 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1285-1294 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1182-1191 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1568-1577 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 80 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 × 4) crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:128 — crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs:128-137 | crates/codegen/xai-grok-shell/src/remote/conversations_client.rs:131-140 | crates/codegen/xai-grok-shell/src/remote/skills_client.rs:402-411 | crates/codegen/xai-grok-shell/src/remote/workspaces_client.rs:106-115 — before extracting anything, compare `crates/codegen/xai-grok-shell/src/remote/chat_models_client.rs` and `crates/codegen/xai-grok-shell/src/remote/conversations_client.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 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.
D4 · Code Duplication · Duplicated block (7–9 lines × 2) · ×2
  • Duplicated block (7–9 lines × 2) crates/codegen/xai-grok-memory/src/archive.rs:17 — crates/codegen/xai-grok-memory/src/archive.rs:17-23 | crates/codegen/xai-grok-memory/src/v2_access.rs:758-766 — 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–9 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:114 — crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:114-122 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:142-148 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (6–8 lines × 2) · ×2
  • Duplicated block (6–8 lines × 2) crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal.rs:583 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal.rs:583-590 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal_support.rs:1572-1577 — 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–8 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs:152 — crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs:152-157 | crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs:160-167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×2
  • Duplicated block (5 lines × 5) crates/codegen/xai-grok-shell/src/remote/client.rs:483 — crates/codegen/xai-grok-shell/src/remote/client.rs:483-488 | crates/codegen/xai-grok-shell/src/remote/client.rs:507-512 | crates/codegen/xai-grok-shell/src/remote/client.rs:520-524 | crates/codegen/xai-grok-shell/src/remote/client.rs:563-567 | crates/codegen/xai-grok-shell/src/remote/client.rs:577-582 — 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.
  • Duplicated block (5 lines × 5) crates/codegen/xai-grok-shell/src/extensions/mod.rs:71 — crates/codegen/xai-grok-shell/src/extensions/mod.rs:71-75 | crates/codegen/xai-grok-shell/src/extensions/subagent_message.rs:92-96 | crates/codegen/xai-grok-shell/src/extensions/task.rs:356-360 | crates/codegen/xai-grok-shell/src/extensions/terminal.rs:136-140 | crates/codegen/xai-grok-shell/src/extensions/worktree.rs:48-52 — 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.
D4 · Code Duplication · Duplicated block (8 lines × 11) · ×2
  • Duplicated block (8 lines × 11) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:846 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:846-853 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:91-98 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs:60-67 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:48-55 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs:93-100 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:116-123 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search.rs:121-128 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:71-78 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:56-63 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:70-77 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:67-74 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 33 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 (8 lines × 11) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:857 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:857-864 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:81-88 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs:72-79 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:57-64 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs:105-112 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:128-135 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search.rs:133-140 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:80-87 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:65-72 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:79-86 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:76-83 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 33 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.
D1 · Cyclomatic Complexity · WorkspaceRpcHandler · ×1
  • WorkspaceRpcHandler::dispatch (cyclomatic 110) crates/codegen/xai-grok-workspace/src/hub_server.rs:392 — WorkspaceRpcHandler::dispatch has cyclomatic complexity 110 (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.
D1 · Cyclomatic Complexity · SessionPersistence · ×1
  • SessionPersistence::run (cyclomatic 97) crates/codegen/xai-grok-shell/src/session/persistence.rs:2082 — SessionPersistence::run has cyclomatic complexity 97 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AgentBuilder · ×1
  • AgentBuilder::build (cyclomatic 93) crates/codegen/xai-grok-agent/src/builder.rs:696 — AgentBuilder::build has cyclomatic complexity 93 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChatStateActor · ×1
  • ChatStateActor::handle_command (cyclomatic 74) crates/codegen/xai-chat-state/src/actor/mod.rs:117 — ChatStateActor::handle_command has cyclomatic complexity 74 (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.
D1 · Cyclomatic Complexity · ToolOutput · ×1
  • ToolOutput::to_prompt_format (cyclomatic 70) crates/codegen/xai-grok-tools/src/types/output.rs:655 — ToolOutput::to_prompt_format has cyclomatic complexity 70 (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.
D1 · Cyclomatic Complexity · SessionSignalsActor · ×1
  • SessionSignalsActor::run (cyclomatic 69) crates/codegen/xai-grok-shell/src/session/signals.rs:1073 — SessionSignalsActor::run 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.
D1 · Cyclomatic Complexity · EntryRenderer · ×1
  • EntryRenderer::render (cyclomatic 68) crates/codegen/xai-grok-pager/src/scrollback/wrappers/entry_renderer.rs:561 — EntryRenderer::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.
D1 · Cyclomatic Complexity · xai_grok_pager_pty_harness · ×1
  • xai_grok_pager_pty_harness::scripted::run_step (cyclomatic 61) crates/codegen/xai-grok-pager-pty-harness/src/scripted.rs:698 — xai_grok_pager_pty_harness::scripted::run_step has cyclomatic complexity 61 (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.
D1 · Cyclomatic Complexity · LatexDelimiterNormalizer · ×1
  • LatexDelimiterNormalizer::process (cyclomatic 57) crates/codegen/xai-grok-markdown/src/latex_delimiters.rs:148 — LatexDelimiterNormalizer::process 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.
D1 · Cyclomatic Complexity · ConfigModelOverride · ×1
  • ConfigModelOverride::apply (cyclomatic 45) crates/codegen/xai-grok-shell/src/agent/config.rs:3520 — ConfigModelOverride::apply has cyclomatic complexity 45 (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.
D1 · Cyclomatic Complexity · ToolServer · ×1
  • ToolServer::run (cyclomatic 42) crates/common/xai-computer-hub-sdk/src/server.rs:1532 — ToolServer::run 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.
D1 · Cyclomatic Complexity · AgentViewLayout · ×1
  • AgentViewLayout::compute (cyclomatic 40) crates/codegen/xai-grok-pager/src/views/agent.rs:178 — AgentViewLayout::compute has cyclomatic complexity 40 (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.
D1 · Cyclomatic Complexity · ptyctl · ×1
  • ptyctl::keys::parse_special (cyclomatic 39) crates/codegen/ptyctl/src/keys.rs:71 — ptyctl::keys::parse_special has cyclomatic complexity 39 (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.
D1 · Cyclomatic Complexity · SessionEvent · ×1
  • SessionEvent::message (cyclomatic 38) crates/codegen/xai-grok-pager/src/scrollback/blocks/session_event.rs:373 — SessionEvent::message has cyclomatic complexity 38 (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.
D1 · Cyclomatic Complexity · MessagesReducer · ×1
  • MessagesReducer::reduce (cyclomatic 36) crates/codegen/xai-grok-pager/src/headless/reducer/messages/mod.rs:495 — MessagesReducer::reduce 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.
D1 · Cyclomatic Complexity · Config · ×1
  • Config::new_from_toml_cfg (cyclomatic 32) crates/codegen/xai-grok-shell/src/agent/config.rs:1403 — Config::new_from_toml_cfg 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.
D1 · Cyclomatic Complexity · WorkflowManager · ×1
  • WorkflowManager::launch (cyclomatic 32) crates/codegen/xai-grok-shell/src/session/workflow/manager.rs:150 — WorkflowManager::launch 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.
D1 · Cyclomatic Complexity · TaskTool · ×1
  • TaskTool::run (cyclomatic 32) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/mod.rs:352 — TaskTool::run 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.
D1 · Cyclomatic Complexity · Osc52Filter · ×1
  • Osc52Filter::feed (cyclomatic 31) crates/codegen/xai-grok-pager/src/wrap_filter.rs:120 — Osc52Filter::feed 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.
D1 · Cyclomatic Complexity · UserPromptBlock · ×1
  • UserPromptBlock::wrap_prompt_lines (cyclomatic 30) crates/codegen/xai-grok-pager/src/scrollback/blocks/user.rs:231 — UserPromptBlock::wrap_prompt_lines 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.
D1 · Cyclomatic Complexity · ListPane · ×1
  • ListPane::render_items (cyclomatic 30) crates/codegen/xai-grok-pager/src/views/list_pane/render.rs:214 — ListPane::render_items 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.
D1 · Cyclomatic Complexity · ReadTool · ×1
  • ReadTool::run (cyclomatic 30) crates/codegen/xai-grok-tools/src/implementations/opencode/read/mod.rs:148 — ReadTool::run 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.
D1 · Cyclomatic Complexity · xai_workflow · ×1
  • xai_workflow::engine::register_host_fns (cyclomatic 30) crates/codegen/xai-workflow/src/engine.rs:490 — xai_workflow::engine::register_host_fns 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.
D1 · Cyclomatic Complexity · xai_grok_external_agent_migration · ×1
  • xai_grok_external_agent_migration::reporting::format_item_summary (cyclomatic 29) crates/codegen/xai-grok-external-agent-migration/src/reporting.rs:31 — xai_grok_external_agent_migration::reporting::format_item_summary has cyclomatic complexity 29 (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.
D1 · Cyclomatic Complexity · QueuePane · ×1
  • QueuePane::render (cyclomatic 29) crates/codegen/xai-grok-pager/src/views/queue_pane.rs:844 — QueuePane::render 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.
D1 · Cyclomatic Complexity · xai_grok_session_search · ×1
  • xai_grok_session_search::bootstrap::reindex_all (cyclomatic 29) crates/codegen/xai-grok-session-search/src/bootstrap.rs:441 — xai_grok_session_search::bootstrap::reindex_all 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.
D1 · Cyclomatic Complexity · Summary · ×1
  • Summary::apply_patch (cyclomatic 29) crates/codegen/xai-grok-shell/src/session/storage/summary_write.rs:113 — Summary::apply_patch 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.
D1 · Cyclomatic Complexity · GrepTool · ×1
  • GrepTool::run (cyclomatic 29) crates/codegen/xai-grok-tools/src/implementations/opencode/grep/mod.rs:144 — GrepTool::run 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.
D1 · Cyclomatic Complexity · xai_grok_markdown_core · ×1
  • xai_grok_markdown_core::analyze (cyclomatic 27) crates/codegen/xai-grok-markdown-core/src/lib.rs:273 — xai_grok_markdown_core::analyze has cyclomatic complexity 27 (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.
D1 · Cyclomatic Complexity · AgentsMdTracker · ×1
  • AgentsMdTracker::check_path (cyclomatic 27) crates/codegen/xai-grok-tools/src/types/agents_md_tracker.rs:127 — AgentsMdTracker::check_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.
D1 · Cyclomatic Complexity · ToolCallBlock · ×1
  • ToolCallBlock::start_timing (cyclomatic 26) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/mod.rs:383 — ToolCallBlock::start_timing 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.
D1 · Cyclomatic Complexity · StreamingLocalTerminalRunner · ×1
  • StreamingLocalTerminalRunner::run_streaming_loop (cyclomatic 26) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:492 — StreamingLocalTerminalRunner::run_streaming_loop 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.
D1 · Cyclomatic Complexity · TasksPane · ×1
  • TasksPane::sync (cyclomatic 25) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:698 — TasksPane::sync 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.
D1 · Cyclomatic Complexity · KeyShortcut · ×1
  • KeyShortcut::display_pretty (cyclomatic 25) crates/codegen/xai-grok-pager-render/src/input/key.rs:140 — KeyShortcut::display_pretty 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.
D1 · Cyclomatic Complexity · AgentRebuildSpec · ×1
  • AgentRebuildSpec::build_agent_inner (cyclomatic 25) crates/codegen/xai-grok-shell/src/session/agent_rebuild.rs:200 — AgentRebuildSpec::build_agent_inner 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.
D1 · Cyclomatic Complexity · ExternalOtelConfig · ×1
  • ExternalOtelConfig::resolve_with (cyclomatic 24) crates/codegen/xai-grok-telemetry/src/external/config.rs:351 — ExternalOtelConfig::resolve_with 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.
D1 · Cyclomatic Complexity · Game · ×1
  • Game::step_imps (cyclomatic 23) crates/codegen/xai-grok-gboom/src/game.rs:527 — Game::step_imps 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.
D1 · Cyclomatic Complexity · BatchDreamSession · ×1
  • BatchDreamSession::resolve (cyclomatic 23) crates/codegen/xai-grok-memory/src/batch_dream_plan.rs:351 — BatchDreamSession::resolve 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.
D1 · Cyclomatic Complexity · V2CaptureStore · ×1
  • V2CaptureStore::adopt_complete_orphans (cyclomatic 23) crates/codegen/xai-grok-memory/src/v2_capture.rs:1188 — V2CaptureStore::adopt_complete_orphans 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.
D1 · Cyclomatic Complexity · TermSink · ×1
  • TermSink::apply_sgr (cyclomatic 23) crates/codegen/xai-grok-pager-render/src/render/terminal_output.rs:154 — TermSink::apply_sgr 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.
D1 · Cyclomatic Complexity · SessionRoutedToolHandler · ×1
  • SessionRoutedToolHandler::handle_call (cyclomatic 23) crates/codegen/xai-grok-workspace/src/hub.rs:454 — SessionRoutedToolHandler::handle_call 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.
D1 · Cyclomatic Complexity · SelectionBox · ×1
  • SelectionBox::render (cyclomatic 21) crates/codegen/xai-grok-pager/src/scrollback/selection.rs:174 — SelectionBox::render 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.
D1 · Cyclomatic Complexity · SlashController · ×1
  • SlashController::command_suggestions (cyclomatic 21) crates/codegen/xai-grok-pager/src/slash/mod.rs:975 — SlashController::command_suggestions 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.
D1 · Cyclomatic Complexity · ScrollConfig · ×1
  • ScrollConfig::from_terminal_context (cyclomatic 21) crates/codegen/xai-grok-pager-render/src/input/mouse.rs:282 — ScrollConfig::from_terminal_context 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.
D1 · Cyclomatic Complexity · xai_file_utils · ×1
  • xai_file_utils::queue::upload_with_retries (cyclomatic 20) crates/codegen/xai-file-utils/src/queue.rs:1875 — xai_file_utils::queue::upload_with_retries has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MemoryBackendImpl · ×1
  • MemoryBackendImpl::search (cyclomatic 20) crates/codegen/xai-grok-memory/src/backend.rs:327 — MemoryBackendImpl::search has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TableGeometry · ×1
  • TableGeometry::detect (cyclomatic 20) crates/codegen/xai-grok-pager/src/scrollback/table_geometry.rs:175 — TableGeometry::detect has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PermissionScript · ×1
  • PermissionScript::analyze (cyclomatic 20) crates/codegen/xai-grok-permission-rules/src/bash_permission_script.rs:46 — PermissionScript::analyze has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · xai_grok_voice · ×1
  • xai_grok_voice::pipeline::start_capture_session (cyclomatic 20) crates/codegen/xai-grok-voice/src/pipeline.rs:317 — xai_grok_voice::pipeline::start_capture_session has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · xai_ratatui_inline · ×1
  • xai_ratatui_inline::segment::split_into_line_segments (cyclomatic 20) crates/codegen/xai-ratatui-inline/src/segment.rs:84 — xai_ratatui_inline::segment::split_into_line_segments has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ptyctl_cli · ×1
  • ptyctl_cli::main (cyclomatic 19) crates/codegen/ptyctl-cli/src/main.rs:12 — ptyctl_cli::main has cyclomatic complexity 19 (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.
D1 · Cyclomatic Complexity · IndexManager · ×1
  • IndexManager::process_command_coalesced (cyclomatic 19) crates/codegen/xai-codebase-graph/src/index_manager.rs:792 — IndexManager::process_command_coalesced 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.
D1 · Cyclomatic Complexity · PluginRegistry · ×1
  • PluginRegistry::from_discovered (cyclomatic 19) crates/codegen/xai-grok-agent/src/plugins/registry.rs:114 — PluginRegistry::from_discovered 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.
D1 · Cyclomatic Complexity · MemoryConfig · ×1
  • MemoryConfig::resolve_settings (cyclomatic 19) crates/codegen/xai-grok-config-types/src/memory.rs:655 — MemoryConfig::resolve_settings 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.
D1 · Cyclomatic Complexity · RenderBlock · ×1
  • RenderBlock::accent_color (cyclomatic 19) crates/codegen/xai-grok-pager/src/scrollback/block.rs:837 — RenderBlock::accent_color 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.
D1 · Cyclomatic Complexity · MarketplaceRelativePath · ×1
  • MarketplaceRelativePath::parse (cyclomatic 19) crates/codegen/xai-grok-plugin-marketplace/src/types.rs:40 — MarketplaceRelativePath::parse 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.
D1 · Cyclomatic Complexity · HashlineEditTool · ×1
  • HashlineEditTool::run (cyclomatic 19) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/mod.rs:298 — HashlineEditTool::run 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.
D1 · Cyclomatic Complexity · TaskCompletionReminder · ×1
  • TaskCompletionReminder::collect_reminders (cyclomatic 19) crates/codegen/xai-grok-tools/src/reminders/task_completion.rs:699 — TaskCompletionReminder::collect_reminders 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.
D1 · Cyclomatic Complexity · xai_codebase_graph · ×1
  • xai_codebase_graph::index_manager::intern_symbols_directly (cyclomatic 18) crates/codegen/xai-codebase-graph/src/index_manager.rs:1380 — xai_codebase_graph::index_manager::intern_symbols_directly 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.
D1 · Cyclomatic Complexity · xai_grok_image · ×1
  • xai_grok_image::jpeg_reaches_eoi (cyclomatic 18) crates/codegen/xai-grok-image/src/lib.rs:126 — xai_grok_image::jpeg_reaches_eoi has cyclomatic complexity 18 (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.
D1 · Cyclomatic Complexity · SamplingClient · ×1
  • SamplingClient::new (cyclomatic 18) crates/codegen/xai-grok-sampler/src/client.rs:510 — SamplingClient::new 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.
D1 · Cyclomatic Complexity · ModelOverrideConfig · ×1
  • ModelOverrideConfig::resolve (cyclomatic 18) crates/codegen/xai-grok-shell/src/config/mod.rs:550 — ModelOverrideConfig::resolve 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.
D1 · Cyclomatic Complexity · ConfigReloader · ×1
  • ConfigReloader::run (cyclomatic 18) crates/codegen/xai-grok-shell/src/config/reloader.rs:97 — ConfigReloader::run has cyclomatic complexity 18 (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.
D1 · Cyclomatic Complexity · xai_grok_compaction · ×1
  • xai_grok_compaction::intra_compaction::fit::fit_turns_for_summarizer (cyclomatic 18) crates/common/xai-grok-compaction/src/intra_compaction/fit.rs:198 — xai_grok_compaction::intra_compaction::fit::fit_turns_for_summarizer 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.
D1 · Cyclomatic Complexity · ScopeGraphIndex · ×1
  • ScopeGraphIndex::read_from (cyclomatic 17) crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:1440 — ScopeGraphIndex::read_from 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.
D1 · Cyclomatic Complexity · McpClient · ×1
  • McpClient::ensure_initialized (cyclomatic 17) crates/codegen/xai-grok-mcp/src/servers.rs:3639 — McpClient::ensure_initialized 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.
D1 · Cyclomatic Complexity · ElicitationViewState · ×1
  • ElicitationViewState::move_focus (cyclomatic 17) crates/codegen/xai-grok-pager/src/views/elicitation_view/state.rs:468 — ElicitationViewState::move_focus 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.
D1 · Cyclomatic Complexity · xai_grok_telemetry · ×1
  • xai_grok_telemetry::external::emit::emit_record (cyclomatic 17) crates/codegen/xai-grok-telemetry/src/external/emit.rs:65 — xai_grok_telemetry::external::emit::emit_record 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.
D1 · Cyclomatic Complexity · AskUserQuestionTool · ×1
  • AskUserQuestionTool::run (cyclomatic 17) crates/codegen/xai-grok-tools/src/implementations/grok_build/ask_user_question/mod.rs:326 — AskUserQuestionTool::run 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.
D1 · Cyclomatic Complexity · PtySession · ×1
  • PtySession::start (cyclomatic 16) crates/codegen/ptyctl/src/session.rs:67 — PtySession::start 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.
D1 · Cyclomatic Complexity · MathBox · ×1
  • MathBox::hcat_rows (cyclomatic 16) crates/codegen/xai-grok-markdown/src/latex/math_box.rs:81 — MathBox::hcat_rows 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.
D1 · Cyclomatic Complexity · xai_grok_mcp · ×1
  • xai_grok_mcp::servers::start_mcp_server (cyclomatic 16) crates/codegen/xai-grok-mcp/src/servers.rs:4830 — xai_grok_mcp::servers::start_mcp_server 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.
D1 · Cyclomatic Complexity · V2ConsolidationStore · ×1
  • V2ConsolidationStore::prepare_changes (cyclomatic 16) crates/codegen/xai-grok-memory/src/v2_consolidation.rs:1318 — V2ConsolidationStore::prepare_changes 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.
D1 · Cyclomatic Complexity · XtversionFilter · ×1
  • XtversionFilter::advance (cyclomatic 16) crates/codegen/xai-grok-pager/src/app/xt_filter.rs:176 — XtversionFilter::advance has cyclomatic complexity 16 (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.
D1 · Cyclomatic Complexity · WorkflowsViewState · ×1
  • WorkflowsViewState::normalize (cyclomatic 16) crates/codegen/xai-grok-pager/src/views/workflows.rs:288 — WorkflowsViewState::normalize 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.
D1 · Cyclomatic Complexity · RawAppearanceConfig · ×1
  • RawAppearanceConfig::to_toml_with_comments (cyclomatic 16) crates/codegen/xai-grok-pager-render/src/appearance/config.rs:1631 — RawAppearanceConfig::to_toml_with_comments 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: xai_grok_pager_render::appearance::config::lookup_named_color (cyclomatic 39) 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.
D1 · Cyclomatic Complexity · xai_grok_plugin_marketplace · ×1
  • xai_grok_plugin_marketplace::installer::update_from_marketplace_entry_transactional (cyclomatic 16) crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:185 — xai_grok_plugin_marketplace::installer::update_from_marketplace_entry_transactional 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.
D1 · Cyclomatic Complexity · SandboxPolicy · ×1
  • SandboxPolicy::apply_grant_under (cyclomatic 16) crates/codegen/xai-grok-sandbox/src/command/policy/apply.rs:58 — SandboxPolicy::apply_grant_under 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.
D1 · Cyclomatic Complexity · xai_grok_shell_terminal · ×1
  • xai_grok_shell_terminal::pty_session::run_pty_output_loop (cyclomatic 16) crates/codegen/xai-grok-shell-terminal/src/pty_session.rs:395 — xai_grok_shell_terminal::pty_session::run_pty_output_loop 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.
D1 · Cyclomatic Complexity · VideoGenClient · ×1
  • VideoGenClient::generate_with_images (cyclomatic 16) crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:313 — VideoGenClient::generate_with_images 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.
D1 · Cyclomatic Complexity · GlobTool · ×1
  • GlobTool::run (cyclomatic 16) crates/codegen/xai-grok-tools/src/implementations/opencode/glob/mod.rs:149 — GlobTool::run 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.
D1 · Cyclomatic Complexity · HubConnection · ×1
  • HubConnection::connect (cyclomatic 16) crates/common/xai-computer-hub-sdk/src/connection.rs:733 — HubConnection::connect has cyclomatic complexity 16 (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.
D1 · Cyclomatic Complexity · ToolHarness · ×1
  • ToolHarness::start_tool_discovery (cyclomatic 16) crates/common/xai-computer-hub-sdk/src/harness.rs:1830 — ToolHarness::start_tool_discovery 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.
D2 · Cognitive Complexity · LatexDelimiterNormalizer · ×1
  • LatexDelimiterNormalizer::process (cognitive 160) crates/codegen/xai-grok-markdown/src/latex_delimiters.rs:148 — LatexDelimiterNormalizer::process has cognitive complexity 160 (threshold 15). Drivers by points: if/else 26 (107 pts), match/switch 9 (36 pts), loops 4 (11 pts), boolean chains 6 (nesting depth added 115). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SessionPersistence · ×1
  • SessionPersistence::run (cognitive 147) crates/codegen/xai-grok-shell/src/session/persistence.rs:2082 — SessionPersistence::run has cognitive complexity 147 (threshold 15). Drivers by points: if/else 40 (117 pts), match/switch 9 (28 pts), boolean chains 1, loops 1 (nesting depth added 96). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgentBuilder · ×1
  • AgentBuilder::build (cognitive 132) crates/codegen/xai-grok-agent/src/builder.rs:696 — AgentBuilder::build has cognitive complexity 132 (threshold 15). Drivers by points: if/else 75 (101 pts), boolean chains 23, loops 4 (8 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.
D2 · Cognitive Complexity · SessionSignalsActor · ×1
  • SessionSignalsActor::run (cognitive 91) crates/codegen/xai-grok-shell/src/session/signals.rs:1073 — SessionSignalsActor::run has cognitive complexity 91 (threshold 15). Drivers by points: if/else 22 (66 pts), match/switch 4 (12 pts), loops 4 (11 pts), boolean chains 2 (nesting depth added 59). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolServer · ×1
  • ToolServer::run (cognitive 88) crates/common/xai-computer-hub-sdk/src/server.rs:1532 — ToolServer::run has cognitive complexity 88 (threshold 15). Drivers by points: if/else 20 (55 pts), match/switch 6 (17 pts), loops 7 (11 pts), boolean chains 5 (nesting depth added 50). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolOutput · ×1
  • ToolOutput::to_prompt_format (cognitive 77) crates/codegen/xai-grok-tools/src/types/output.rs:655 — ToolOutput::to_prompt_format has cognitive complexity 77 (threshold 15). Drivers by points: if/else 23 (48 pts), match/switch 13 (26 pts), loops 1 (3 pts) (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.
D2 · Cognitive Complexity · UserPromptBlock · ×1
  • UserPromptBlock::wrap_prompt_lines (cognitive 70) crates/codegen/xai-grok-pager/src/scrollback/blocks/user.rs:231 — UserPromptBlock::wrap_prompt_lines has cognitive complexity 70 (threshold 15). Drivers by points: if/else 28 (59 pts), boolean chains 7, loops 2 (3 pts), match/switch 1 (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.
D2 · Cognitive Complexity · AgentsMdTracker · ×1
  • AgentsMdTracker::check_path (cognitive 67) crates/codegen/xai-grok-tools/src/types/agents_md_tracker.rs:127 — AgentsMdTracker::check_path has cognitive complexity 67 (threshold 15). Drivers by points: if/else 14 (42 pts), loops 5 (15 pts), match/switch 4 (8 pts), boolean chains 2 (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.
D2 · Cognitive Complexity · Osc52Filter · ×1
  • Osc52Filter::feed (cognitive 61) crates/codegen/xai-grok-pager/src/wrap_filter.rs:120 — Osc52Filter::feed has cognitive complexity 61 (threshold 15). Drivers by points: if/else 17 (44 pts), match/switch 5 (15 pts), boolean chains 1, loops 1 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgentViewLayout · ×1
  • AgentViewLayout::compute (cognitive 59) crates/codegen/xai-grok-pager/src/views/agent.rs:178 — AgentViewLayout::compute has cognitive complexity 59 (threshold 15). Drivers by points: if/else 56, boolean chains 2, match/switch 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.
D2 · Cognitive Complexity · StreamingLocalTerminalRunner · ×1
  • StreamingLocalTerminalRunner::run_streaming_loop (cognitive 56) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:492 — StreamingLocalTerminalRunner::run_streaming_loop has cognitive complexity 56 (threshold 15). Drivers by points: if/else 12 (37 pts), match/switch 7 (15 pts), boolean chains 3, 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.
D2 · Cognitive Complexity · TaskTool · ×1
  • TaskTool::run (cognitive 56) crates/codegen/xai-grok-tools/src/implementations/grok_build/task/mod.rs:352 — TaskTool::run has cognitive complexity 56 (threshold 15). Drivers by points: if/else 31 (46 pts), boolean chains 5, match/switch 2 (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.
D2 · Cognitive Complexity · Game · ×1
  • Game::step_imps (cognitive 51) crates/codegen/xai-grok-gboom/src/game.rs:527 — Game::step_imps has cognitive complexity 51 (threshold 15). Drivers by points: if/else 18 (47 pts), match/switch 1 (2 pts), boolean chains 1, 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.
D2 · Cognitive Complexity · MessagesReducer · ×1
  • MessagesReducer::reduce (cognitive 49) crates/codegen/xai-grok-pager/src/headless/reducer/messages/mod.rs:495 — MessagesReducer::reduce has cognitive complexity 49 (threshold 15). Drivers by points: if/else 20 (43 pts), boolean chains 5, 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.
D2 · Cognitive Complexity · V2CaptureStore · ×1
  • V2CaptureStore::adopt_complete_orphans (cognitive 47) crates/codegen/xai-grok-memory/src/v2_capture.rs:1188 — V2CaptureStore::adopt_complete_orphans has cognitive complexity 47 (threshold 15). Drivers by points: if/else 10 (25 pts), match/switch 3 (9 pts), loops 4 (8 pts), boolean chains 5 (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.
D2 · Cognitive Complexity · ConfigModelOverride · ×1
  • ConfigModelOverride::apply (cognitive 45) crates/codegen/xai-grok-shell/src/agent/config.rs:3520 — ConfigModelOverride::apply has cognitive complexity 45 (threshold 15). Drivers by points: if/else 40 (41 pts), boolean chains 3, match/switch 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · GrepTool · ×1
  • GrepTool::run (cognitive 45) crates/codegen/xai-grok-tools/src/implementations/opencode/grep/mod.rs:144 — GrepTool::run has cognitive complexity 45 (threshold 15). Drivers by points: if/else 21 (28 pts), match/switch 5 (8 pts), loops 3 (5 pts), boolean chains 4 (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.
D2 · Cognitive Complexity · xai_workflow · ×1
  • xai_workflow::engine::register_host_fns (cognitive 45) crates/codegen/xai-workflow/src/engine.rs:490 — xai_workflow::engine::register_host_fns has cognitive complexity 45 (threshold 15). Drivers by points: if/else 12 (25 pts), match/switch 6 (12 pts), loops 6 (7 pts), 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.
D2 · Cognitive Complexity · ReadTool · ×1
  • ReadTool::run (cognitive 41) crates/codegen/xai-grok-tools/src/implementations/opencode/read/mod.rs:148 — ReadTool::run has cognitive complexity 41 (threshold 15). Drivers by points: if/else 23 (29 pts), boolean chains 5, loops 3 (5 pts), match/switch 2 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · MemoryBackendImpl · ×1
  • MemoryBackendImpl::search (cognitive 40) crates/codegen/xai-grok-memory/src/backend.rs:327 — MemoryBackendImpl::search has cognitive complexity 40 (threshold 15). Drivers by points: if/else 13 (23 pts), loops 5 (11 pts), match/switch 2 (4 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Config · ×1
  • Config::new_from_toml_cfg (cognitive 40) crates/codegen/xai-grok-shell/src/agent/config.rs:1403 — Config::new_from_toml_cfg has cognitive complexity 40 (threshold 15). Drivers by points: if/else 17 (27 pts), loops 7, boolean chains 5, match/switch 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.
D2 · Cognitive Complexity · xai_grok_pager_pty_harness · ×1
  • xai_grok_pager_pty_harness::scripted::run_step (cognitive 37) crates/codegen/xai-grok-pager-pty-harness/src/scripted.rs:698 — xai_grok_pager_pty_harness::scripted::run_step has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (29 pts), loops 3 (6 pts), boolean chains 1, match/switch 1 (nesting depth added 18). 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.
D2 · Cognitive Complexity · Summary · ×1
  • Summary::apply_patch (cognitive 37) crates/codegen/xai-grok-shell/src/session/storage/summary_write.rs:113 — Summary::apply_patch has cognitive complexity 37 (threshold 15). Drivers by points: if/else 26 (35 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.
D2 · Cognitive Complexity · OtherToolCallBlock · ×1
  • OtherToolCallBlock::output (cognitive 35) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs:167 — OtherToolCallBlock::output has cognitive complexity 35 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 3 (11 pts), 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.
D2 · Cognitive Complexity · PermissionScript · ×1
  • PermissionScript::analyze (cognitive 35) crates/codegen/xai-grok-permission-rules/src/bash_permission_script.rs:46 — PermissionScript::analyze has cognitive complexity 35 (threshold 15). Drivers by points: if/else 7 (22 pts), match/switch 2 (5 pts), boolean chains 4, loops 3 (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.
D2 · Cognitive Complexity · TaskCompletionReminder · ×1
  • TaskCompletionReminder::collect_reminders (cognitive 35) crates/codegen/xai-grok-tools/src/reminders/task_completion.rs:699 — TaskCompletionReminder::collect_reminders has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 3 (8 pts), boolean chains 5 (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.
D2 · Cognitive Complexity · GlobTool · ×1
  • GlobTool::run (cognitive 34) crates/codegen/xai-grok-tools/src/implementations/opencode/glob/mod.rs:149 — GlobTool::run has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (26 pts), match/switch 2 (4 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.
D2 · Cognitive Complexity · SelectionBox · ×1
  • SelectionBox::render (cognitive 33) crates/codegen/xai-grok-pager/src/scrollback/selection.rs:174 — SelectionBox::render has cognitive complexity 33 (threshold 15). Drivers by points: if/else 16 (27 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.
D2 · Cognitive Complexity · ConfigReloader · ×1
  • ConfigReloader::run (cognitive 32) crates/codegen/xai-grok-shell/src/config/reloader.rs:97 — ConfigReloader::run has cognitive complexity 32 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 5 (12 pts), loops 3 (5 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.
D2 · Cognitive Complexity · HashlineEditTool · ×1
  • HashlineEditTool::run (cognitive 31) crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/edit/mod.rs:298 — HashlineEditTool::run has cognitive complexity 31 (threshold 15). Drivers by points: match/switch 8 (16 pts), if/else 6 (12 pts), boolean chains 3 (nesting depth added 14). 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.
D2 · Cognitive Complexity · CsiFragmentFilter · ×1
  • CsiFragmentFilter::filter (cognitive 29) crates/codegen/xai-grok-pager/src/app/csi_filter.rs:28 — CsiFragmentFilter::filter has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (19 pts), match/switch 3 (9 pts), 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.
D2 · Cognitive Complexity · ElicitationViewState · ×1
  • ElicitationViewState::move_focus (cognitive 29) crates/codegen/xai-grok-pager/src/views/elicitation_view/state.rs:468 — ElicitationViewState::move_focus has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 14). 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.
D2 · Cognitive Complexity · PtySession · ×1
  • PtySession::start (cognitive 27) crates/codegen/ptyctl/src/session.rs:67 — PtySession::start has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (19 pts), loops 4, match/switch 2 (4 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.
D2 · Cognitive Complexity · ToolCallBlock · ×1
  • ToolCallBlock::start_timing (cognitive 27) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/mod.rs:383 — ToolCallBlock::start_timing has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (26 pts), match/switch 1 (nesting depth added 13). 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.
D2 · Cognitive Complexity · TableGeometry · ×1
  • TableGeometry::detect (cognitive 27) crates/codegen/xai-grok-pager/src/scrollback/table_geometry.rs:175 — TableGeometry::detect has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 3 (6 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.
D2 · Cognitive Complexity · WorkspaceRpcHandler · ×1
  • WorkspaceRpcHandler::dispatch (cognitive 27) crates/codegen/xai-grok-workspace/src/hub_server.rs:392 — WorkspaceRpcHandler::dispatch has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 5 (11 pts), 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.
D2 · Cognitive Complexity · xai_grok_gboom · ×1
  • xai_grok_gboom::engine::draw_text (cognitive 26) crates/codegen/xai-grok-gboom/src/engine.rs:668 — xai_grok_gboom::engine::draw_text has cognitive complexity 26 (threshold 15). Drivers by points: loops 5 (15 pts), if/else 2 (10 pts), boolean chains 1 (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.
D2 · Cognitive Complexity · ApiEmbeddingProvider · ×1
  • ApiEmbeddingProvider::embed_batch (cognitive 26) crates/codegen/xai-grok-memory/src/embedding.rs:97 — ApiEmbeddingProvider::embed_batch has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (7 pts), match/switch 2 (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.
D2 · Cognitive Complexity · QueuedPromptEntry · ×1
  • QueuedPromptEntry::build_styled (cognitive 26) crates/codegen/xai-grok-pager/src/views/queue_pane.rs:187 — QueuedPromptEntry::build_styled has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (24 pts), boolean chains 1, match/switch 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.
D2 · Cognitive Complexity · SnapshotRefresher · ×1
  • SnapshotRefresher::refresh (cognitive 26) crates/codegen/xai-grok-shell/src/session/acp_session_impl/mcp_snapshot.rs:139 — SnapshotRefresher::refresh has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 2 (4 pts), match/switch 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.
D2 · Cognitive Complexity · AgentRebuildSpec · ×1
  • AgentRebuildSpec::build_agent_inner (cognitive 26) crates/codegen/xai-grok-shell/src/session/agent_rebuild.rs:200 — AgentRebuildSpec::build_agent_inner has cognitive complexity 26 (threshold 15). Drivers by points: if/else 18 (20 pts), boolean chains 6 (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.
D2 · Cognitive Complexity · SessionRoutedToolHandler · ×1
  • SessionRoutedToolHandler::handle_call (cognitive 26) crates/codegen/xai-grok-workspace/src/hub.rs:454 — SessionRoutedToolHandler::handle_call has cognitive complexity 26 (threshold 15). Drivers by points: match/switch 9 (11 pts), if/else 8 (10 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.
D2 · Cognitive Complexity · EnvVarRefIter · ×1
  • EnvVarRefIter::next (cognitive 25) crates/codegen/xai-grok-hooks/src/env_expand.rs:158 — EnvVarRefIter::next has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 4 (10 pts), boolean chains 4 (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.
D2 · Cognitive Complexity · MathBox · ×1
  • MathBox::hcat_rows (cognitive 25) crates/codegen/xai-grok-markdown/src/latex/math_box.rs:81 — MathBox::hcat_rows has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 4 (7 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.
D2 · Cognitive Complexity · ToolUsageStats · ×1
  • ToolUsageStats::from_range (cognitive 25) crates/codegen/xai-grok-pager/src/tool_usage.rs:257 — ToolUsageStats::from_range has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (22 pts), match/switch 1 (2 pts), 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.
D2 · Cognitive Complexity · LockInner · ×1
  • LockInner::process_queue (cognitive 25) crates/codegen/xai-grok-tools/src/implementations/editor_infra/file_operation_lock.rs:158 — LockInner::process_queue has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (20 pts), boolean chains 2, 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.
D2 · Cognitive Complexity · HubConnection · ×1
  • HubConnection::connect (cognitive 25) crates/common/xai-computer-hub-sdk/src/connection.rs:733 — HubConnection::connect has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 6 (11 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.
D2 · Cognitive Complexity · ToolHarness · ×1
  • ToolHarness::start_tool_discovery (cognitive 25) crates/common/xai-computer-hub-sdk/src/harness.rs:1830 — ToolHarness::start_tool_discovery has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 3 (8 pts), boolean chains 2, 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.
D2 · Cognitive Complexity · QuoteAwareBreakPoints · ×1
  • QuoteAwareBreakPoints::next (cognitive 24) crates/codegen/xai-grok-pager/src/views/permission_view.rs:1131 — QuoteAwareBreakPoints::next has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (4 pts), boolean chains 2, match/switch 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.
D2 · Cognitive Complexity · ShortcutsBar · ×1
  • ShortcutsBar::render (cognitive 24) crates/codegen/xai-grok-pager/src/views/shortcuts_bar.rs:197 — ShortcutsBar::render has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 2, 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.
D2 · Cognitive Complexity · ProductSkillsCatalog · ×1
  • ProductSkillsCatalog::to_skill_infos (cognitive 24) crates/codegen/xai-grok-shell/src/remote/skills_client.rs:102 — ProductSkillsCatalog::to_skill_infos has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (21 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.
D2 · Cognitive Complexity · ExternalOtelConfig · ×1
  • ExternalOtelConfig::resolve_with (cognitive 24) crates/codegen/xai-grok-telemetry/src/external/config.rs:351 — ExternalOtelConfig::resolve_with has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 11 (14 pts), if/else 5 (7 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 6). 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.
D2 · Cognitive Complexity · xai_compaction_transcript · ×1
  • xai_compaction_transcript::compute_turn_stats (cognitive 23) crates/codegen/xai-compaction-transcript/src/lib.rs:200 — xai_compaction_transcript::compute_turn_stats has cognitive complexity 23 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 3 (8 pts), boolean chains 2, match/switch 1 (2 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.
D2 · Cognitive Complexity · GitignoreCache · ×1
  • GitignoreCache::is_ignored (cognitive 23) crates/codegen/xai-fsnotify/src/vcs.rs:56 — GitignoreCache::is_ignored has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (18 pts), boolean chains 4, 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.
D2 · Cognitive Complexity · PluginRegistry · ×1
  • PluginRegistry::from_discovered (cognitive 23) crates/codegen/xai-grok-agent/src/plugins/registry.rs:114 — PluginRegistry::from_discovered has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 12, if/else 4 (7 pts), loops 2 (4 pts) (nesting depth added 5). 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.
D2 · Cognitive Complexity · SessionEvent · ×1
  • SessionEvent::message (cognitive 23) crates/codegen/xai-grok-pager/src/scrollback/blocks/session_event.rs:373 — SessionEvent::message has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 3 (5 pts) (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.
D2 · Cognitive Complexity · QuestionViewState · ×1
  • QuestionViewState::build_accepted_response (cognitive 23) crates/codegen/xai-grok-pager/src/views/question_view.rs:790 — QuestionViewState::build_accepted_response has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 4, match/switch 1 (3 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.
D2 · Cognitive Complexity · DomainMatcher · ×1
  • DomainMatcher::new (cognitive 23) crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/domain.rs:46 — DomainMatcher::new has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 3 (7 pts), boolean chains 2, 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.
D2 · Cognitive Complexity · xai_tool_runtime · ×1
  • xai_tool_runtime::render::extract_content_blocks (cognitive 23) crates/common/xai-tool-runtime/src/render.rs:203 — xai_tool_runtime::render::extract_content_blocks has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 2 (6 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.
D2 · Cognitive Complexity · postinstall.installBinary (cognitive 23) · ×1
  • postinstall.installBinary (cognitive 23) crates/codegen/xai-grok-pager/npm/grok/bin/postinstall.js:88 — postinstall.installBinary has cognitive complexity 23 (threshold 15). Drivers by points: error handling 7 (18 pts), if/else 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.
D2 · Cognitive Complexity · SentMessageToolCallBlock · ×1
  • SentMessageToolCallBlock::output (cognitive 22) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/sent_message.rs:342 — SentMessageToolCallBlock::output has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (6 pts), match/switch 2 (3 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.
D2 · Cognitive Complexity · WebFetchToolCallBlock · ×1
  • WebFetchToolCallBlock::output (cognitive 22) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:181 — WebFetchToolCallBlock::output has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 1 (3 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.
D2 · Cognitive Complexity · Theme · ×1
  • Theme::ansi16_chrome_overrides (cognitive 22) crates/codegen/xai-grok-pager-render/src/theme/mod.rs:429 — Theme::ansi16_chrome_overrides 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.
D2 · Cognitive Complexity · Journal · ×1
  • Journal::load (cognitive 22) crates/codegen/xai-workflow/src/journal.rs:64 — Journal::load has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (17 pts), match/switch 2 (4 pts), 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.
D2 · Cognitive Complexity · FuzzyFileMatcher · ×1
  • FuzzyFileMatcher::get_top_k (cognitive 21) crates/codegen/xai-fuzzy-file-search/src/lib.rs:455 — FuzzyFileMatcher::get_top_k has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 7). Of this number, 16 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RegistrationStore · ×1
  • RegistrationStore::load_sync (cognitive 21) crates/codegen/xai-grok-lifecycle/src/persist.rs:81 — RegistrationStore::load_sync has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (11 pts), match/switch 4 (8 pts), 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.
D2 · Cognitive Complexity · ModalInput · ×1
  • ModalInput::handle_key (cognitive 21) crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:796 — ModalInput::handle_key has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 1, 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.
D2 · Cognitive Complexity · ScrollConfig · ×1
  • ScrollConfig::from_terminal_context (cognitive 21) crates/codegen/xai-grok-pager-render/src/input/mouse.rs:282 — ScrollConfig::from_terminal_context has cognitive complexity 21 (threshold 15). Drivers by points: if/else 16, match/switch 2 (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.
D2 · Cognitive Complexity · SandboxPolicy · ×1
  • SandboxPolicy::apply_grant_under (cognitive 21) crates/codegen/xai-grok-sandbox/src/command/policy/apply.rs:58 — SandboxPolicy::apply_grant_under has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (2 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.
D2 · Cognitive Complexity · EffectiveAllowlist · ×1
  • EffectiveAllowlist::apply_selectability (cognitive 21) crates/codegen/xai-grok-shell/src/agent/remote_config/resolution.rs:299 — EffectiveAllowlist::apply_selectability has cognitive complexity 21 (threshold 15). Drivers by points: loops 5 (13 pts), if/else 2 (5 pts), match/switch 2 (3 pts) (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.
D2 · Cognitive Complexity · ApplyPatchTool · ×1
  • ApplyPatchTool::run (cognitive 21) crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/tool.rs:370 — ApplyPatchTool::run has cognitive complexity 21 (threshold 15). Drivers by points: match/switch 6 (12 pts), if/else 4 (8 pts), loops 1 (nesting depth added 10). 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.
D2 · Cognitive Complexity · SuppressionTracker · ×1
  • SuppressionTracker::process (cognitive 21) crates/codegen/xai-grok-tools/src/implementations/grok_build/monitor/rate_limiter.rs:76 — SuppressionTracker::process has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (20 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.
D2 · Cognitive Complexity · xai_grok_bundle · ×1
  • xai_grok_bundle::extract_bundle_archive (cognitive 20) crates/codegen/xai-grok-bundle/src/lib.rs:177 — xai_grok_bundle::extract_bundle_archive has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 2 (4 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.
D2 · Cognitive Complexity · RenderBlock · ×1
  • RenderBlock::accent_color (cognitive 20) crates/codegen/xai-grok-pager/src/scrollback/block.rs:837 — RenderBlock::accent_color has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 3 (6 pts) (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.
D2 · Cognitive Complexity · ContextInfoBlock · ×1
  • ContextInfoBlock::build_lines (cognitive 20) crates/codegen/xai-grok-pager/src/scrollback/blocks/context_info.rs:219 — ContextInfoBlock::build_lines has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 8 (9 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.
D2 · Cognitive Complexity · MemorySearchToolCallBlock · ×1
  • MemorySearchToolCallBlock::output (cognitive 20) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:135 — MemorySearchToolCallBlock::output has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 2 (5 pts), boolean chains 1, 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.
D2 · Cognitive Complexity · UseToolCallBlock · ×1
  • UseToolCallBlock::output (cognitive 20) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:145 — UseToolCallBlock::output has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (6 pts), 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.
D2 · Cognitive Complexity · SlashMru · ×1
  • SlashMru::ensure_loaded (cognitive 20) crates/codegen/xai-grok-pager/src/slash/mru.rs:106 — SlashMru::ensure_loaded has cognitive complexity 20 (threshold 15). Drivers by points: loops 2 (9 pts), if/else 3 (6 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · SourceLine · ×1
  • SourceLine::render (cognitive 20) crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:214 — SourceLine::render has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (16 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.
D2 · Cognitive Complexity · VideoGenClient · ×1
  • VideoGenClient::generate_with_images (cognitive 20) crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:313 — VideoGenClient::generate_with_images has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 3 (6 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.
D2 · Cognitive Complexity · ResourcesPersistence · ×1
  • ResourcesPersistence::writer_loop (cognitive 20) crates/codegen/xai-grok-tools/src/persistence.rs:217 — ResourcesPersistence::writer_loop has cognitive complexity 20 (threshold 15). Drivers by points: if/else 3 (11 pts), match/switch 2 (5 pts), boolean chains 3, 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.
D2 · Cognitive Complexity · WorkspaceBindConfig · ×1
  • WorkspaceBindConfig::resolve (cognitive 20) crates/codegen/xai-grok-workspace/src/config.rs:175 — WorkspaceBindConfig::resolve has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 2 (4 pts), match/switch 1 (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.
D2 · Cognitive Complexity · xai_grok_workspace_types · ×1
  • xai_grok_workspace_types::rewrite_grok_files_mount_dest (cognitive 20) crates/codegen/xai-grok-workspace-types/src/lib.rs:111 — xai_grok_workspace_types::rewrite_grok_files_mount_dest has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (17 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.
D2 · Cognitive Complexity · MemoryStorage · ×1
  • MemoryStorage::gc (cognitive 19) crates/codegen/xai-grok-memory/src/storage.rs:563 — MemoryStorage::gc has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (6 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.
D2 · Cognitive Complexity · RawAppearanceConfig · ×1
  • RawAppearanceConfig::to_toml_with_comments (cognitive 19) crates/codegen/xai-grok-pager-render/src/appearance/config.rs:1631 — RawAppearanceConfig::to_toml_with_comments has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15 (19 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.
D2 · Cognitive Complexity · ModelOverrideConfig · ×1
  • ModelOverrideConfig::resolve (cognitive 19) crates/codegen/xai-grok-shell/src/config/mod.rs:550 — ModelOverrideConfig::resolve has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14 (16 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.
D2 · Cognitive Complexity · DoomLoopTurnTally · ×1
  • DoomLoopTurnTally::detection_summary (cognitive 19) crates/codegen/xai-grok-shell/src/session/doom_loop_telemetry.rs:138 — DoomLoopTurnTally::detection_summary has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 2 (4 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.
D2 · Cognitive Complexity · PullDiagnostics · ×1
  • PullDiagnostics::resolve (cognitive 19) crates/codegen/xai-grok-tools/src/implementations/lsp/pull.rs:225 — PullDiagnostics::resolve has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 2, 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.
D2 · Cognitive Complexity · SkillDiscoveryReminder · ×1
  • SkillDiscoveryReminder::collect_reminders (cognitive 19) crates/codegen/xai-grok-tools/src/reminders/skill_discovery.rs:92 — SkillDiscoveryReminder::collect_reminders has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 3 (4 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.
D2 · Cognitive Complexity · SkillManager · ×1
  • SkillManager::suggest_skill_path (cognitive 19) crates/codegen/xai-grok-tools/src/types/skill_discovery_tracker/skill_path_suggestion.rs:23 — SkillManager::suggest_skill_path has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 2 (3 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.
D2 · Cognitive Complexity · xai_ratatui_textarea · ×1
  • xai_ratatui_textarea::textarea::truncate_line_display (cognitive 19) crates/codegen/xai-ratatui-textarea/src/textarea.rs:3411 — xai_ratatui_textarea::textarea::truncate_line_display has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 2, 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.
D2 · Cognitive Complexity · UserMcpConfig · ×1
  • UserMcpConfig::toml_definitions (cognitive 18) crates/codegen/xai-grok-config/src/mcp_servers/server_list.rs:276 — UserMcpConfig::toml_definitions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (5 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.
D2 · Cognitive Complexity · McpClient · ×1
  • McpClient::ensure_initialized (cognitive 18) crates/codegen/xai-grok-mcp/src/servers.rs:3639 — McpClient::ensure_initialized has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 6 (11 pts), if/else 3 (4 pts), boolean chains 2, loops 1 (nesting depth added 6). 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.
D2 · Cognitive Complexity · WorkspaceMembership · ×1
  • WorkspaceMembership::next_effect (cognitive 18) crates/codegen/xai-grok-pager/src/app/workspace_membership.rs:356 — WorkspaceMembership::next_effect has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (15 pts), match/switch 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskEntry · ×1
  • TaskEntry::from_bg_task (cognitive 18) crates/codegen/xai-grok-pager/src/views/tasks_pane.rs:208 — TaskEntry::from_bg_task has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (15 pts), match/switch 1 (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.
D2 · Cognitive Complexity · WelcomeLayout · ×1
  • WelcomeLayout::compute_inner (cognitive 18) crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:356 — WelcomeLayout::compute_inner has cognitive complexity 18 (threshold 15). Drivers by points: if/else 17, boolean chains 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.
D2 · Cognitive Complexity · FailedResponseCapture · ×1
  • FailedResponseCapture::take_items (cognitive 18) crates/codegen/xai-grok-sampler/src/doom_loop_recovery.rs:413 — FailedResponseCapture::take_items has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2, match/switch 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.
D2 · Cognitive Complexity · ConfigHooksPath · ×1
  • ConfigHooksPath::visit (cognitive 18) crates/codegen/xai-grok-sandbox/src/command/git_config.rs:702 — ConfigHooksPath::visit has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (6 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.
D2 · Cognitive Complexity · SubagentPersona · ×1
  • SubagentPersona::render_io_summary (cognitive 18) crates/codegen/xai-grok-subagent-resolution/src/config.rs:117 — SubagentPersona::render_io_summary has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 2 (4 pts), 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.
D2 · Cognitive Complexity · xai_tool_types · ×1
  • xai_tool_types::schema_utils::resolve_ref_type (cognitive 18) crates/common/xai-tool-types/src/schema_utils.rs:155 — xai_tool_types::schema_utils::resolve_ref_type has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 2 (4 pts), boolean chains 2, loops 1 (2 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.
D2 · Cognitive Complexity · ChatStateActor · ×1
  • ChatStateActor::handle_command (cognitive 17) crates/codegen/xai-chat-state/src/actor/mod.rs:117 — ChatStateActor::handle_command has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 4 (8 pts), if/else 3 (5 pts), loops 2 (4 pts) (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.
D2 · Cognitive Complexity · xai_grok_cloud_config · ×1
  • xai_grok_cloud_config::managed_config::store::apply_fetched (cognitive 17) crates/codegen/xai-grok-cloud-config/src/managed_config/store.rs:327 — xai_grok_cloud_config::managed_config::store::apply_fetched has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), match/switch 2 (3 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, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · FireSim · ×1
  • FireSim::draw (cognitive 17) crates/codegen/xai-grok-gboom/src/engine.rs:628 — FireSim::draw has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (13 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.
D2 · Cognitive Complexity · Map · ×1
  • Map::los (cognitive 17) crates/codegen/xai-grok-gboom/src/game.rs:110 — Map::los has cognitive complexity 17 (threshold 15). Drivers by points: if/else 13 (16 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, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · LineViewerState · ×1
  • LineViewerState::interleave_comments (cognitive 17) crates/codegen/xai-grok-pager/src/views/file_search/line_viewer.rs:1058 — LineViewerState::interleave_comments has cognitive complexity 17 (threshold 15). Drivers by points: loops 6 (9 pts), if/else 2 (6 pts), boolean chains 2 (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.
D2 · Cognitive Complexity · AgentActivity · ×1
  • AgentActivity::flush_all_sessions (cognitive 17) crates/codegen/xai-grok-shell/src/agent/activity.rs:111 — AgentActivity::flush_all_sessions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (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.
D2 · Cognitive Complexity · ReadFileTool · ×1
  • ReadFileTool::execute (cognitive 17) crates/codegen/xai-grok-tools/src/implementations/grok_build/read_file/mod.rs:778 — ReadFileTool::execute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (7 pts), loops 2 (7 pts), boolean chains 2, 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.
D2 · Cognitive Complexity · XaiProtoBuilder · ×1
  • XaiProtoBuilder::emit_rerun_if_changed (cognitive 16) crates/build/xai-proto-build/src/lib.rs:138 — XaiProtoBuilder::emit_rerun_if_changed has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (5 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.
D2 · Cognitive Complexity · IndexManager · ×1
  • IndexManager::spawn (cognitive 16) crates/codegen/xai-codebase-graph/src/index_manager.rs:551 — IndexManager::spawn has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 2 (4 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.
D2 · Cognitive Complexity · MemoryConfig · ×1
  • MemoryConfig::resolve_settings (cognitive 16) crates/codegen/xai-grok-config-types/src/memory.rs:655 — MemoryConfig::resolve_settings has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 6 (8 pts), boolean chains 6, if/else 2 (nesting depth added 2). 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.
D2 · Cognitive Complexity · xai_grok_egress_proxy · ×1
  • xai_grok_egress_proxy::tls::inspect_records (cognitive 16) crates/codegen/xai-grok-egress-proxy/src/tls.rs:42 — xai_grok_egress_proxy::tls::inspect_records has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (14 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.
D2 · Cognitive Complexity · xai_grok_file_lock · ×1
  • xai_grok_file_lock::lock::lock_file_with (cognitive 16) crates/codegen/xai-grok-file-lock/src/lock.rs:41 — xai_grok_file_lock::lock::lock_file_with has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), match/switch 4 (7 pts), boolean chains 1, 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.
D2 · Cognitive Complexity · xai_grok_http · ×1
  • xai_grok_http::send_with_retry_escaping_pool (cognitive 16) crates/codegen/xai-grok-http/src/lib.rs:422 — xai_grok_http::send_with_retry_escaping_pool has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 3 (9 pts), if/else 3 (5 pts), boolean chains 1, loops 1 (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.
D2 · Cognitive Complexity · ActionRegistry · ×1
  • ActionRegistry::lookup_with_mode (cognitive 16) crates/codegen/xai-grok-pager/src/actions/mod.rs:387 — ActionRegistry::lookup_with_mode has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 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.
D2 · Cognitive Complexity · XtversionFilter · ×1
  • XtversionFilter::filter (cognitive 16) crates/codegen/xai-grok-pager/src/app/xt_filter.rs:123 — XtversionFilter::filter has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 1 (2 pts), boolean chains 1, 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.
D2 · Cognitive Complexity · NotificationService · ×1
  • NotificationService::on_tick (cognitive 16) crates/codegen/xai-grok-pager/src/notifications/mod.rs:140 — NotificationService::on_tick has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 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.
D2 · Cognitive Complexity · ExtensionsModalState · ×1
  • ExtensionsModalState::is_group_expanded (cognitive 16) crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2155 — ExtensionsModalState::is_group_expanded has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 5, match/switch 1 (nesting depth added 3). 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.
D2 · Cognitive Complexity · MouseScrollState · ×1
  • MouseScrollState::on_scroll_event_at (cognitive 16) crates/codegen/xai-grok-pager-render/src/input/mouse.rs:578 — MouseScrollState::on_scroll_event_at has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 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.
D2 · Cognitive Complexity · MarketplaceRelativePath · ×1
  • MarketplaceRelativePath::parse (cognitive 16) crates/codegen/xai-grok-plugin-marketplace/src/types.rs:40 — MarketplaceRelativePath::parse has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 3 (8 pts), loops 3 (5 pts), if/else 3 (nesting depth added 7). 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.
D2 · Cognitive Complexity · ConfigFileWatcher · ×1
  • ConfigFileWatcher::start (cognitive 16) crates/codegen/xai-grok-shell/src/config/watcher.rs:98 — ConfigFileWatcher::start has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 3, loops 3 (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.
D2 · Cognitive Complexity · PlanGuard · ×1
  • PlanGuard::restore_core (cognitive 16) crates/codegen/xai-grok-shell/src/session/goal_strategist.rs:446 — PlanGuard::restore_core has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), match/switch 3 (5 pts) (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.
D2 · Cognitive Complexity · StreamingSttSession · ×1
  • StreamingSttSession::connect (cognitive 16) crates/codegen/xai-grok-voice/src/stt/streaming.rs:36 — StreamingSttSession::connect has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), match/switch 2 (5 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.
D2 · Cognitive Complexity · FileIndex · ×1
  • FileIndex::from_walk_with_options (cognitive 16) crates/codegen/xai-grok-workspace/src/file_system/index.rs:504 — FileIndex::from_walk_with_options has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), match/switch 3 (6 pts), boolean chains 1, 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.
D2 · Cognitive Complexity · HubHandle · ×1
  • HubHandle::fmt (cognitive 16) crates/codegen/xai-grok-workspace/src/hub.rs:116 — HubHandle::fmt has cognitive complexity 16 (threshold 15). Drivers by points: if/else 16. 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.
D2 · Cognitive Complexity · xai_hunk_tracker · ×1
  • xai_hunk_tracker::loc::handle_event (cognitive 16) crates/codegen/xai-hunk-tracker/src/loc/mod.rs:323 — xai_hunk_tracker::loc::handle_event has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 2 (3 pts), boolean chains 2 (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.
D23 · Boundary Type-Coupling · Cross-context type CursorState (xai-grok-pager-render → xai-grok-pager) · ×1
  • Cross-context type CursorState (xai-grok-pager-render → xai-grok-pager) crates/codegen/xai-grok-pager/src/app/app_view.rs:530 — CursorState (context xai-grok-pager-render) is exposed in xai-grok-pager's public surface via AppView.cursor — couples the contexts.
D3 · God Classes · TooManyFunctions · ×1
  • TooManyFunctions: xai_computer_hub_sdk::metrics::inner crates/common/xai-computer-hub-sdk/src/metrics.rs:338 — TooManyFunctions — 39 free functions. The bar is 30 free functions; this is 9 over it, 1.30× 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.
D4 · Code Duplication · Near-duplicate member pair (65 shared lines) · ×1
  • Near-duplicate member pair (65 shared lines) crates/codegen/xai-grok-pager-render/src/theme/grokday.rs:53 — crates/codegen/xai-grok-pager-render/src/theme/grokday.rs:53-135 | crates/codegen/xai-grok-pager-render/src/theme/groknight.rs:55-137 — These two members are variants of one another: 65 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 · Near-duplicate member pair (51 shared lines) · ×1
  • Near-duplicate member pair (51 shared lines) crates/codegen/xai-fast-worktree/src/worktree/execute.rs:776 — crates/codegen/xai-fast-worktree/src/worktree/execute.rs:776-901 | crates/codegen/xai-fast-worktree/src/worktree/execute.rs:940-1155 — These two members are variants of one another: 51 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 · Near-duplicate member pair (45 shared lines) · ×1
  • Near-duplicate member pair (45 shared lines) crates/codegen/xai-codebase-graph/src/manager/builder.rs:400 — crates/codegen/xai-codebase-graph/src/manager/builder.rs:400-469 | crates/codegen/xai-codebase-graph/src/scope_graph/graph.rs:580-649 — These two members are variants of one another: 45 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 · Near-duplicate member pair (44 shared lines) · ×1
  • Near-duplicate member pair (44 shared lines) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:305 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:305-448 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:461-554 — These two members are variants of one another: 44 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 · Near-duplicate member pair (40 shared lines) · ×1
  • Near-duplicate member pair (40 shared lines) crates/codegen/xai-file-utils/src/storage_client.rs:699 — crates/codegen/xai-file-utils/src/storage_client.rs:699-795 | crates/codegen/xai-file-utils/src/storage_client.rs:803-912 — These two members are variants of one another: 40 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 · Near-duplicate member pair (32 shared lines) · ×1
  • Near-duplicate member pair (32 shared lines) crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:140 — crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:140-300 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1075-1213 — These two members are variants of one another: 32 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 · Near-duplicate member pair (31 shared lines) · ×1
  • Near-duplicate member pair (31 shared lines) crates/codegen/xai-grok-shell/src/extensions/consent.rs:21 — crates/codegen/xai-grok-shell/src/extensions/consent.rs:21-94 | crates/codegen/xai-grok-shell/src/extensions/privacy.rs:20-90 — These two members are variants of one another: 31 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 · Near-duplicate member pair (24 shared lines) · ×1
  • Near-duplicate member pair (24 shared lines) crates/codegen/xai-grok-login/src/manager.rs:863 — crates/codegen/xai-grok-login/src/manager.rs:863-908 | crates/codegen/xai-grok-login/src/manager.rs:910-953 — These two members are variants of one another: 24 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 (56 corresponding lines) · ×1
  • Edited copy of a member (56 corresponding lines) crates/codegen/xai-grok-tools/src/implementations/web_search/client.rs:195 — crates/codegen/xai-grok-tools/src/implementations/web_search/client.rs:195-252 | crates/codegen/xai-grok-tools/src/implementations/web_search/client.rs:260-317 — These two members are one piece of code written twice and then edited apart: 56 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 (26 corresponding lines) · ×1
  • Edited copy of a member (26 corresponding lines) crates/codegen/xai-grok-pager/src/views/agents_modal.rs:559 — crates/codegen/xai-grok-pager/src/views/agents_modal.rs:559-589 | crates/codegen/xai-grok-shell/src/extensions/bundle.rs:261-290 — These two members are one piece of code written twice and then edited apart: 26 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 (35 corresponding lines) · ×1
  • Edited copy of a member (35 corresponding lines) crates/codegen/xai-grok-markdown/src/latex/symbols.rs:3 — crates/codegen/xai-grok-markdown/src/latex/symbols.rs:3-51 | crates/codegen/xai-grok-markdown/src/latex/symbols.rs:53-90 — These two members are one piece of code written twice and then edited apart: 35 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 (16 corresponding lines) · ×1
  • Edited copy of a member (16 corresponding lines) crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:228 — crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:228-275 | crates/codegen/xai-grok-shell-terminal/src/streaming_local_terminal.rs:418-488 — These two members are one piece of code written twice and then edited apart: 16 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 (10 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (10 members, 50+ identical tokens) crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:81 — crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:81-123 | crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:125-159 | crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:194-225 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:165-1637 | crates/codegen/xai-grok-pager/src/app/dispatch/session/modal.rs:103-128 | crates/codegen/xai-grok-pager/src/app/dispatch/session/modal.rs:132-166 | crates/codegen/xai-grok-pager/src/app/dispatch/status.rs:156-177 | crates/codegen/xai-grok-pager/src/app/dispatch/status.rs:317-336 | crates/codegen/xai-grok-pager/src/app/dispatch/turn.rs:693-711 | crates/codegen/xai-grok-pager/src/app/dispatch/turn.rs:735-764 — These 10 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 10 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 10 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) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:135 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:135-241 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:175-256 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:145-231 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:181-277 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:211-318 — 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.
D4 · Code Duplication · Duplicated block (58 lines × 2) · ×1
  • Duplicated block (58 lines × 2) crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1418 — crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1418-1475 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1556-1613 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (51 lines × 2) · ×1
  • Duplicated block (51 lines × 2) crates/codegen/xai-grok-tools/src/implementations/web_search/client.rs:199 — crates/codegen/xai-grok-tools/src/implementations/web_search/client.rs:199-249 | crates/codegen/xai-grok-tools/src/implementations/web_search/client.rs:264-314 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (48 lines × 2) · ×1
  • Duplicated block (48 lines × 2) crates/codegen/xai-grok-shell/src/leader/mod.rs:636 — crates/codegen/xai-grok-shell/src/leader/mod.rs:636-683 | crates/codegen/xai-grok-shell/src/leader/mod.rs:691-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.
D4 · Code Duplication · Duplicated block (45 lines × 2) · ×1
  • Duplicated block (45 lines × 2) crates/codegen/xai-grok-markdown/src/render.rs:724 — crates/codegen/xai-grok-markdown/src/render.rs:724-768 | crates/codegen/xai-grok-markdown/src/render.rs:1021-1065 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (35–37 lines × 2) · ×1
  • Duplicated block (35–37 lines × 2) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:543 — crates/codegen/xai-grok-agent/src/plugins/git_install.rs:543-579 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:585-619 — before extracting anything, compare `crates/codegen/xai-grok-agent/src/plugins/git_install.rs` and `crates/codegen/xai-grok-plugin-marketplace/src/installer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 127 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.
D4 · Code Duplication · Duplicated block (37 lines × 2) · ×1
  • Duplicated block (37 lines × 2) crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1196 — crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1196-1232 | crates/codegen/xai-grok-tools/src/computer/local/terminal.rs:1346-1382 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (35–36 lines × 2) · ×1
  • Duplicated block (35–36 lines × 2) crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:919 — crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:919-954 | crates/codegen/xai-grok-pager/src/app/agent_view/modals.rs:1303-1337 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (33 lines × 3) · ×1
  • Duplicated block (33 lines × 3) crates/codegen/xai-grok-shell/src/session/goal_classifier.rs:501 — crates/codegen/xai-grok-shell/src/session/goal_classifier.rs:501-533 | crates/codegen/xai-grok-shell/src/session/goal_strategist.rs:174-206 | crates/codegen/xai-grok-shell/src/session/goal_summarizer.rs:160-192 — 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.
D4 · Code Duplication · Duplicated block (31–32 lines × 3) · ×1
  • Duplicated block (31–32 lines × 3) crates/codegen/xai-grok-shell/src/session/helpers/session_compact.rs:514 — crates/codegen/xai-grok-shell/src/session/helpers/session_compact.rs:514-545 | crates/codegen/xai-grok-shell/src/session/helpers/session_compact.rs:606-636 | crates/codegen/xai-grok-shell/src/session/helpers/session_compact.rs:730-761 — 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 · Duplicated block (31 lines × 2) · ×1
  • Duplicated block (31 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/list_dir/mod.rs:130 — crates/codegen/xai-grok-tools/src/implementations/grok_build/list_dir/mod.rs:130-160 | crates/codegen/xai-grok-tools/src/implementations/grok_build/list_dir/versions/legacy_0_4_10.rs:72-102 — 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.
D4 · Code Duplication · Duplicated block (30 lines × 2) · ×1
  • Duplicated block (30 lines × 2) crates/codegen/xai-file-utils/src/storage_client.rs:1095 — crates/codegen/xai-file-utils/src/storage_client.rs:1095-1124 | crates/codegen/xai-file-utils/src/storage_client.rs:1206-1235 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (23–27 lines × 2) · ×1
  • Duplicated block (23–27 lines × 2) crates/codegen/xai-grok-pager-render/src/render/bidi.rs:393 — crates/codegen/xai-grok-pager-render/src/render/bidi.rs:393-415 | crates/codegen/xai-grok-pager-render/src/render/wrapping.rs:287-313 — 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.
D4 · Code Duplication · Duplicated block (24–27 lines × 2) · ×1
  • Duplicated block (24–27 lines × 2) crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1555 — crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1555-1578 | crates/codegen/xai-grok-pager/src/views/dashboard/render.rs:1602-1628 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×1
  • Duplicated block (26 lines × 2) crates/codegen/xai-fast-worktree/src/worktree/execute.rs:777 — crates/codegen/xai-fast-worktree/src/worktree/execute.rs:777-802 | crates/codegen/xai-fast-worktree/src/worktree/execute.rs:941-966 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (21–26 lines × 2) · ×1
  • Duplicated block (21–26 lines × 2) crates/codegen/xai-grok-shell/src/session/goal_classifier.rs:1395 — crates/codegen/xai-grok-shell/src/session/goal_classifier.rs:1395-1420 | crates/codegen/xai-grok-shell/src/session/goal_classifier.rs:1448-1468 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (24–25 lines × 2) · ×1
  • Duplicated block (24–25 lines × 2) crates/codegen/xai-grok-sampler/src/client.rs:1162 — crates/codegen/xai-grok-sampler/src/client.rs:1162-1186 | crates/codegen/xai-grok-sampler/src/client.rs:1876-1899 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (24 lines × 3) · ×1
  • Duplicated block (24 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1466 — crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1466-1489 | crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs:1604-1627 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1340-1363 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/lifecycle.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 80 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.
D4 · Code Duplication · Duplicated block (19–24 lines × 2) · ×1
  • Duplicated block (19–24 lines × 2) crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:360 — crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:360-383 | crates/codegen/xai-grok-pager/src/scrollback/scrollback_pane.rs:417-435 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (19–22 lines × 4) · ×1
  • Duplicated block (19–22 lines × 4) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:140 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:140-158 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:180-198 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:186-207 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:216-235 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 142 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.
D4 · Code Duplication · Duplicated block (22 lines × 3) · ×1
  • Duplicated block (22 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:852 — crates/codegen/xai-grok-pager/src/app/dispatch/prompt.rs:852-873 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:73-94 | crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs:228-249 — 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.
D4 · Code Duplication · Duplicated block (21–22 lines × 3) · ×1
  • Duplicated block (21–22 lines × 3) crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:30 — crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs:30-51 | crates/codegen/xai-grok-sampler/src/stream/messages.rs:69-89 | crates/codegen/xai-grok-sampler/src/stream/responses.rs:222-242 — before extracting anything, compare `crates/codegen/xai-grok-sampler/src/stream/chat_completions.rs` and `crates/codegen/xai-grok-sampler/src/stream/messages.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 64 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.
D4 · Code Duplication · Duplicated block (17–22 lines × 2) · ×1
  • Duplicated block (17–22 lines × 2) crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:1642 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:1642-1658 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/run_loop.rs:1743-1764 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (15–20 lines × 3) · ×1
  • Duplicated block (15–20 lines × 3) crates/codegen/xai-grok-sampler/src/client.rs:1159 — crates/codegen/xai-grok-sampler/src/client.rs:1159-1178 | crates/codegen/xai-grok-sampler/src/client.rs:1546-1560 | crates/codegen/xai-grok-sampler/src/client.rs:1873-1891 — 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 · Duplicated block (18 lines × 3) · ×1
  • Duplicated block (18 lines × 3) crates/codegen/xai-grok-config/src/deserialize.rs:16 — crates/codegen/xai-grok-config/src/deserialize.rs:16-33 | crates/codegen/xai-grok-config/src/display_refresh.rs:99-116 | crates/codegen/xai-grok-config/src/remote_settings.rs:186-203 — 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.
D4 · Code Duplication · Duplicated block (11–18 lines × 2) · ×1
  • Duplicated block (11–18 lines × 2) crates/codegen/xai-grok-memory/src/dream_lock.rs:62 — crates/codegen/xai-grok-memory/src/dream_lock.rs:62-79 | crates/codegen/xai-grok-shell-base/src/util/mod.rs:200-210 — 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.
D4 · Code Duplication · Duplicated block (14–18 lines × 2) · ×1
  • Duplicated block (14–18 lines × 2) crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal.rs:287 — crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal.rs:287-300 | crates/codegen/xai-grok-shell/src/session/acp_session_impl/goal.rs:2231-2248 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (15–18 lines × 2) · ×1
  • Duplicated block (15–18 lines × 2) crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs:511 — crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs:511-528 | crates/codegen/xai-grok-tools/src/computer/local/static_shell.rs:208-222 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/computer/local/shell_state.rs` and `crates/codegen/xai-grok-tools/src/computer/local/static_shell.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 49 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.
D4 · Code Duplication · Duplicated block (16–17 lines × 3) · ×1
  • Duplicated block (16–17 lines × 3) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:97 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:97-112 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:137-153 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:122-138 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 142 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.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×1
  • Duplicated block (17 lines × 3) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:199 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:199-215 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:250-266 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:276-292 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 82 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.
D4 · Code Duplication · Duplicated block (14–17 lines × 3) · ×1
  • Duplicated block (14–17 lines × 3) crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:2151 — crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:2151-2164 | crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:2171-2187 | crates/codegen/xai-grok-pager/src/views/welcome/mod.rs:2210-2225 — 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 · Duplicated block (16–17 lines × 2) · ×1
  • Duplicated block (16–17 lines × 2) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:602 — crates/codegen/xai-grok-agent/src/plugins/git_install.rs:602-618 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:641-656 — before extracting anything, compare `crates/codegen/xai-grok-agent/src/plugins/git_install.rs` and `crates/codegen/xai-grok-plugin-marketplace/src/installer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 127 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.
D4 · Code Duplication · Duplicated block (14–17 lines × 2) · ×1
  • Duplicated block (14–17 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:387 — crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:387-400 | crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs:333-349 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs` as WHOLE FILES: this scan already matched 7 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. 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.
D4 · Code Duplication · Duplicated block (12–17 lines × 2) · ×1
  • Duplicated block (12–17 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build_concise/read_file.rs:79 — crates/codegen/xai-grok-tools/src/implementations/grok_build_concise/read_file.rs:79-90 | crates/codegen/xai-grok-tools/src/implementations/grok_build_hashline/read_file.rs:180-196 — 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.
D4 · Code Duplication · Duplicated block (12–16 lines × 3) · ×1
  • Duplicated block (12–16 lines × 3) crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:877 — crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:877-892 | crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:907-918 | crates/codegen/xai-grok-pager/src/app/agent_view/viewer.rs:931-942 — 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 · Duplicated block (13–16 lines × 2) · ×1
  • Duplicated block (13–16 lines × 2) crates/codegen/xai-grok-shell/src/session/goal_tracker.rs:941 — crates/codegen/xai-grok-shell/src/session/goal_tracker.rs:941-956 | crates/codegen/xai-grok-shell/src/session/goal_tracker.rs:975-987 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (14–15 lines × 3) · ×1
  • Duplicated block (14–15 lines × 3) crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:981 — crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:981-994 | crates/codegen/xai-grok-pager/src/views/feedback_modal/enum_picker.rs:175-189 | crates/codegen/xai-grok-pager/src/views/tutorial.rs:121-135 — 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.
D4 · Code Duplication · Duplicated block (14 lines × 5) · ×1
  • Duplicated block (14 lines × 5) crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2957 — crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2957-2970 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3081-3094 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3164-3177 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3303-3316 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3459-3472 — 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.
D4 · Code Duplication · Duplicated block (12–14 lines × 3) · ×1
  • Duplicated block (12–14 lines × 3) crates/codegen/xai-grok-pager-pty-harness/src/scenarios/large_codeblock.rs:23 — crates/codegen/xai-grok-pager-pty-harness/src/scenarios/large_codeblock.rs:23-34 | crates/codegen/xai-grok-pager-pty-harness/src/scenarios/mixed_interaction.rs:30-41 | crates/codegen/xai-grok-pager-pty-harness/src/scenarios/scroll_stress.rs:33-46 — 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.
D4 · Code Duplication · Duplicated block (13–14 lines × 3) · ×1
  • Duplicated block (13–14 lines × 3) crates/codegen/xai-grok-shell/src/agent/config.rs:3799 — crates/codegen/xai-grok-shell/src/agent/config.rs:3799-3812 | crates/codegen/xai-grok-shell/src/agent/config.rs:4557-4569 | crates/codegen/xai-grok-shell/src/agent/config.rs:4792-4804 — 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 · Duplicated block (12–14 lines × 2) · ×1
  • Duplicated block (12–14 lines × 2) crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/tool.rs:431 — crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/tool.rs:431-442 | crates/codegen/xai-grok-tools/src/implementations/codex/apply_patch/tool.rs:493-506 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (9–13 lines × 5) · ×1
  • Duplicated block (9–13 lines × 5) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:147 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:147-156 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:187-196 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:155-163 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:193-205 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:223-233 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 142 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.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×1
  • Duplicated block (10–13 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:320 — crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs:320-329 | crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs:287-299 — before extracting anything, compare `crates/codegen/xai-grok-tools/src/implementations/grok_build/search_replace/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/opencode/edit/mod.rs` as WHOLE FILES: this scan already matched 7 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. 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.
D4 · Code Duplication · Duplicated block (12 lines × 6) · ×1
  • Duplicated block (12 lines × 6) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:244 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:244-255 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs:317-328 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:259-270 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:234-245 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:280-291 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:321-332 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 39 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.
D4 · Code Duplication · Duplicated block (12 lines × 4) · ×1
  • Duplicated block (12 lines × 4) crates/codegen/xai-file-utils/src/queue.rs:1361 — crates/codegen/xai-file-utils/src/queue.rs:1361-1372 | crates/codegen/xai-file-utils/src/queue.rs:1414-1425 | crates/codegen/xai-file-utils/src/queue.rs:1468-1479 | crates/codegen/xai-file-utils/src/queue.rs:1504-1515 — 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.
D4 · Code Duplication · Duplicated block (10–12 lines × 2) · ×1
  • Duplicated block (10–12 lines × 2) crates/codegen/xai-grok-agent/src/plugins/git_install.rs:398 — crates/codegen/xai-grok-agent/src/plugins/git_install.rs:398-409 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:488-497 — before extracting anything, compare `crates/codegen/xai-grok-agent/src/plugins/git_install.rs` and `crates/codegen/xai-grok-plugin-marketplace/src/installer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 127 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.
D4 · Code Duplication · Duplicated block (9–12 lines × 2) · ×1
  • Duplicated block (9–12 lines × 2) crates/codegen/xai-grok-pager-render/src/input/key.rs:164 — crates/codegen/xai-grok-pager-render/src/input/key.rs:164-175 | crates/codegen/xai-grok-pager-render/src/input/key.rs:208-216 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (8–12 lines × 3) · ×1
  • Duplicated block (8–12 lines × 3) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:260 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:260-267 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:414-424 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:453-464 — 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 · Duplicated block (11 lines × 6) · ×1
  • Duplicated block (11 lines × 6) crates/codegen/xai-grok-sampler/src/client.rs:943 — crates/codegen/xai-grok-sampler/src/client.rs:943-953 | crates/codegen/xai-grok-sampler/src/client.rs:1081-1091 | crates/codegen/xai-grok-sampler/src/client.rs:1301-1311 | crates/codegen/xai-grok-sampler/src/client.rs:1442-1452 | crates/codegen/xai-grok-sampler/src/client.rs:1668-1678 | crates/codegen/xai-grok-sampler/src/client.rs:1794-1804 — 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.
D4 · Code Duplication · Duplicated block (10–11 lines × 3) · ×1
  • Duplicated block (10–11 lines × 3) crates/codegen/xai-grok-shell/src/session/goal_planner.rs:239 — crates/codegen/xai-grok-shell/src/session/goal_planner.rs:239-249 | crates/codegen/xai-grok-shell/src/session/goal_strategist.rs:120-129 | crates/codegen/xai-grok-shell/src/session/goal_summarizer.rs:105-114 — 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.
D4 · Code Duplication · Duplicated block (8–11 lines × 2) · ×1
  • Duplicated block (8–11 lines × 2) crates/codegen/xai-grok-tools/src/implementations/grok_build/image_gen/mod.rs:114 — crates/codegen/xai-grok-tools/src/implementations/grok_build/image_gen/mod.rs:114-121 | crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs:195-205 — `crates/codegen/xai-grok-tools/src/implementations/grok_build/image_gen/mod.rs` and `crates/codegen/xai-grok-tools/src/implementations/grok_build/video_gen/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 37 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (9–10 lines × 4) · ×1
  • Duplicated block (9–10 lines × 4) crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:942 — crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:942-950 | crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:952-960 | crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:969-978 | crates/codegen/xai-grok-permission-rules/src/bash_command_splitting.rs:997-1005 — 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.
D4 · Code Duplication · Duplicated block (8–10 lines × 3) · ×1
  • Duplicated block (8–10 lines × 3) crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:174 — crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs:174-181 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:233-242 | crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs:1160-1167 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/app/dispatch/session/fork.rs` and `crates/codegen/xai-grok-pager/src/app/dispatch/session/load.rs` 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. 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.
D4 · Code Duplication · Duplicated block (9 lines × 8) · ×1
  • Duplicated block (9 lines × 8) crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:821 — crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:821-829 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:837-845 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:853-861 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:869-877 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:886-894 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:905-913 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:925-933 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:946-954 — all 8 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 · Duplicated block (8–9 lines × 8) · ×1
  • Duplicated block (8–9 lines × 8) crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2877 — crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2877-2885 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:2958-2965 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3024-3031 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3082-3089 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3113-3120 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3165-3172 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3304-3311 | crates/codegen/xai-grok-pager/src/views/extensions_modal.rs:3460-3467 — all 8 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 · Duplicated block (7–9 lines × 6) · ×1
  • Duplicated block (7–9 lines × 6) crates/codegen/xai-grok-pager/src/views/elicitation_view/render.rs:196 — crates/codegen/xai-grok-pager/src/views/elicitation_view/render.rs:196-203 | crates/codegen/xai-grok-pager/src/views/modal.rs:881-887 | crates/codegen/xai-grok-pager/src/views/overlay_list.rs:99-106 | crates/codegen/xai-grok-pager/src/views/permission_view.rs:446-453 | crates/codegen/xai-grok-pager/src/views/question_view.rs:1565-1573 | crates/codegen/xai-grok-pager/src/views/rewind.rs:332-339 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/views/overlay_list.rs` and `crates/codegen/xai-grok-pager/src/views/rewind.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 40 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.
D4 · Code Duplication · Duplicated block (8–9 lines × 4) · ×1
  • Duplicated block (8–9 lines × 4) crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:65 — crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:65-72 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:85-92 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:147-155 | crates/codegen/xai-grok-plugin-marketplace/src/installer.rs:169-177 — 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.
D4 · Code Duplication · Duplicated block (5–9 lines × 3) · ×1
  • Duplicated block (5–9 lines × 3) crates/codegen/xai-grok-markdown/src/mermaid.rs:3194 — crates/codegen/xai-grok-markdown/src/mermaid.rs:3194-3202 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3228-3232 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3253-3257 — 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 · Duplicated block (8 lines × 10) · ×1
  • Duplicated block (8 lines × 10) crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:196 — crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:196-203 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:736-743 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:755-762 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:772-779 | crates/codegen/xai-grok-pager/src/app/dispatch/session/modal.rs:105-112 | crates/codegen/xai-grok-pager/src/app/dispatch/session/modal.rs:134-141 | crates/codegen/xai-grok-pager/src/app/dispatch/status.rs:161-169 | crates/codegen/xai-grok-pager/src/app/dispatch/status.rs:322-329 | crates/codegen/xai-grok-pager/src/app/dispatch/turn.rs:695-702 | crates/codegen/xai-grok-pager/src/app/dispatch/turn.rs:737-744 — there are 10 copies across 5 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 10 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (6–8 lines × 4) · ×1
  • Duplicated block (6–8 lines × 4) crates/codegen/xai-file-utils/src/queue.rs:797 — crates/codegen/xai-file-utils/src/queue.rs:797-802 | crates/codegen/xai-file-utils/src/queue.rs:957-962 | crates/codegen/xai-file-utils/src/queue.rs:1046-1053 | crates/codegen/xai-file-utils/src/queue.rs:1181-1188 — 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.
D4 · Code Duplication · Duplicated block (5–8 lines × 4) · ×1
  • Duplicated block (5–8 lines × 4) crates/codegen/xai-grok-markdown/src/mermaid.rs:3127 — crates/codegen/xai-grok-markdown/src/mermaid.rs:3127-3131 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3194-3201 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3228-3232 | crates/codegen/xai-grok-markdown/src/mermaid.rs:3253-3257 — 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.
D4 · Code Duplication · Duplicated block (7–8 lines × 3) · ×1
  • Duplicated block (7–8 lines × 3) crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:888 — crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:888-894 | crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:913-919 | crates/codegen/xai-grok-tools/src/implementations/grok_build/scheduler/actor.rs:963-970 — 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 · Duplicated block (7 lines × 12) · ×1
  • Duplicated block (7 lines × 12) crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:82 — crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:82-88 | crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:126-132 | crates/codegen/xai-grok-pager/src/app/dispatch/rewind.rs:195-201 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:735-741 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:754-760 | crates/codegen/xai-grok-pager/src/app/dispatch/router.rs:771-777 | crates/codegen/xai-grok-pager/src/app/dispatch/session/modal.rs:104-110 | crates/codegen/xai-grok-pager/src/app/dispatch/session/modal.rs:133-139 | crates/codegen/xai-grok-pager/src/app/dispatch/status.rs:160-166 | crates/codegen/xai-grok-pager/src/app/dispatch/status.rs:321-327 | crates/codegen/xai-grok-pager/src/app/dispatch/turn.rs:694-700 | crates/codegen/xai-grok-pager/src/app/dispatch/turn.rs:736-742 — there are 12 copies across 5 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 12 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (3–6 lines × 3) · ×1
  • Duplicated block (3–6 lines × 3) crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:1781 — crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:1781-1783 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3279-3284 | crates/codegen/xai-grok-pager/src/app/agent_view/render.rs:3845-3850 — 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 · Duplicated block (5 lines × 4) · ×1
  • Duplicated block (5 lines × 4) crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:194 — crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:194-198 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:222-226 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:251-255 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:281-285 — 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.
D4 · Code Duplication · Duplicated block (4–5 lines × 4) · ×1
  • Duplicated block (4–5 lines × 4) crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:265 — crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:265-268 | crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:496-500 | crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:505-509 | crates/codegen/xai-grok-shell/src/session/acp_conversion.rs:515-518 — 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.
D4 · Code Duplication · Duplicated block (8 lines × 7) · ×1
  • Duplicated block (8 lines × 7) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:866 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:866-873 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/execute.rs:106-113 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs:81-88 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs:114-121 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/read.rs:137-144 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search.rs:142-149 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:88-95 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/list_dir.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 33 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.
D4 · Code Duplication · Duplicated block (6 lines × 5) · ×1
  • Duplicated block (6 lines × 5) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:66 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:66-71 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:89-94 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/sent_message.rs:261-266 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:74-79 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:85-90 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 142 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.
D4 · Code Duplication · Duplicated block (10 lines × 6) · ×1
  • Duplicated block (10 lines × 6) crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:257 — crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs:257-266 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs:330-340 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/search_tool.rs:272-281 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/use_tool.rs:247-256 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_fetch.rs:293-302 | crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/web_search.rs:334-343 — before extracting anything, compare `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/memory_search.rs` and `crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/other.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 39 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.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×1
  • Duplicated block (9 lines × 5) crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2567 — crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2567-2575 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2604-2612 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2872-2880 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:2913-2921 | crates/codegen/xai-grok-pager/src/app/effects/mod.rs:3091-3099 — 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.
D4 · Code Duplication · Duplicated block (2–6 lines × 5) · ×1
  • Duplicated block (2–6 lines × 5) crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:192 — crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:192-193 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:220-221 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:244-249 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:274-279 | crates/codegen/xai-grok-shell/src/extensions/code_nav.rs:309-310 — 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.
D4 · Code Duplication · Near-duplicate member pair (81 shared lines) · ×1
  • Near-duplicate member pair (81 shared lines) crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs:33 — crates/codegen/xai-grok-shell/src/agent/subagent/isolated_spawn_e2e.rs:33-151 | crates/codegen/xai-grok-shell/src/test_support/lsp_runtime.rs:18-133 — These two members are variants of one another: 81 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 · Duplicated block (30 lines × 3) · ×1
  • Duplicated block (30 lines × 3) crates/codegen/xai-grok-test-support/src/sse.rs:571 — crates/codegen/xai-grok-test-support/src/sse.rs:571-600 | crates/codegen/xai-grok-test-support/src/sse.rs:667-696 | crates/codegen/xai-grok-test-support/src/sse.rs:988-1017 — 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 · Duplicated block (19 lines × 4) · ×1
  • Duplicated block (19 lines × 4) crates/codegen/xai-grok-test-support/src/sse.rs:402 — crates/codegen/xai-grok-test-support/src/sse.rs:402-420 | crates/codegen/xai-grok-test-support/src/sse.rs:567-585 | crates/codegen/xai-grok-test-support/src/sse.rs:663-681 | crates/codegen/xai-grok-test-support/src/sse.rs:984-1002 — 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.
D44 · Platform End-of-Life · End-of-life runtime · ×1
  • End-of-life runtime: Rust 1.94 rust-toolchain.toml:1 — rust-toolchain.toml declares Rust 1.94 as this project's toolchain file, and Rust 1.94, superseded by 1.95 on 2026-04-16 (the Rust project patches only the current stable). An unsupported runtime receives no security patches, so every vulnerability disclosed in it since 2026-04-16 is present and unfixable without moving off it. This is a migration rather than an upgrade: there is no newer release of a runtime that has ended.
D5 · Coupling · Unstable project xai-grok-pager · ×1
  • Unstable project xai-grok-pager — xai-grok-pager has instability 0.88 with 2 dependents.
D5 · Coupling · Unstable project xai-grok-shell · ×1
  • Unstable project xai-grok-shell — xai-grok-shell has instability 0.83 with 4 dependents.
D6 · Cohesion (LCOM4) · Low cohesion · ×1
  • Low cohesion: ToolDescription (LCOM4 4) crates/common/xai-tool-types/src/types.rs:10 — ToolDescription'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.
P1 · CI/CD gates · No CI pipeline · ×1
  • No CI pipeline — No CI workflow found (.github/workflows, azure-pipelines.yml, .gitlab-ci.yml, …) — changes aren't gated by an automated build/test.
SC1 · Supply-chain hygiene · JavaScript dependencies are not locked · ×1
  • JavaScript dependencies are not locked — No package-lock.json / yarn.lock / pnpm-lock.yaml / bun.lock — JS installs aren't reproducible (SSDF PW.4.4). Commit your package manager's lockfile and install from it (`npm ci`, `yarn --immutable`, `pnpm i --frozen-lockfile` or `bun i --frozen-lockfile`). Advisory — never scored.
X1 · Async correctness · Blocking `thread · ×1
  • Blocking `thread::sleep` inside an `async` body crates/codegen/xai-grok-pager-pty-harness/src/scroll_matrix/runner.rs:158 — This `async` body is polled on an executor's worker thread, and `std::thread::sleep` blocks that thread: for the whole delay no other task scheduled on it makes progress — the Rust form of blocking on a task. Use `tokio::time::sleep(…).await` (or the runtime's own timer), which suspends only this task. Where the blocking work is not a sleep but a synchronous call that cannot be made async, move it off the executor with `tokio::task::spawn_blocking(…).await`.
X14 · Bypassable address classification · IP classification is bypassable through an IPv4-in-IPv6 embedding · ×1
  • IP classification is bypassable through an IPv4-in-IPv6 embedding crates/codegen/xai-grok-hooks/src/runner/http.rs:63 — This function unwraps IPv4-MAPPED IPv6 (`to_ipv4_mapped`, line 70) and then rejects `10.0.0.0/8` on its IPv4 path — but the IPv6 decision at line 63 classifies the address as written, and IPv4 reaches IPv6 through three MORE embeddings this function never mentions: IPv4-compatible (`::a.b.c.d`), 6to4 (`2002::/16`) and NAT64 (`64:ff9b::/96`). So `::10.0.0.1`, `2002:0a00:0001::` and `64:ff9b::10.0.0.0` all name a host inside `10.0.0.0/8` — the range this same function declares non-public — and all reach the IPv6 decision un-unwrapped, taking the opposite verdict. Unwrap every embedding to its IPv4 form before classifying, or reject any IPv6 address carrying an embedded IPv4 outright.
Minor — 126 finding(s)
X4 · Structured logging · Interpolated log message defeats structured logging · ×40
  • Interpolated log message defeats structured logging crates/common/xai-computer-hub-sdk/src/connection.rs:374 — `debug!` at line 374 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-tracing-macros/src/timestamp.rs:26 — `info!` at line 26 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-tracing-macros/src/timestamp.rs:33 — `info!` at line 33 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-tracing-macros/src/timestamp.rs:45 — `warn!` at line 45 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-tracing-macros/src/timestamp.rs:52 — `warn!` at line 52 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-ratatui-textarea/src/textarea.rs:2070 — `debug!` at line 2070 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-hunk-tracker/src/actor/mod.rs:333 — `debug!` at line 333 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:512 — `debug!` at line 512 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:595 — `debug!` at line 595 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:613 — `debug!` at line 613 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:632 — `debug!` at line 632 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-hunk-tracker/src/actor/mutations.rs:636 — `debug!` at line 636 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/fs_notify.rs:204 — `debug!` at line 204 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/fs_notify.rs:210 — `debug!` at line 210 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/fs_notify.rs:215 — `debug!` at line 215 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/fs_notify.rs:218 — `debug!` at line 218 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/fs_notify.rs:227 — `debug!` at line 227 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/handle.rs:1884 — `warn!` at line 1884 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/handle.rs:4173 — `warn!` at line 4173 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/sandbox_mode.rs:378 — `warn!` at line 378 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/permission/sandbox_network.rs:375 — `info!` at line 375 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs:531 — `info!` at line 531 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/permission/manager/mod.rs:540 — `info!` at line 540 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/file_system/attach_file.rs:202 — `warn!` at line 202 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/codegen/xai-grok-workspace/src/file_system/attach_file.rs:226 — `warn!` at line 226 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • + 15 more in this group — see findings.md.
X7 · Silent fallback defaults · Silent fallback default on Err · ×40
  • Silent fallback default on Err crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:168 — `collect_files_git2` turns every `Err` into `vec![]` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-codebase-graph/src/bin/bench_file_listing.rs:216 — `collect_files_git2_index_only` turns every `Err` into `vec![]` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-fast-worktree/src/api.rs:1231 — `cleanup_orphaned_btrfs_snapshots` turns every `Err` into `CleanupReport::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-announcements/src/lib.rs:92 — `read_hidden_announcement_ids` turns every `Err` into `BTreeSet::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-config/src/endpoints.rs:114 — `from_effective_config` turns every `Err` into `Self::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-config/src/endpoints.rs:124 — `from_config_value` turns every `Err` into `Self::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-config/src/config_layers.rs:310 — `load_dismissed_ids` turns every `Err` into `std::collections::HashSet::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-config/src/mcp_servers/config_toml.rs:94 — `get_all_mcp_disabled_tools` turns every `Err` into `HashMap::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-http/src/lib.rs:247 — `process_client_identifier` turns every `Err` into `"grok-shell".to_string()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager/src/acp/tracker.rs:2900 — `parse_search_tool_results` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager/src/app/acp_handler/permissions.rs:349 — `mcp_args_lines` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager/src/app/event_loop.rs:2968 — `load_initial_ui_config` turns every `Err` into `UiConfig::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager/src/app/event_loop.rs:2987 — `load_initial_config_session_bools` turns every `Err` into `InitialConfigSessionBools::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager/src/memory_trace.rs:558 — `collect_for_export` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager/src/slash/commands/export.rs:90 — `list_path_completions` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager/src/views/agents_modal.rs:594 — `load_agent_toggle` turns every `Err` into `HashMap::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager/src/views/dashboard/state.rs:946 — `read_subdirs` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager-render/src/render/bidi.rs:583 — `style_at` turns every `Err` into `Style::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-pager-render/src/theme/cache.rs:270 — `load_auto_theme_config` turns every `Err` into `AutoThemeConfig::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-sampler/src/doom_loop.rs:89 — `take` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-shell/src/agent/mvp_agent/mod.rs:1294 — `find_orphaned_background_tasks` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-shell/src/relay/sync.rs:110 — `load` turns every `Err` into `Self::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-shell/src/session/acp_session_impl/status_line.rs:226 — `repo_state` turns every `Err` into `RepoState::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-shell/src/config/mod.rs:1704 — `dismissed_plugin_ctas_in_file` turns every `Err` into `std::collections::HashSet::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/codegen/xai-grok-shell/src/config/mod.rs:1843 — `registered_hook_paths` turns every `Err` into `std::collections::HashSet::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • + 15 more in this group — see findings.md.
X10 · Duplicated predicate · Duplicated predicate · ×25
  • Duplicated predicate crates/codegen/xai-grok-pager-render/src/terminal/da2.rs:58 — `!gate_allows_probe(ctx) || !std::io::stdin().is_terminal()` appears character-identically in 2 files — crates/codegen/xai-grok-pager-render/src/terminal/da2.rs, crates/codegen/xai-grok-pager-render/src/terminal/xtversion.rs. 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 crates/codegen/xai-grok-pager/src/app/acp_handler/mod.rs:358 — `!had_activity_before && agent.session.tracker.activity().is_some()` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/app/acp_handler/mod.rs, crates/codegen/xai-grok-pager/src/app/acp_handler/session_notification.rs. 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 crates/codegen/xai-grok-pager/src/acp/tracker.rs:2529 — `!id.is_empty() && seen.insert(id.to_string())` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/acp/tracker.rs, crates/common/xai-tool-types/src/task.rs. 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 crates/codegen/xai-grok-tools/src/implementations/grok_build/kill_task/mod.rs:409 — `!msg.contains("task-a") && !msg.contains("task-b")` appears character-identically in 2 files — crates/codegen/xai-grok-tools/src/implementations/grok_build/kill_task/mod.rs, crates/codegen/xai-grok-tools/src/implementations/grok_build/task_output/mod.rs. 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 crates/codegen/xai-grok-pager/src/views/elicitation_view/state.rs:279 — `!parsed.username().is_empty() || parsed.password().is_some()` appears character-identically in 3 files — crates/codegen/xai-grok-pager/src/views/elicitation_view/state.rs, crates/codegen/xai-grok-shell/src/upload/trace.rs, crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/client.rs. 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 crates/codegen/xai-grok-agent/src/prompt/template.rs:733 — `!rendered.contains("${{") && !rendered.contains("${%")` appears character-identically in 2 files — crates/codegen/xai-grok-agent/src/prompt/template.rs, crates/common/xai-tool-types/src/task.rs. 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 crates/codegen/xai-grok-workspace/src/handle.rs:4757 — `!s.is_empty() && !s.contains('/') && !s.contains('\\') && !s.contains("..") && !s.contains('\0')` appears character-identically in 2 files — crates/codegen/xai-grok-workspace/src/handle.rs, crates/codegen/xai-grok-workspace/src/recovery.rs. 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 crates/codegen/xai-grok-pager/src/app/agent_view/prompt.rs:796 — `!self.prompt.text().is_empty() || !self.prompt.images.is_empty()` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/app/agent_view/prompt.rs, crates/codegen/xai-grok-pager/src/app/agent_view/prompt_stash.rs. 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 crates/codegen/xai-grok-markdown/src/streaming.rs:2134 — `a.column_range.end <= b.column_range.start || b.column_range.end <= a.column_range.start` appears character-identically in 2 files — crates/codegen/xai-grok-markdown/src/streaming.rs, crates/codegen/xai-grok-markdown/src/url_scan.rs. 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 crates/codegen/xai-grok-pager/src/app/dispatch/modes.rs:467 — `agent.session.session_id.is_none() || agent.deferred_permission_mode.is_some()` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/app/dispatch/modes.rs, crates/codegen/xai-grok-pager/src/app/dispatch/settings/ui.rs. 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 crates/codegen/xai-grok-pager/src/app/dispatch/turn.rs:604 — `agent.session.state.is_turn_running() || agent.session.state.is_cancelling()` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/app/dispatch/turn.rs, crates/codegen/xai-grok-pager/src/app/turn_completion.rs. 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 crates/codegen/xai-grok-mcp/src/oauth.rs:228 — `c.is_alphanumeric() || c == '-' || c == '_'` appears character-identically in 2 files — crates/codegen/xai-grok-mcp/src/oauth.rs, crates/codegen/xai-grok-pager/src/views/agents_modal.rs. 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 crates/codegen/xai-grok-shell/src/leader/server.rs:1039 — `c.is_ascii_alphanumeric() || c == '-' || c == '_'` appears character-identically in 4 files — crates/codegen/xai-grok-shell/src/leader/server.rs, crates/codegen/xai-grok-tools/src/util/mcp_truncate.rs, crates/codegen/xai-grok-workspace/src/permission/state.rs, crates/codegen/xai-grok-workspace/src/session/checkpoint_store.rs. 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 crates/codegen/xai-grok-session-search/src/fts.rs:655 — `c.is_ascii_alphanumeric() || c == '_' || c == '-'` appears character-identically in 3 files — crates/codegen/xai-grok-session-search/src/fts.rs, crates/codegen/xai-grok-workspace/src/session/tool_config.rs, crates/common/xai-tool-protocol/src/ids.rs. 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 crates/codegen/xai-grok-pager/src/views/fps_hud.rs:363 — `cell.fg == Color::White || cell.fg == Color::Yellow` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/views/fps_hud.rs, crates/codegen/xai-grok-pager/src/views/scroll_debug_hud.rs. 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 crates/codegen/xai-grok-pager/src/app/modals.rs:3341 — `cell.modifier.contains(ratatui::style::Modifier::REVERSED) || (theme.text_primary != ratatui::style::Color::Reset && cell.bg == theme.text_p…` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/app/modals.rs, crates/codegen/xai-grok-pager/src/views/new_worktree_dialog.rs. 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 crates/codegen/xai-grok-pager/src/views/overlay_list.rs:60 — `col < area.x || col >= area.x + area.width` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/views/overlay_list.rs, crates/codegen/xai-grok-pager/src/views/rewind.rs. 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 crates/codegen/xai-grok-pager/src/app/agent_view/paste.rs:236 — `completion == ClipboardPasteCompletion::FullMiss && ctx.source.is_clipboard_key()` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/app/agent_view/paste.rs, crates/codegen/xai-grok-pager/src/views/dashboard/state.rs. 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 crates/codegen/xai-grok-pager/src/views/picker.rs:1917 — `content_area.height == 0 || content_area.width == 0` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/views/picker.rs, crates/codegen/xai-grok-pager/src/views/settings_modal/render.rs. 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 crates/codegen/xai-grok-pager/src/app/queue_edit.rs:58 — `crate::input::is_mod_enter(key) || crate::input::is_delivered_super_enter(key)` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/app/queue_edit.rs, crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs. 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 crates/codegen/xai-grok-pager/src/views/picker.rs:2671 — `crate::input::key::is_paste_key(key) || crate::input::key::is_inline_paste_key(key)` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/views/picker.rs, crates/codegen/xai-grok-pager/src/views/prompt_widget/mod.rs. 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 crates/codegen/xai-fast-worktree/src/db/queries.rs:243 — `crate::nfs::dest_is_nfs_mount(dest) || crate::nfs::dest_is_mountpoint(dest) || !crate::nfs::dest_is_known_unmounted(dest)` appears character-identically in 2 files — crates/codegen/xai-fast-worktree/src/db/queries.rs, crates/codegen/xai-fast-worktree/src/discovery.rs. 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 crates/codegen/xai-grok-shell/src/session/acp_session_impl/rewind.rs:204 — `current_content.is_none() && after_content.is_some()` appears character-identically in 2 files — crates/codegen/xai-grok-shell/src/session/acp_session_impl/rewind.rs, crates/codegen/xai-grok-workspace/src/session/file_state.rs. 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 crates/codegen/xai-grok-shell/src/session/acp_session_impl/rewind.rs:206 — `current_content.is_some() && after_content.is_none()` appears character-identically in 2 files — crates/codegen/xai-grok-shell/src/session/acp_session_impl/rewind.rs, crates/codegen/xai-grok-workspace/src/session/file_state.rs. 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 crates/codegen/xai-grok-pager/src/app/mouse.rs:1136 — `dd_area.contains((mouse.column, mouse.row).into()) && !on_scrollbar` appears character-identically in 2 files — crates/codegen/xai-grok-pager/src/app/mouse.rs, crates/codegen/xai-grok-pager/src/views/dashboard/state.rs. 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.
X9 · Subsumed condition operand · Subsumed condition operand · ×10
  • Subsumed condition operand crates/codegen/xai-grok-workspace/src/session/tool_config.rs:571 — `base_url.contains("cli-chat-proxy")` can never decide this `||` — every value satisfying `base_url.contains("cli-chat-proxy")` also satisfies `base_url.contains("chat-proxy")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-update/tests/test_check_status_regression.rs:93 — `err.contains("E403")` can never decide this `||` — every value satisfying `err.contains("E403")` also satisfies `err.contains("403")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-update/tests/test_check_status_regression.rs:121 — `err.contains("E403")` can never decide this `||` — every value satisfying `err.contains("E403")` also satisfies `err.contains("403")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-shell/tests/test_config_update_isolation.rs:232 — `msg.contains("Is a directory")` can never decide this `||` — every value satisfying `msg.contains("Is a directory")` also satisfies `msg.contains("directory")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-shell/src/session/compaction_inline_auto_compact_flow_tests.rs:662 — `message.contains("Unauthorized (401)")` can never decide this `||` — every value satisfying `message.contains("Unauthorized (401)")` also satisfies `message.contains("401")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-pager-pty-harness/tests/pty_auto_mode.rs:176 — `screen.contains("Switched to mode: Auto")` can never decide this `||` — every value satisfying `screen.contains("Switched to mode: Auto")` also satisfies `screen.contains("Auto")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-pager/src/views/dashboard/render_tests.rs:4378 — `content.contains(":send")` can never decide this `&&` — every value satisfying `content.contains(":send+open")` also satisfies `content.contains(":send")`, so the `&&` chain is already decided by the former. The expression is equivalent to the chain without it, which means it is narrower than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-pager/src/views/dashboard/row_title_tests.rs:364 — `text.contains("1 bg")` can never decide this `||` — every value satisfying `text.contains("1 bg")` also satisfies `text.contains("bg")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-pager/src/scrollback/blocks/tool/edit.rs:3141 — `line2.contains(" fmt")` can never decide this `||` — every value satisfying `line2.contains(" fmt")` also satisfies `line2.contains("fmt")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
  • Subsumed condition operand crates/codegen/xai-grok-memory/src/text_utils.rs:7 — `text.contains("## ")` can never decide this `||` — every value satisfying `text.contains("## ")` also satisfies `text.contains("# ")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
D30 · Dependency Vulnerabilities · Low vulnerability · ×4
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D20 · ADR Quality · No ADRs found · ×1
  • 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 — 11 of 106 project(s) overshoot their size bounds, lowering Project Cohesion to 7.9/10. The most over is `crates/codegen/xai-grok-pager` (366969 LoC, 1202 module-visible types across 49 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.
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
P10 · Library API & versioning · No explicit versioning · ×1
  • No explicit versioning crates/codegen/xai-grok-shared/Cargo.toml — No explicit version was found for the crates.io library declared by `Cargo.toml`. This check read a `version` in Cargo.toml (or `version.workspace = true`), and a CHANGELOG/CHANGES/HISTORY/NEWS/RELEASES file with a semver heading, or release tooling (changesets, release-please, semantic-release, goreleaser, cargo-release, bump2version, standard-version, git-cliff) in the library's directory or at the repository root, or a semver release tag (or a Drupal `8.x-1.2` release tag) in the repository. A version computed where none of those can see is invisible here. A published library needs explicit semantic versioning so consumers can reason about breaking changes.
P2 · Observability · Logging is not universal · ×1
  • Logging is not universal — Only 70/75 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `.`, `crates/codegen/xai-grok-egress-proxy`, `crates/codegen/xai-grok-markdown`, `crates/codegen/xai-grok-pager/npm/grok`, `crates/codegen/xai-mixpanel`.
S1 · Web-Security Posture · No app-layer HTTPS enforcement detected · ×1
  • No app-layer HTTPS enforcement detected — This repository starts an HTTP server and nothing in its Rust source or committed `Rocket.toml` secures the transport: no TLS served (actix-web `bind_rustls`/`bind_openssl`, axum-server `bind_rustls` with a `RustlsConfig`, tonic `ServerTlsConfig`, a `TlsAcceptor`, Rocket's `[default.tls]`), no `Strict-Transport-Security` header, no `X-Forwarded-Proto` read from a TLS-terminating proxy — so its traffic may cross the network in clear text. (−2.0 on this card.) The server: `axum::serve(` (crates/codegen/xai-grok-shell/src/agent/server.rs:633).
S1 · Web-Security Posture · No security response headers detected · ×1
  • No security response headers detected — None of the 11 security response headers the OWASP Secure Headers Project recommends (Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options, …) is set on a response this repository's Rust server sends — defense in depth, even when a proxy could set them. (−2.0 on this card.) The server: `axum::serve(` (crates/codegen/xai-grok-shell/src/agent/server.rs:633).
Minor — 90 finding(s)
D12 · Dependency Hygiene · Outdated · ×90
  • Outdated: anstyle — `anstyle` is locked at 1.0.13 but 1.0.14 is the current stable release on crates.io, and it already satisfies the `"1.0"` requirement declared in crates/codegen/xai-grok-markdown/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p anstyle` and commit the updated REDACTED.
  • Outdated: anstyle-lossy — `anstyle-lossy` is locked at 1.1.4 but 1.1.5 is the current stable release on crates.io, and it already satisfies the `"1.1.4"` requirement declared in crates/codegen/xai-grok-markdown/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p anstyle-lossy` and commit the updated REDACTED.
  • Outdated: anstyle-syntect — `anstyle-syntect` is locked at 1.0.4 but 1.0.5 is the current stable release on crates.io, and it already satisfies the `"1.0.4"` requirement declared in crates/codegen/xai-grok-markdown/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p anstyle-syntect` and commit the updated REDACTED.
  • Outdated: arboard — `arboard` is locked at 3.6.1 but 3.7.0 is the current stable release on crates.io, and it already satisfies the `"3.6"` requirement declared in crates/codegen/xai-grok-shared/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p arboard` and commit the updated REDACTED.
  • Outdated: arc-swap — `arc-swap` is locked at 1.9.2 but 1.9.3 is the current stable release on crates.io, and it already satisfies the `"1.7"` requirement declared in crates/codegen/xai-grok-login/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p arc-swap` and commit the updated REDACTED.
  • Outdated: async-compression — `async-compression` is locked at 0.4.19 but 0.4.51 is the current stable release on crates.io, and it already satisfies the `"0.4.17"` requirement declared in crates/codegen/xai-file-utils/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p async-compression` and commit the updated REDACTED.
  • Outdated: async-lsp — `async-lsp` is locked at 0.2.3 but 0.2.4 is the current stable release on crates.io, and it already satisfies the `"0.2.3"` requirement declared in crates/codegen/xai-grok-tools/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p async-lsp` and commit the updated REDACTED.
  • Outdated: async-trait — `async-trait` is locked at 0.1.89 but 0.1.92 is the current stable release on crates.io, and it already satisfies the `"0.1"` requirement declared in crates/codegen/xai-acp-lib/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p async-trait` and commit the updated REDACTED.
  • Outdated: aws-config — `aws-config` is locked at 1.8.8 but 1.13.0 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in crates/codegen/xai-file-utils/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p aws-config` and commit the updated REDACTED.
  • Outdated: aws-sdk-s3 — `aws-sdk-s3` is locked at 1.109.0 but 1.155.0 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in crates/codegen/xai-file-utils/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p aws-sdk-s3` and commit the updated REDACTED.
  • Outdated: aws-smithy-http-client — `aws-smithy-http-client` is locked at 1.1.9 but 1.5.1 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in crates/codegen/xai-file-utils/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p aws-smithy-http-client` and commit the updated REDACTED.
  • Outdated: axum — `axum` is locked at 0.8.6 but 0.8.9 is the current stable release on crates.io, and it already satisfies the `"0.8"` requirement declared in crates/codegen/ptyctl-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p axum` and commit the updated REDACTED.
  • Outdated: blake3 — `blake3` is locked at 1.8.2 but 1.8.7 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in crates/codegen/xai-grok-cloud-config/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p blake3` and commit the updated REDACTED.
  • Outdated: bstr — `bstr` is locked at 1.12.1 but 1.13.1 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in crates/codegen/xai-grok-tools/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p bstr` and commit the updated REDACTED.
  • Outdated: bytes — `bytes` is locked at 1.11.1 but 1.12.1 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in crates/codegen/xai-fast-worktree/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p bytes` and commit the updated REDACTED.
  • Outdated: camino — `camino` is locked at 1.2.1 but 1.2.6 is the current stable release on crates.io, and it already satisfies the `"1.1.10"` requirement declared in crates/codegen/xai-grok-paths/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p camino` and commit the updated REDACTED.
  • Outdated: chrono — `chrono` is locked at 0.4.44 but 0.4.45 is the current stable release on crates.io, and it already satisfies the `"0.4"` requirement declared in crates/codegen/ptyctl-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p chrono` and commit the updated REDACTED.
  • Outdated: clap — `clap` is locked at 4.5.53 but 4.6.7 is the current stable release on crates.io, and it already satisfies the `"4"` requirement declared in crates/codegen/ptyctl-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p clap` and commit the updated REDACTED.
  • Outdated: clap_complete — `clap_complete` is locked at 4.6.5 but 4.6.11 is the current stable release on crates.io, and it already satisfies the `"4"` requirement declared in crates/codegen/xai-grok-pager/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p clap_complete` and commit the updated REDACTED.
  • Outdated: command-fds — `command-fds` is locked at 0.3.2 but 0.3.3 is the current stable release on crates.io, and it already satisfies the `"0.3"` requirement declared in crates/codegen/xai-grok-tools/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p command-fds` and commit the updated REDACTED.
  • Outdated: crc32fast — `crc32fast` is locked at 1.5.0 but 1.5.3 is the current stable release on crates.io, and it already satisfies the `"1.4"` requirement declared in crates/codegen/xai-grok-image/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p crc32fast` and commit the updated REDACTED.
  • Outdated: crossbeam — `crossbeam` is locked at 0.8.4 but 0.8.5 is the current stable release on crates.io, and it already satisfies the `"0.8"` requirement declared in crates/codegen/xai-codebase-graph/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p crossbeam` and commit the updated REDACTED.
  • Outdated: dashmap — `dashmap` is locked at 6.1.0 but 6.2.1 is the current stable release on crates.io, and it already satisfies the `"6"` requirement declared in crates/codegen/xai-codebase-graph/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p dashmap` and commit the updated REDACTED.
  • Outdated: encoding_rs — `encoding_rs` is locked at 0.8.35 but 0.8.42 is the current stable release on crates.io, and it already satisfies the `"0.8.35"` requirement declared in crates/codegen/xai-grok-tools/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p encoding_rs` and commit the updated REDACTED.
  • Outdated: env_logger — `env_logger` is locked at 0.11.8 but 0.11.11 is the current stable release on crates.io, and it already satisfies the `"0.11"` requirement declared in crates/codegen/ptyctl-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p env_logger` and commit the updated REDACTED.
  • + 65 more in this group — see findings.md.

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.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-23c6523e8d8b477087edc5637dbb60ae/history.json --exit-code 0 --source .3artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-23c6523e8d8b477087edc5637dbb60ae/tree.json --exit-code 0 --source .3artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/watchdog-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off --exclude *.arrow --exclude *.avro --exclude *.csv --exclude *.dat --exclude *.db --exclude *.feather --exclude *.geojson --exclude *.h5 --exclude *.hdf5 --exclude *.jsonl --exclude *.log --exclude *.ndjson --exclude *.npy --exclude *.npz --exclude *.orc --exclude *.parquet --exclude *.pickle --exclude *.pkl --exclude *.psv --exclude *.sqlite --exclude *.sqlite3 --exclude *.tfrecord --exclude *.tsv --exclude *.txt --exclude crates/common/xai-tool-protocol/generated .4artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** . --skip-db-update41artifacts/raw/trivy-fs.json
D31 · IaC & Container Securitytrivy—trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.0—
D32 · Data Compliance (PII/GDPR)semgrep—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.0—
D36 · Supply-chain Provenance & Signingprovenance—provenance: not applicable — No CI/build pipeline found (.github/.forgejo/.gitea workflows, .circleci, .buildkite, .woodpecker, .teamcity, .gitlab-ci.yml, .travis.yml, bitbucket-pipelines.yml, .drone.yml, .cirrus.yml, .woodpecker.yml, appveyor.yml, azure-pipelines*.yml, .pipelines/, .vsts-ci/, .azuredevops/, Jenkinsfile); there is no build to attest provenance for.0—
D40 · Network Egress Confinementruntime-hardening—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.0—
D41 · Kernel & Syscall Confinementruntime-hardening—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.0—
D42 · Runtime Threat Enforcementruntime-hardening—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.0—
D43 · Malicious Dependenciestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** . --skip-db-update0artifacts/raw/trivy-fs.json

Run 01a17642-5a8d-75e2-84ea-5a68e8c28c22 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

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.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md