Public report of ZhuLinsen/daily_stock_analysis, published 25 October 2026. It has the same score, grades and number of
findings as the full report. The details of security findings (where they are in the code, which known
vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive reportMeasured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.10.5). Watchdog signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey →
Signed and filed in the standard's public register, 25 October 2026, 04:13 UTC · Survey ID cd_e0b79be0335e47a08cd7a30db4759a83
ZhuLinsen/daily_stock_analysis
Measured 25 October 2026, 03:56 UTC, at code version ec66bf4
Regression: 1 dimension fell since the last survey
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.
CAI scoreAt riskDown 1 since the last survey
The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.
A large codebase: 215,955 lines of product code in 21 projects, tests not counted · Estimated rebuild effort: about 2.4 person-years · Weakest lens: Accessibility, 33
Findings by how serious they are
163 critical1797 serious233 minor
11 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
25 October 2026, 03:56 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.
A critical security finding is open, such as a library with a known critical vulnerability or a password or key found in the code. The score itself is unchanged, but its band shows At risk until the finding is fixed. See the Security and Compliance lens.
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 ▸
83of 86 dimensions measured by tools. The other 3 are advisory notes from an AI model, which explain the code but don't count towards the score.
2165of 2193 findings point to an exact file and line, so you can open each one in the code. The other 28 concern the repository as a whole, such as missing documentation.
86dimensions across 7 lenses, read from 215,955 lines of product code in 21 projects.
ZhuLinsen/daily_stock_analysis scores 44 out of 100, but it is rated At risk while a critical security finding is open; the score itself is unchanged.
The weakest lens counts most in the score, and here that is Accessibility, which scores 33 and is rated Weak. Its Text alternatives dimension scores 1 out of 10, and until that reaches 4, Accessibility can't be rated higher than Adequate. The first actions are to add a text alternative — alt on images (alt="" for purely decorative ones), a title or aria-label on meaningful svg, an aria-label or inner fallback content on canvas, and a captions <track> on video and to add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing, and if Accessibility rose to 70, the score would rise from 44 to about 52.
163 findings are critical: 84 in Static Analysis (SAST), 39 in Forms & labels, 31 in Dependency Vulnerabilities, four in Keyboard semantics, one in Coupling, one in IaC & Container Security, one in Knowledge Freshness, one in Project dependency cycles and one in Secrets (history).
Watchdog couldn't measure 10 dimensions in this code, among them Code Coverage, Test Reliability and Internal API Consistency, so they are left out of the score. The product code is 215,955 lines, which would take an estimated 2.4 person-years, around €350,000, to rebuild.
A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.
How the score is built: what each lens counts forThe lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
If Accessibility rose from 33 to 70, the lowest score rated Strong, the score would rise from 44 to about 52.
Code composition: what the lines of code are
Product code 54%Tests 46%
New since the last survey: 157 findings
These 157 critical or serious findings weren't in the previous survey, on 11 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.
Large Files · apps/dsa-web/src/components/settings/LLMChannelEditor.tsx: 2469 lines of code apps/dsa-web/src/components/settings/LLMChannelEditor.tsx
Large Files · apps/dsa-web/src/i18n/uiText.ts: 2026 lines of code apps/dsa-web/src/i18n/uiText.ts
Large Files · apps/dsa-web/src/pages/SettingsPage.tsx: 1667 lines of code apps/dsa-web/src/pages/SettingsPage.tsx
Large Files · apps/dsa-web/src/pages/ChatPage.tsx: 1481 lines of code apps/dsa-web/src/pages/ChatPage.tsx
Large Files · apps/dsa-web/src/stores/agentChatStore.ts: 543 lines of code apps/dsa-web/src/stores/agentChatStore.ts
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: 208 findings
These 208 critical or serious findings were in the previous survey, on 11 October 2026, and are gone from this one. The first 100 are listed here.
Code Duplication · Duplicated block with local edits (5 matched lines × 2 locations) apps/dsa-web/src/components/run-flow/topologyViewModel.ts
Rebuild cost: about €350,000 · Estimate
Cost to rebuild
€120,000 to €580,000, for 1,928 to 6,115 hours of work, about 2.4 person-years for 1 to 5 engineers
Difficulty of the problem
Standard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor
×0.7 at a score of 44. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
Size
Large: 215,955 lines of product code
How the estimate is made: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Add a text alternative — alt on images (alt="" for purely decorative ones), a title or aria-label on meaningful svg, an aria-label or inner fallback content on canvas, and a captions <track> on video.
Raises the score by about 3 points · Medium effort · Text alternatives
2
Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
Keep a visible focus style (don't remove the outline without a replacement), guard animation with prefers-reduced-motion, and raise low-contrast colour pairs to at least 4.5:1.
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 €350,000 to build again, about 2.4 person-years of work. Its weakest lens is Accessibility, at 33 (Weak). Accessibility is about whether the interface is built so that everyone can use it, including people who can't see the screen or can't use a mouse. Because the weakest lens counts most in the score, work on Accessibility also moves the score most.
Based on: the rebuild estimate · the Accessibility grade · how much each lens counts
What to do: Start with the Accessibility actions in Top priorities.
If you do one thing first · First action
Add a text alternative — alt on images (alt="" for purely decorative ones), a title or aria-label on meaningful svg, an aria-label or inner fallback content on canvas, and a captions <track> on video. Of all the actions in this report, it raises the score most for the work it takes: about 3 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 5.8 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 5% to 12% on every change. The history of the code shows how much it changes: about 131,698 lines over the last 90 days, which is about 534,109 lines a year. At that pace, the extra work comes to an estimated 71.9 to 431.6 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of Watchdog's own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.
Architecture — module dependency graph
Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways — a layering smell or cycle. A clean layered graph has none.
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.
404 modules, with 385 dependencies between them. Every module uses only modules listed above it, so there are no loops.
The table shows the 40 modules with the most connections; 364 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.
apps.dsa-web.src.components.run-flow uses apps.dsa-web.src.types.runFlow, so a change to apps.dsa-web.src.types.runFlow can break apps.dsa-web.src.components.run-flow, while a change to apps.dsa-web.src.components.run-flow can't break apps.dsa-web.src.types.runFlow.
Position
Below the diagonal: apps.dsa-web.src.components.run-flow uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.components.settings uses apps.dsa-web.src.i18n.uiText, so a change to apps.dsa-web.src.i18n.uiText can break apps.dsa-web.src.components.settings, while a change to apps.dsa-web.src.components.settings can't break apps.dsa-web.src.i18n.uiText.
Position
Below the diagonal: apps.dsa-web.src.components.settings uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.components.settings uses apps.dsa-web.src.types.systemConfig, so a change to apps.dsa-web.src.types.systemConfig can break apps.dsa-web.src.components.settings, while a change to apps.dsa-web.src.components.settings can't break apps.dsa-web.src.types.systemConfig.
Position
Below the diagonal: apps.dsa-web.src.components.settings uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.hooks uses apps.dsa-web.src.types.analysis, so a change to apps.dsa-web.src.types.analysis can break apps.dsa-web.src.hooks, while a change to apps.dsa-web.src.hooks can't break apps.dsa-web.src.types.analysis.
Position
Below the diagonal: apps.dsa-web.src.hooks uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.hooks uses apps.dsa-web.src.types.runFlow, so a change to apps.dsa-web.src.types.runFlow can break apps.dsa-web.src.hooks, while a change to apps.dsa-web.src.hooks can't break apps.dsa-web.src.types.runFlow.
Position
Below the diagonal: apps.dsa-web.src.hooks uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.stores uses apps.dsa-web.src.api.error, so a change to apps.dsa-web.src.api.error can break apps.dsa-web.src.stores, while a change to apps.dsa-web.src.stores can't break apps.dsa-web.src.api.error.
Position
Below the diagonal: apps.dsa-web.src.stores uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.stores uses apps.dsa-web.src.types.analysis, so a change to apps.dsa-web.src.types.analysis can break apps.dsa-web.src.stores, while a change to apps.dsa-web.src.stores can't break apps.dsa-web.src.types.analysis.
Position
Below the diagonal: apps.dsa-web.src.stores uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.types.decisionSignals uses apps.dsa-web.src.types.analysis, so a change to apps.dsa-web.src.types.analysis can break apps.dsa-web.src.types.decisionSignals, while a change to apps.dsa-web.src.types.decisionSignals can't break apps.dsa-web.src.types.analysis.
Position
Below the diagonal: apps.dsa-web.src.types.decisionSignals uses a module listed above it, which is the healthy direction.
src.agent.agent_backend uses src.agent.llm_adapter, so a change to src.agent.llm_adapter can break src.agent.agent_backend, while a change to src.agent.agent_backend can't break src.agent.llm_adapter.
Position
Below the diagonal: src.agent.agent_backend uses a module listed above it, which is the healthy direction.
src.agent.agent_backend uses src.agent.tools.registry, so a change to src.agent.tools.registry can break src.agent.agent_backend, while a change to src.agent.agent_backend can't break src.agent.tools.registry.
Position
Below the diagonal: src.agent.agent_backend uses a module listed above it, which is the healthy direction.
src.agent.agents.base_agent uses src.agent.llm_adapter, so a change to src.agent.llm_adapter can break src.agent.agents.base_agent, while a change to src.agent.agents.base_agent can't break src.agent.llm_adapter.
Position
Below the diagonal: src.agent.agents.base_agent uses a module listed above it, which is the healthy direction.
src.agent.agents.base_agent uses src.agent.protocols, so a change to src.agent.protocols can break src.agent.agents.base_agent, while a change to src.agent.agents.base_agent can't break src.agent.protocols.
Position
Below the diagonal: src.agent.agents.base_agent uses a module listed above it, which is the healthy direction.
src.agent.agents.base_agent uses src.agent.tools.registry, so a change to src.agent.tools.registry can break src.agent.agents.base_agent, while a change to src.agent.agents.base_agent can't break src.agent.tools.registry.
Position
Below the diagonal: src.agent.agents.base_agent uses a module listed above it, which is the healthy direction.
src.agent.executor uses src.agent.llm_adapter, so a change to src.agent.llm_adapter can break src.agent.executor, while a change to src.agent.executor can't break src.agent.llm_adapter.
Position
Below the diagonal: src.agent.executor uses a module listed above it, which is the healthy direction.
src.agent.executor uses src.agent.tools.registry, so a change to src.agent.tools.registry can break src.agent.executor, while a change to src.agent.executor can't break src.agent.tools.registry.
Position
Below the diagonal: src.agent.executor uses a module listed above it, which is the healthy direction.
src.agent.orchestrator uses src.agent.llm_adapter, so a change to src.agent.llm_adapter can break src.agent.orchestrator, while a change to src.agent.orchestrator can't break src.agent.llm_adapter.
Position
Below the diagonal: src.agent.orchestrator uses a module listed above it, which is the healthy direction.
src.agent.orchestrator uses src.agent.protocols, so a change to src.agent.protocols can break src.agent.orchestrator, while a change to src.agent.orchestrator can't break src.agent.protocols.
Position
Below the diagonal: src.agent.orchestrator uses a module listed above it, which is the healthy direction.
src.agent.orchestrator uses src.agent.tools.registry, so a change to src.agent.tools.registry can break src.agent.orchestrator, while a change to src.agent.orchestrator can't break src.agent.tools.registry.
Position
Below the diagonal: src.agent.orchestrator uses a module listed above it, which is the healthy direction.
src.agent.tool_surface uses src.agent.tools.execution, so a change to src.agent.tools.execution can break src.agent.tool_surface, while a change to src.agent.tool_surface can't break src.agent.tools.execution.
Position
Below the diagonal: src.agent.tool_surface uses a module listed above it, which is the healthy direction.
src.agent.tool_surface uses src.agent.tools.registry, so a change to src.agent.tools.registry can break src.agent.tool_surface, while a change to src.agent.tool_surface can't break src.agent.tools.registry.
Position
Below the diagonal: src.agent.tool_surface uses a module listed above it, which is the healthy direction.
src.analyzer uses src.llm.generation_backend, so a change to src.llm.generation_backend can break src.analyzer, while a change to src.analyzer can't break src.llm.generation_backend.
Position
Below the diagonal: src.analyzer uses a module listed above it, which is the healthy direction.
src.llm uses src.llm.generation_backend, so a change to src.llm.generation_backend can break src.llm, while a change to src.llm can't break src.llm.generation_backend.
Position
Below the diagonal: src.llm uses a module listed above it, which is the healthy direction.
src.services.alert_service uses src.storage, so a change to src.storage can break src.services.alert_service, while a change to src.services.alert_service can't break src.storage.
Position
Below the diagonal: src.services.alert_service uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.api uses apps.dsa-web.src.api.error, so a change to apps.dsa-web.src.api.error can break apps.dsa-web.src.api, while a change to apps.dsa-web.src.api can't break apps.dsa-web.src.api.error.
Position
Below the diagonal: apps.dsa-web.src.api uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.api uses apps.dsa-web.src.types.systemConfig, so a change to apps.dsa-web.src.types.systemConfig can break apps.dsa-web.src.api, while a change to apps.dsa-web.src.api can't break apps.dsa-web.src.types.systemConfig.
Position
Below the diagonal: apps.dsa-web.src.api uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.api uses apps.dsa-web.src.types.decisionSignals, so a change to apps.dsa-web.src.types.decisionSignals can break apps.dsa-web.src.api, while a change to apps.dsa-web.src.api can't break apps.dsa-web.src.types.decisionSignals.
Position
Below the diagonal: apps.dsa-web.src.api uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.pages uses apps.dsa-web.src.api.error, so a change to apps.dsa-web.src.api.error can break apps.dsa-web.src.pages, while a change to apps.dsa-web.src.pages can't break apps.dsa-web.src.api.error.
Position
Below the diagonal: apps.dsa-web.src.pages uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.pages uses apps.dsa-web.src.i18n.uiText, so a change to apps.dsa-web.src.i18n.uiText can break apps.dsa-web.src.pages, while a change to apps.dsa-web.src.pages can't break apps.dsa-web.src.i18n.uiText.
Position
Below the diagonal: apps.dsa-web.src.pages uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.pages uses apps.dsa-web.src.types.analysis, so a change to apps.dsa-web.src.types.analysis can break apps.dsa-web.src.pages, while a change to apps.dsa-web.src.pages can't break apps.dsa-web.src.types.analysis.
Position
Below the diagonal: apps.dsa-web.src.pages uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.pages uses apps.dsa-web.src.types.systemConfig, so a change to apps.dsa-web.src.types.systemConfig can break apps.dsa-web.src.pages, while a change to apps.dsa-web.src.pages can't break apps.dsa-web.src.types.systemConfig.
Position
Below the diagonal: apps.dsa-web.src.pages uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.pages uses apps.dsa-web.src.types.decisionSignals, so a change to apps.dsa-web.src.types.decisionSignals can break apps.dsa-web.src.pages, while a change to apps.dsa-web.src.pages can't break apps.dsa-web.src.types.decisionSignals.
Position
Below the diagonal: apps.dsa-web.src.pages uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.utils uses apps.dsa-web.src.i18n.uiText, so a change to apps.dsa-web.src.i18n.uiText can break apps.dsa-web.src.utils, while a change to apps.dsa-web.src.utils can't break apps.dsa-web.src.i18n.uiText.
Position
Below the diagonal: apps.dsa-web.src.utils uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.utils uses apps.dsa-web.src.types.analysis, so a change to apps.dsa-web.src.types.analysis can break apps.dsa-web.src.utils, while a change to apps.dsa-web.src.utils can't break apps.dsa-web.src.types.analysis.
Position
Below the diagonal: apps.dsa-web.src.utils uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.utils uses apps.dsa-web.src.types.systemConfig, so a change to apps.dsa-web.src.types.systemConfig can break apps.dsa-web.src.utils, while a change to apps.dsa-web.src.utils can't break apps.dsa-web.src.types.systemConfig.
Position
Below the diagonal: apps.dsa-web.src.utils uses a module listed above it, which is the healthy direction.
apps.dsa-web.src.utils uses apps.dsa-web.src.types.decisionSignals, so a change to apps.dsa-web.src.types.decisionSignals can break apps.dsa-web.src.utils, while a change to apps.dsa-web.src.utils can't break apps.dsa-web.src.types.decisionSignals.
Position
Below the diagonal: apps.dsa-web.src.utils uses a module listed above it, which is the healthy direction.
src.agent uses src.agent.llm_adapter, so a change to src.agent.llm_adapter can break src.agent, while a change to src.agent can't break src.agent.llm_adapter.
Position
Below the diagonal: src.agent uses a module listed above it, which is the healthy direction.
src.agent uses src.agent.protocols, so a change to src.agent.protocols can break src.agent, while a change to src.agent can't break src.agent.protocols.
Position
Below the diagonal: src.agent uses a module listed above it, which is the healthy direction.
src.agent uses src.agent.tools.execution, so a change to src.agent.tools.execution can break src.agent, while a change to src.agent can't break src.agent.tools.execution.
Position
Below the diagonal: src.agent uses a module listed above it, which is the healthy direction.
src.agent uses src.agent.tools.registry, so a change to src.agent.tools.registry can break src.agent, while a change to src.agent can't break src.agent.tools.registry.
Position
Below the diagonal: src.agent uses a module listed above it, which is the healthy direction.
src.agent uses src.agent.tool_surface, so a change to src.agent.tool_surface can break src.agent, while a change to src.agent can't break src.agent.tool_surface.
Position
Below the diagonal: src.agent uses a module listed above it, which is the healthy direction.
src.notification uses src.analyzer, so a change to src.analyzer can break src.notification, while a change to src.notification can't break src.analyzer.
Position
Below the diagonal: src.notification uses a module listed above it, which is the healthy direction.
src.services uses src.llm.generation_backend, so a change to src.llm.generation_backend can break src.services, while a change to src.services can't break src.llm.generation_backend.
Position
Below the diagonal: src.services uses a module listed above it, which is the healthy direction.
src.services.stock_profile_service uses src.services.alert_service, so a change to src.services.alert_service can break src.services.stock_profile_service, while a change to src.services.stock_profile_service can't break src.services.alert_service.
Position
Below the diagonal: src.services.stock_profile_service uses a module listed above it, which is the healthy direction.
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A05:2025 — Injection
116
High / Critical
A03:2025 — Software Supply Chain Failures
48
High / Critical
A02:2025 — Security Misconfiguration
3
High / Critical
A07:2025 — Authentication Failures
2
High / Critical
Roadmap
First, ensure all media elements have appropriate text alternatives to support screen readers. Next, integrate static security analysis into the CI pipeline to prevent regressions from reaching production. Then, improve visual accessibility by maintaining visible focus styles, respecting reduced motion preferences, and fixing low-contrast colors. Finally, make custom controls fully keyboard-operable and enforce accessibility standards through linting and automated testing in the build process.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Add a text alternative — alt on images (alt="" for purely decorative ones), a title or aria-label on meaningful svg, an aria-label or inner fallback content on canvas, and a captions <track> on video.
Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
Keep a visible focus style (don't remove the outline without a replacement), guard animation with prefers-reduced-motion, and raise low-contrast colour pairs to at least 4.5:1.
Pass `timeout=` on every `requests`/`httpx` call (requests has no default and will wait forever), mount an `HTTPAdapter(max_retries=Retry(...))` on shared sessions, and wrap calls to flaky dependencies in `tenacity` retries or a `pybreaker` circuit breaker.
Replace SQLAlchemy create_all() with Alembic (`alembic revision --autogenerate` + `alembic upgrade head`) so the production schema can evolve safely and reproducibly.
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 — 163
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 — 1797
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 — 233
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 11
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. 83 of 86 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 3 documentation/naming judgement(s) are LLM-assisted and labelled advisory. Overall confidence is 0.9 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.
Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.
What we checked — 86 dimensions across the health lenses
Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.
How to trust any code-health report — three questions
Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 2165 of 2193 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
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: this repository's production source spans .ts, .tsx, .py, and our analyzer cannot run the .py test suite(s) — so no coverage was collected for the repository as a whole. The JavaScript/TypeScript half did build and run, and its own line coverage came back at 86.6% — but that is a figure for one half of the product, and we do not publish a partial one as if it were complete. This is OUR limitation, not a defect in the repo — coverage is excluded from the score rather than counted as a near-zero. In the meantime, produce a coverage report in a standard format (lcov — `vitest --coverage`, `jest --coverage`, `bun test --coverage --coverage-reporter=lcov`, or `nyc`, or `coverage run -m pytest` then `coverage xml`) 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 and real coverage will be read. You can widen what we reach: optional: produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) 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 both halves are read on the next scan.
D10 Test Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 1,366 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 304 test source file(s) (.py) that it cannot: it reads JavaScript/TypeScript test declarations off disk, so a JUnit/pytest-style suite is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
D11 Test Reliability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test reliability NOT MEASURED: the JavaScript/TypeScript suite could not be re-run in the analyzer sandbox — the dependency install for apps/dsa-web/ was timed out after 468.6s, so the suite never ran. This is OUR limitation, not a defect in the repo — it is excluded from the score.
D11 Test Reliability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test reliability for the vitest suite in apps/dsa-web/ was NOT MEASURED: the dependency install for apps/dsa-web/ was timed out after 468.6s, so the suite never ran. This is OUR limitation, not a defect in the repository, and the suite is excluded from the measurement rather than counted against it.
D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22 identifies the intentionally-exposed surface from `IsPackable` and `.Contracts` project names, MSBuild conventions read off the loaded project set. This target exposed no such projects, so the probe never ran; this says nothing about whether the repository has a public API. This repository commits no C#/VB source at all, so there was never an MSBuild project set to read these conventions off. That is OUR side and it is an ADMISSION gap, not an environment fault: no published-package marker D22 reads admitted any project here. D22 DOES collect the public API of every language in this tree, and admits a project only when its manifest makes that ecosystem's publication act in a form the marker recognises — so what is missing is not a collector but an admission rule for the publication act this repository makes, if it makes one. The remedy is a better discriminator for that marker — not a collector, and no change to the scan image can close it. The marker's rules are measured to refuse applications, so one refused repository is the rule working as calibrated; several are the evidence that it is too strict. For npm the surface is what a published package.json's entry points (exports, main, module, types) export, followed through the source; an entry that names build output the tree does not commit (dist/, build/) is not followed back to source, because only a tsconfig outDir/rootDir pair states that mapping and a bundler's input lives in executable configuration this engine does not evaluate.
D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
D32 Data Compliance (PII/GDPR) — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `apps/dsa-web/src/components/report/AnalysisContextSummary.tsx` produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
AC2 Forms & labels — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 1 further occurrence(s) are not listed individually; the score already reflects all 41.
AX1 Captive dependencies — 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 Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and this repository defines its own container in src/agent/skills/base.py, whose lifetimes are not modelled 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.
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 DockerCompose (docker/docker-compose.yml). compose up failed (exit 14 — a file the compose project references is missing) — env file .env not found: stat .env: no such file or directory; runtime evidence skipped.
C1 Data Protection — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
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 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 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.
R10 Code Duplication — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 77 further occurrence(s) are not listed individually; the score already reflects all 117.
S1 Web-Security Posture — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
X3 Exception handling — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 95 further occurrence(s) are not listed individually; the score already reflects all 135.
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. 724 further occurrence(s) are not listed individually; the score already reflects all 764.
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.
D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
D13 REDACTED Scanning: REDACTED detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D19 Documentation Quality: Documentation quality is judged by an LLM over a bounded sample of docs — it reads what is written, not whether the docs match the running system, and it is advisory, not a measurement. Its critique rows are drawn from a closed category vocabulary and each row means the same thing in every run, so two scans can be compared row by row; the SET that fires is still a sample, and does not repeat exactly. Measured on one frozen input, six scans at one engine SHA: 2-5 critique rows per scan, 8 distinct rows across the six, 3 of those 8 seen in only one scan. So a D19 row is evidence about the documentation, but a COUNT of D19 rows is not a quantity — never read a change in it as an improvement or a regression.
D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
D21 Naming Consistency: Naming quality is an LLM judgement over a bounded sample — it assesses clarity/consistency of the names it sees, not domain-correctness, and is advisory.
D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
AC1 Text alternatives: Alt-text is detected structurally — the scan sees that an alternative EXISTS, not whether it meaningfully describes the image, and decorative-vs-missing is judged by attribute shape; runtime-injected images and a non-role=img decorative svg are out of scope. This is accessibility readiness, never a WCAG conformance claim.
AC2 Forms & labels: Label association is read from static markup — a label wired up at runtime (JS-set aria-labelledby, framework-injected ids) reads as missing, a present label says nothing about whether its text is correct. A known UI-library field component (e.g. a JSX <TextField>) is now checked conservatively — flagged only when it carries NO label/aria-label/aria-labelledby/id/name — but wrapper/context-labelled libraries (Chakra/Radix FormControl+FormLabel) aren't statically visible (possible false positive) and non-JSX lowercased components are still skipped. A click handler on a plain element is now asked for a name too (it is a control the author declared), but the subtree test that answers it is deliberately generous: any DYNAMIC text expression in the subtree counts as a name, so an icon chosen by a ternary ({cond ? <IconA/> : <IconB/>}) reads as named, and a glyph component from a library the icon-import list does not know still names its parent. A clean result is "no unlabelled control found", not a labelling proof.
AC3 Page structure: Page structure is read from the static markup tree — landmarks, headings and lang injected at runtime aren't seen, heading ORDER is checked structurally (not against the rendered visual hierarchy), and lang/title/main fire only on full documents, never partials, and the data-table check sees header-cell presence (a <th> exists), not whether each header correctly associates with its cells. Static readiness, not conformance.
AC4 Keyboard semantics: Keyboard semantics are inferred from markup attributes — interactivity wired purely in script, focus managed at runtime, and component-level handlers are invisible. A clean result means "no static keyboard-trap shape", not a keyboard-operability proof.
AC5 ARIA correctness: ARIA correctness is checked against the static role/attribute shape — roles/attributes set dynamically aren't seen, a valid role says nothing about whether it matches the element's real behaviour, and required-state checks are suppressed when a JSX spread could supply them. The two-branch toggle check (a control whose state is conveyed only by which of two mutually exclusive branches renders) reads CONDITIONALS THAT ARE ATTRIBUTES — Vue v-if/v-else/v-show and Alpine x-if/x-show — so the same toggle written as a Svelte {#if} block or a JSX ternary is control flow the markup model never projects as a branch and is not seen at all.
AC6 Visual & motion safety: Contrast and motion safety are PARTIAL by construction — literal colours (hex/rgb/hsl/named) in inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS top-level declarations are read (same-rule/same-element colour+background pairs only); computed/runtime/theme colour, external-CDN stylesheets, CSS-in-JS dynamic (${…}) and nested-selector colours, cross-element pairs and image contrast stay out of reach, so a clean result is bounded by what the static CSS itself shows.
AC7 A11y enforcement: Enforcement is scored from in-repo config/CI evidence only — an a11y gate enforced in external tooling with no in-repo trace can't be credited, and a configured linter is presence, not proof the rules actually run or block a merge.
AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
The LLM boundary
LLM-set scores this run (3): D19, D21, M4 (model: Local LLM). For these, a model reads a bounded sample and sets the numeric score; each names its own sample and method on its card. They are sampled and advisory by design: they vary at the margins between runs and are never a deterministic measurement. Every other score in this report is tool-computed at confidence 1.0.
What it measures: How tangled the control flow is — methods with many branches are hard to test and change.
Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.
443 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was PortfolioPage.PortfolioPage at 253. A further 1 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 PortfolioPage.getPortfolioRiskAvailability at 21 — they are counted neither in the figure above nor in this dimension's score.
+ 433 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 20 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with PortfolioPage.PortfolioPage (cyclomatic 253), StockScreeningPage.StockScreeningPage (cyclomatic 251), HomePage.HomePage (cyclomatic 213). — 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 20 together lifts Cyclomatic Complexity from 2.0 to about 4.0/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How hard the code is for a person to follow, beyond raw branching.
Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.
+ 624 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 62 bodies over 60 down to 60 or less in Cognitive Complexity — start with StockScreeningPage.StockScreeningPage (cognitive 358), PortfolioPage.PortfolioPage (cognitive 292), HomePage.HomePage (cognitive 246). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 62 together lifts Cognitive Complexity from 2.0 to about 3.2/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes7.2 / 10Strong✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
Resolve the 83 FileTooLong finding(s) in God Classes — start with pipeline.py (2), system_config_service.py, analyzer.py. — One of this dimension's main actionable groups (83 warning-level).
Resolve the 57 FunctionTooLong finding(s) in God Classes — start with SettingsPage.tsx (3), LLMChannelEditor.tsx (2), agentChatStore.ts (2). — One of this dimension's main actionable groups (57 warning-level).
Resolve the 23 TooManyMethods finding(s) in God Classes — start with system_config_service.py, REDACTED, base.py. — One of this dimension's main actionable groups (23 warning-level).
Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Copy-pasted code that should be shared instead.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.
270 duplicated block group(s) detected. A further 12 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted.
+ 100 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 22 Duplicated block (11 lines × 2) finding(s) in Code Duplication — start with daily.py (3), REDACTED (2), search_service.py (2). — One of this dimension's main actionable groups (22 warning-level).
Resolve the 19 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with scorer.py (3), base.py (2), notification.py (2). — One of this dimension's main actionable groups (19 warning-level).
Resolve the 15 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with analysis_context_pack_overview.py (3), base.py (2), generate_index_from_csv.py (2). — One of this dimension's main actionable groups (15 warning-level).
Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · Coupling0.0 / 10Critical✓ 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.
21 production modules (npm+source-import), 1 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations, and — for the source no manifest declares — its top-level source directories, with the imports between them as edges; 5 module(s) off the main sequence, with abstractness counted on 20 of the 21 (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).
Circular dependency
Off the main sequence: src/patches · ×5
What to do
Resolve the 5 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (5 warning-level).
Resolve the 1 Circular dependency finding(s) in Coupling. — One of this dimension's main actionable groups (1 issue-level).
Enforce Coupling in CI to reach Verified (currently Documented). — 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.
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
D9 · Test Distribution9.9 / 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.
8230 test methods: 8097 unit, 89 integration, 0 BDD, 44 e2e. The JavaScript/TypeScript suite contributes 1366 `it`/`test` case(s) across 118 test file(s) declaring at least one; its tier split is read from package names and paths only. The Python suite contributes 6864 test function(s) across 297 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality9.9 / 10Stronggated by 8 serious findings✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
7 skipped, 0 zero-assertion, 1 synchronised by a fixed sleep, no mocking-framework packages referenced (hand-written doubles or no mocking) across 1366 tests. Measured on the JavaScript/TypeScript suite only — at least 304 test source file(s) (.py) went unread, so its test quality is unmeasured and is not in these counts.
Fixed-sleep synchronisation: createWindow startup path does not throw ReferenceError after restore result handlingapps/dsa-desktop/tests/main.test.js:1336
Mock-dominated test: submits manually when fallback input receives Enter · ×19apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx:308
What to do
Resolve the 19 Mock-dominated test finding(s) in Test Quality — start with HomePage.test.tsx (7), StockAutocomplete.test.tsx (6), useDashboardLifecycle.test.tsx (6). — One of this dimension's main actionable groups (19 recommendation-level).
Resolve the 7 Skipped test finding(s) in Test Quality — start with smoke.spec.ts (2), report-markdown.spec.ts (2), Shell.test.tsx (2). — One of this dimension's main actionable groups (7 warning-level).
Resolve the 1 Fixed-sleep synchronisation finding(s) in Test Quality — start with main.test.js. — One of this dimension's main actionable groups (1 warning-level).
Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether 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.
2 outdated, 0 yanked pinned Python distributions. 2 of 42 shipped distributions were graded against pypi.org (0 not published there, 40 declared without an exact pin, which installs the newest release the declaration admits and so cannot be behind one). Only EXACT pins are graded for currency: a floor or a range already installs the newest release it admits, so reporting one would report this repository for being current. Whether a deliberate upper cap has itself gone stale is a different and weaker question, and is not asked. Whether any distribution is UNMAINTAINED is not graded — PyPI publishes no maintenance status, and release age does not stand in for one. Lockfiles are not read (poetry.lock, uv.lock, Pipfile.lock, pdm.lock), so a lock-resolved install is outside this verdict. Known CVEs in this dependency graph are D30's question.
Outdated: futu-api · ×2
What to do
Enforce Dependency Hygiene in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: Whether the licenses of third-party packages are compatible with your policy.
Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.
0 of 153 shipped Python distribution(s) use a banned license. Licences were resolved from PyPI over the distributions a consumer installs — this repository's 42 declared runtime requirement(s) closed transitively over each distribution's published `requires_dist` (111 reached that way). Requirements it states ONLY under an extra, a PEP 735 dependency group, a Poetry dev group or a dev-named requirements file are excluded: pip does not install any of them for a consumer. ★ This repository commits no dependency lockfile that this pass reads, so each licence is the one PyPI publishes for the distribution's CURRENT release rather than for a pinned version. 14 of them publish no licence on PyPI this pass can read; that is missing data, not a violation, and none of them is charged. A further 1 direct requirement(s) are installed from a URL or a version-control checkout and publish no licence this pass can read; they are outside this verdict.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
Top hotspots: src/config.py (17×130=2210); apps/dsa-web/src/pages/SettingsPage.tsx (9×174=1566); apps/dsa-web/src/pages/HomePage.tsx (6×213=1278)
Hotspot: src/config.py · ×35src/config.py:1492
What to do
Resolve the 35 Hotspot finding(s) in Churn × Complexity Hotspots — start with pipeline.py (2), config.py, SettingsPage.tsx. — One of this dimension's main actionable groups (35 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor8.7 / 10Strong✓ Tool-verified
What it measures: Whether knowledge is concentrated in too few people (the "bus factor").
Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.
58 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is REDACTED. Counted over 422 of the 540 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Off-boarding risk: anonymized user #1 · ×4
Further sole-owners (lower concentration)
What to do
Resolve the 4 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (4 recommendation-level).
Resolve the 1 Further sole-owners (lower concentration) finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.
Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.
0 deducted task-comment markers across 215955 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic doc sample (READMEs plus first 25 architecture docs), with two-pass stability filtering. Advisory, sampled.
This project's documentation is comprehensive and well-organized: the README (in Chinese and English) gives a strong overview of what the system does and how to run it; architecture/design docs are explicitly named and present; there is an extensive FAQ covering data-source failures, model-provider configuration, push-notifications, and LLM integration with detailed solutions and related GitHub issues; a dedicated multi-language documentation index (Chinese/English) lists every document by goal, with navigation anchors for each one; the README also links to full-guide.md, contributing documents, and an INDEX.md that is itself well structured. The only unshown element is the missing architecture doc referenced in the FAQ's Q12 section, which would appear under its own heading. This is a comprehensive documentation set for an AI stock analysis system: the README (3k words) gives a strong overview of what the project does and its featured repositories, with a detailed architecture diagram and a dedicated beginner-client-setup guide. The Tushare stock list fetcher (TUSHARE_STOCK_LIST_GUIDE.md), agent-stream-events, trajectory-eval, real-time alerts, and AnalysisContextPack documents are all well-structured guides for their respective tasks, each carrying its own overview and showing commands to type. The architecture doc is clipped mid-sentence but the outline lists every section present; no missing sections to flag. (9 of 25 sampled documents could not be assessed: 1 of 3 evaluation groups failed.)
Documentation: no project overview · ×3docs/README_CHT.md
✓ On the Gold path — maintain.
Detailed fixes: d19_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.
What it measures: Whether names — types, methods, variables — are clear and consistent.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic random symbol sample (fixed size, not exhaustive), with disclosed confidence band. Advisory, sampled.
2 of 3 build units (Python, npm) flagged as possibly oversized/incoherent.
Projects may be oversized for their cohesion
What to do
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: REDACTED scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.
1 finding(s): 0 critical, 1 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.
REDACTED
REDACTED
What to do
Resolve the 1 REDACTED finding(s) in Secrets (history) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
116 finding(s): 0 critical, 84 high, 15 medium, 17 low. 66 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 26 file(s) — `REDACTED`, `apps/dsa-web/src/components/report/AnalysisContextSummary.tsx` (line 36), `apps/dsa-web/src/components/report/__tests__/MarketStructureCard.test.tsx` (line 109), `apps/dsa-web/src/pages/HomePage.tsx`, `scripts/macos-signature-audit.sh` (line 16), … (+21 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 4 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
+ 12 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 7 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (3), REDACTED (3), REDACTED. — One of this dimension's main actionable groups (7 issue-level).
Resolve the 5 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (5 issue-level).
No action in Static Analysis (SAST) — all 66 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (66 issue-level, 0 of them charged here).
Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.
Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over 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.
+ 1 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 29 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (28), REDACTED. — One of this dimension's main actionable groups (29 issue-level).
Resolve the 1 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 1 High vulnerability 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.
Resolve the 1 High IaC finding(s) in IaC & Container Security — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 2 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (2). — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.
Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.
37 of 422 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is src/agent/skills/deliberation.py. Counted over 422 of the 540 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Resolve the 1 Orphaned knowledge finding(s) in Knowledge Freshness — start with deliberation.py. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 36 Orphaned file finding(s) in Knowledge Freshness — start with base.py (2), portfolio.py, social_sentiment_service.py. — One of this dimension's main actionable groups (36 recommendation-level).
Resolve the 1 Further orphaned files (smaller) finding(s) in Knowledge Freshness. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Resolve the 10 Change coupling finding(s) in Change Coupling — start with systemConfig.ts (3), router.py (2), HomePage.tsx. — One of this dimension's main actionable groups (10 warning-level).
Resolve the 3 Change-coupling hub finding(s) in Change Coupling — start with portfolio_service.py, market.py, system_config.py. — One of this dimension's main actionable groups (3 warning-level).
Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.
Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.
+ 1 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Scored apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.
Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. SCORED, not informational.
What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.
Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.
0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 42 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.
✓ On the Gold path — maintain.
Detailed fixes: d44_recommendation.md.
Do you agree with this assessment?
Frontend & cross-cutting dimensions
R = React/JS · M = Maturity · P = Readiness.
AC1 · Text alternatives1.0 / 10Critical✓ Tool-verified
Other · Accessibility — Whether non-text content carries a text alternative — img/area/input[type=image] have alt, a meaningful svg has a title or aria-label, video has a captions track, and object/embed/canvas have a name or fallback content. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: every img/area/input[type=image] checked for alt, svg[role=img] for a title/aria-label, video for a captions <track>. Components skipped, spreads suppressed. Deterministic, hard fact per element.
Coverage: Population: image/media elements — img, area, input[type=image], svg, video, object, embed, canvas — across the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and dynamic-attribute elements are skipped. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is NOT read by any producer, so it contributes no element to this population; where such a frontend is present the card discloses it as an analyzer gap rather than scoring around it.
A <canvas> with no aria-label/title and no inner fallback content can't be described by assistive tech. Add a name or fallback content. — apps/dsa-web/src/components/common/ParticleBackground.tsx:152
What to do
Add a text alternative — alt on images (alt="" for purely decorative ones), a title or aria-label on meaningful svg, an aria-label or inner fallback content on canvas, and a captions <track> on video.
Do you agree with this assessment?
AC2 · Forms & labels5.1 / 10Adequate✓ Tool-verified
Other · Accessibility — Whether form controls have a programmatic label (an associated label, aria-label or aria-labelledby), buttons have text, links have an accessible name, a click handler on a plain element names the control it declares, fieldsets have a non-empty legend, known UI-library field components carry a label prop, and a placeholder isn't used as the only label. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: inputs/selects/textareas checked for an associated label[for]/wrapping label/aria-label/aria-labelledby (per document), buttons for accessible text, fieldsets for a legend; placeholder-only labelling flagged. Deterministic, hard fact per control.
Coverage: Population: form controls, buttons, links, fieldsets and known UI-library field components in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and spread/dynamic-attribute elements are skipped, so a control whose label arrives through a spread or a runtime expression is deliberately not judged. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it. (×21) — apps/dsa-web/src/components/history/HistoryListItem.tsx:47, apps/dsa-web/src/components/history/StockBar.tsx:167, apps/dsa-web/src/components/settings/IntelligentImport.tsx:408, …
This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label. (×18) — apps/dsa-web/src/components/settings/IntelligentImport.tsx:345, apps/dsa-web/src/pages/BacktestPage.tsx:443, apps/dsa-web/src/pages/BacktestPage.tsx:463, …
This UI-library field component is named only by a placeholder — a placeholder is not a label (it vanishes as soon as the user types, and many assistive technologies ignore it). Give it a real name whichever way this library supports: a label prop, an aria-label, or an id on the rendered control with a <label htmlFor> pointing at it. For a group of controls, name the group itself (aria-label, or a fieldset with a legend) — labelling each item leaves the set unnamed. — apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2415
What to do
Give every control a programmatic label (a <label for> / wrapping <label> / aria-label) and every button text — a placeholder is not a label.
Do you agree with this assessment?
AC3 · Page structure7.2 / 10Strong✓ Tool-verified
Other · Accessibility — Whether pages declare a language (well-formed BCP-47) and a non-empty title, expose exactly one main landmark and a sane heading order with non-empty headings, keep zoom enabled, title their iframes, give data tables header cells, and avoid meta-refresh. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: html lang, document <title>, a main landmark and heading order on full documents only, plus zoom-disabling viewports, untitled iframes and meta-refresh anywhere. Deterministic, per structural checkpoint.
Coverage: Population: the PARSED MARKUP documents (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx). The page-level checks — lang, title, single main landmark — fire ONCE PER FULL DOCUMENT (an <html> root) and never on a partial or component fragment, so a repo of fragments is assessed only on the per-element checks (heading order, table headers, iframe titles, meta-refresh, zoom). Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>. — apps/dsa-desktop/renderer/loading.html:2
Skipping heading levels breaks the document outline assistive tech relies on. Don't jump levels — increase by at most one. — apps/dsa-web/src/components/report/ReportOverview.tsx:334
What to do
Declare <html lang>, a document <title> and a <main> landmark, keep headings in order, leave zoom enabled, title iframes and drop meta-refresh.
Other · Accessibility — Whether interactive behaviour is keyboard-reachable — no click handler on a non-interactive element lacking a role, tabindex and key handler, no element the repo's own CSS styles `cursor: pointer` without giving it any of the three, no unfocusable element whose only binding is a mouse enter/leave pair or a double-click, no positive tabindex, no href-less anchor, no placeholder-href (#/javascript) link acting as a button. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: click handlers on non-interactive elements lacking role+tabindex+key handler, positive tabindex values, and href-less anchors. Components skipped, spreads suppressed. Deterministic, hard fact per element.
Coverage: Population: elements that pose a keyboard-semantics question, in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) — a non-natively-interactive element carrying a click handler, a double-click or hover enter/leave binding, a pointer-only gesture on a tabindex="0" element, or `cursor: pointer` from the repo's own CSS; an href-less or placeholder-href (#, javascript:) anchor; and any element with a positive tabindex. Natively interactive elements used correctly (<button>, <a href>, form controls) are NOT in the population — there is nothing to judge — so a page of nothing but correct controls gives AC4 nothing to measure. Keyboard reachability is judged from the markup, never from a rendered page. ★ An interactive element declared in a tagged-template (html`…`) or hyperscript frontend is NOT in this population — no producer reads either — so an empty population is reported as an analyzer gap, never as "this repository has no interactive elements".
This <li> announces itself as a role="option" and binds a click, but nothing can put focus on it: no tabIndex={0} in any spelling, no key handler, and nothing in this file moves focus or sets aria-activedescendant. The role tells assistive tech what the control IS; it does not make the control reachable, so a keyboard user cannot operate it at all (WCAG 2.1.1). Give it tabIndex={0}="0" and an Enter/Space key handler, or make it a native <button>. If a parent widget owns the keyboard model, that parent must move focus onto the active role="option" or point aria-activedescendant at it. — apps/dsa-web/src/components/StockAutocomplete/SuggestionsList.tsx:47
This <div role="dialog"> is a modal dialog, but nothing moves focus into it when it opens and nothing keeps focus inside it while it is open, so a keyboard or screen-reader user keeps acting on the content behind it (WCAG 2.4.3). Use a native <dialog> opened with showModal(), a dialog component that traps focus, or move focus to the dialog on open, trap Tab inside it (or make the page behind inert) and return focus to the control that opened it on close. (×2) — apps/dsa-web/src/components/common/Drawer.tsx:79, apps/dsa-web/src/components/layout/DesktopUpdateIndicator.tsx:101
A click handler on a plain element isn't keyboard-operable. Use a <button>, or add role + tabIndex={0} + a key handler. — apps/dsa-web/src/components/history/StockHistoryTrendDrawer.tsx:328
This <div role="dialog"> is a modal dialog, but focus is moved into it, but nothing keeps it there: Tab walks out to the page behind, so a keyboard or screen-reader user keeps acting on the content behind it (WCAG 2.4.3). Use a native <dialog> opened with showModal(), a dialog component that traps focus, or move focus to the dialog on open, trap Tab inside it (or make the page behind inert) and return focus to the control that opened it on close. — apps/dsa-web/src/components/market-review/MarketReviewRegionSelector.tsx:122
A click handler on a plain element with no role and no tabindex: even where another element's key handler can reach it, assistive tech can neither focus it nor announce what it is. Use a <button>, or add role + tabIndex={0}. (×2) — apps/dsa-web/src/pages/ChatPage.tsx:909, apps/dsa-web/src/pages/HomePage.tsx:1712
What to do
Make custom controls keyboard-operable (role + tabindex + key handler), drop positive tabindex, and give anchors a real href.
Other · Accessibility — Whether ARIA is used correctly — valid non-abstract roles, the ARIA state a role requires, valid (non-misspelled) aria-* attribute names, in-enum values for token-typed aria-* attributes, and no aria-hidden on (or wrapping) a focusable element. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: role values checked against the WAI-ARIA role set (abstract/invalid flagged), required ARIA state for a role, and aria-hidden on a focusable element. Deterministic, role/attribute level.
Coverage: Population: elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) that carry a role or an aria-* attribute; roles and token values are checked against the ARIA enums exhaustively within that set. An expression-valued (dynamic) role or aria-* value is skipped rather than guessed, and markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
Other · Accessibility — Whether focus outlines aren't removed without a replacement, motion respects prefers-reduced-motion, and literal CSS colour pairs meet contrast — PARTIAL: inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS literals are read (hex/rgb/hsl/named), never computed/runtime/external-CDN colour. Static markup readiness, not a WCAG conformance claim.
Method: Static markup/CSS scan: inline outline:none/0, literal inline colour/background contrast against the 4.5:1 AA floor, and <style>-block animation without a prefers-reduced-motion guard. Deterministic but PARTIAL — only inline styles and in-repo CSS literals are visible.
Coverage: Population: styled elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx), plus in-repo <style> blocks, in-repo .css files and CSS-in-JS literals. Colour contrast is computed from LITERAL colour pairs only (hex/rgb/hsl/named, including var() tokens and Tailwind neutral utilities) — computed, runtime-themed and external-CDN colour is never resolved, so this is a partial read of contrast by construction. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
`.dot` moves (`animation: pulse 1.5s ease-in-out infinite`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-desktop/renderer/loading.html:98
<div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:. (×9) — apps/dsa-web/src/components/StockAutocomplete/StockAutocomplete.tsx:288, apps/dsa-web/src/components/dashboard/DashboardStateBlock.tsx:40, apps/dsa-web/src/components/history/HistoryList.tsx:188, …
<svg> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:. (×5) — apps/dsa-web/src/components/common/Button.tsx:78, apps/dsa-web/src/components/common/Loading.tsx:15, apps/dsa-web/src/pages/BacktestPage.tsx:537, …
<input> takes keyboard focus, and its outline-none utility removes the focus ring with no focus-state ring, shadow, border or outline utility in its place. Add one (e.g. focus-visible:ring-2). — apps/dsa-web/src/components/common/Input.tsx:135
<span> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:. — apps/dsa-web/src/components/report/ReportDiagnostics.tsx:320
<div> moves — its `animate-[shimmer_1.5s_infinite]` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:. — REDACTED:245
`.input-surface` moves (`transition: border-color 0.2s ease,
box-shadow 0.2s ease,
transform 0.2s ease,
color 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:712
`.animate-fade-in` moves (`animation: fadeIn 0.3s ease-out`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:934
`.animate-slide-up` moves (`animation: slideUp 0.4s ease-out`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:938
`.animate-slide-in-right` moves (`animation: slideInRight 0.3s ease-out`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:942
`.animate-spin` moves (`animation: spin 1s linear infinite`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:950
`.fade-in` moves (`animation-name: fadeIn`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:968
`.zoom-in` moves (`animation-name: zoomIn`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:972
`.slide-in-from-top-1` moves (`animation-name: slideInFromTopSm`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:976
`.slide-in-from-top-2` moves (`animation-name: slideInFromTopMd`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:980
`.slide-in-from-bottom-2` moves (`animation-name: slideInFromBottomMd`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:984
`.terminal-card-hover` moves (`transition: transform 0.24s ease,
box-shadow 0.24s ease,
border-color 0.24s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:1143
`.home-subpanel` moves (`transition: border-color 0.2s ease,
background-color 0.2s ease,
box-shadow 0.2s ease,
transform 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:1326
`.home-history-item` moves (`transition: border-color 0.2s ease,
background-color 0.2s ease,
box-shadow 0.2s ease,
transform 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:1349
`.chat-copy-btn` moves (`transition: transform 0.15s ease, background-color 0.15s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:1479
`.chat-skill-checkbox` moves (`transition: border-color 0.2s ease,
background-color 0.2s ease,
box-shadow 0.2s ease,
transform 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:1534
`.btn-primary` moves (`transition: transform 0.2s ease,
box-shadow 0.2s ease,
border-color 0.2s ease,
background 0.2s ease,
color 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:1983
`.animate-slide-in-left` moves (`animation: slideInLeft 0.3s ease-out`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:2245
`.skill-desc-tooltip` moves (`animation: fadeIn 0.2s ease-out`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:2466
`.session-item` moves (`transition: border-color 0.2s ease,
background-color 0.2s ease,
box-shadow 0.2s ease,
transform 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:2494
`.backtest-spinner` moves (`animation: spin 1s linear infinite`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — apps/dsa-web/src/index.css:2747
What to do
Keep a visible focus style (don't remove the outline without a replacement), guard animation with prefers-reduced-motion, and raise low-contrast colour pairs to at least 4.5:1.
Do you agree with this assessment?
AC7 · A11y enforcement4.0 / 10Weak✓ Tool-verified
Other · Accessibility — Whether accessibility is ENFORCED in the toolchain — an accessibility checker configured over the markup (an a11y lint rule set, e.g. eslint-plugin-jsx-a11y or vuejs-accessibility where the project lints JavaScript) and an automated accessibility assertion wired into tests or CI (axe/pa11y/Lighthouse or an equivalent) — on the Documented→Verified→Prevented ladder.
Method: Repo config/CI scan: an accessibility checker configured over the markup (an a11y lint rule set such as eslint-plugin-jsx-a11y / vuejs-accessibility where JavaScript is linted) and an automated accessibility assertion in tests or CI (axe/pa11y/Lighthouse or equivalent), graded on the Documented→Verified→Prevented rungs. Deterministic, presence/rung detection.
Coverage: Population: the repository's own tooling configuration — lint config, test and CI files — NOT the markup. It is read for a configured accessibility checker and an automated accessibility assertion (axe/pa11y/Lighthouse, or a native-toolkit equivalent), and it credits an INVOCATION, never a mention: a licence filename, an import comment or a doc reference earns no rung. Enforcement configured entirely outside the repository leaves no evidence here and cannot be credited.
No accessibility enforcement found — no a11y linter (eslint-plugin-jsx-a11y) and no axe/pa11y/Lighthouse in tests or CI. Start with the linter to catch issues at author time. What was searched, so you can tell an absence from a miss: the 105 markup file(s) this pass actually assessed, the linter configuration checked in beside them, and this repository's test and CI files — matched by name against the accessibility checkers this dimension carries. An audit run outside the repository, a hosted scanner, or a check whose name is not one of those, is not seen here.
What to do
Enforce accessibility in the toolchain: add eslint-plugin-jsx-a11y, then assert with vitest-axe in tests, then gate axe/pa11y/Lighthouse in CI.
Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.
Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.
Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.
What to do
The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
Other · Architecture — Whether singleton services avoid mutable shared instance state that concurrent callers would race on.
Method: Roslyn scan: singleton field mutations unguarded by lock or Interlocked, per type; syntax-based guard detection. Deterministic, traceable per field.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
The projects (root) → api → src/services → (root) (one cycle inside a mutually-dependent group of 14 projects) form a reference cycle. Cyclic dependencies prevent independent build/test/deploy, blur ownership, and tend to grow into a big ball of mud. Break the cycle by extracting the shared types into a separate project both can reference.
What to do
Break project reference cycles by extracting shared abstractions into a separate project; keep the graph a DAG.
Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.
Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.
Other · Architecture — Whether interfaces stay focused rather than fat — the Interface-Segregation principle (SOLID 'I').
Method: Roslyn scan: public interface declared-member counts (accessors fold into their property/event); fat-interface threshold (over 15 declared members) flagged per type. Each finding also reports the distinct-OPERATION count — members counted by name, so an overload group counts once — which decides whether it states the caller-side ISP harm or the implementer-side burden of an overload set. TypeScript: exported interfaces that declare behaviour, counted over their REQUIRED operations (method signatures and function-typed properties with no `?`, once per signature) — data-shape interfaces and ambient .d.ts declarations are outside the population; JavaScript declares no interfaces and is not applicable. Deterministic, type-level.
`StockPoolState` declares 33 required operations: `setQuery`, `clearError`, `clearInlineMessages`, `openMarkdownDrawer`, `closeMarkdownDrawer`, `openHistoryTrend`, `closeHistoryTrend`, `setStockHistoryRange`, `loadMoreStockHistory`, `loadInitialHistory`, `refreshHistory`, `refreshHistoryForCompletedTask`, `loadMoreHistory`, `loadMarketReviewHistory`, `refreshMarketReviewHistory`, `loadMoreMarketReviewHistory`, `selectHistoryItem`, `toggleHistorySelection`, `toggleSelectAllVisible`, `deleteSelectedHistory`, `toggleMarketReviewHistorySelection`, `toggleSelectAllVisibleMarketReviewHistory`, `deleteSelectedMarketReviewHistory`, `submitAnalysis`, `setNotify`, `syncTaskCreated`, `syncTaskUpdated`, `syncTaskFailed`, `refreshActiveTasks`, `removeTask`, `resetDashboardState`, `loadStockBar`, `refreshStockBar`. Counted over its REQUIRED operations — a method signature or a function-typed property with no `?`, once per signature; optional members and data properties are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — apps/dsa-web/src/stores/stockPoolStore.ts:55
What to do
Split fat interfaces into focused role-interfaces so clients depend only on what they use.
Do you agree with this assessment?
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.
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.
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
Add a build/run (quick start) section to the root README — the first thing a newcomer needs.
Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
Add a README to the 2 of 2 project(s) that lack one — worth up to 2 pts.
Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.
Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.
No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
What to do
Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).
Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.
docs/DEPLOY.md runs `docker-compose -f ./docker/docker-compose.yml logs -f --tail=100`, but `--tail=100` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/DEPLOY.md:273
docs/DEPLOY_EN.md runs `docker-compose -f ./docker/docker-compose.yml logs -f --tail=100`, but `--tail=100` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/DEPLOY_EN.md:261
docs/full-guide.md runs `docker-compose -f ./docker/docker-compose.yml logs -f server`, but `server` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/full-guide.md:548
docs/full-guide.md names `src/report.py`, but no file or folder `src/report.py` exists. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/full-guide.md:1532
docs/full-guide_EN.md runs `docker-compose -f ./docker/docker-compose.yml logs -f server`, but `server` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/full-guide_EN.md:492
docs/openclaw-skill-integration.md documents the environment variable `DSA_BASE_URL`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/openclaw-skill-integration.md:107
What to do
Reconcile the README with reality: docs/DEPLOY.md runs `docker-compose -f ./docker/docker-compose.yml logs -f --tail=100`, but `--tail=100` does not exist; docs/DEPLOY_EN.md runs `docker-compose -f ./docker/docker-compose.yml logs -f --tail=100`, but `--tail=100` does not exist; docs/full-guide.md runs `docker-compose -f ./docker/docker-compose.yml logs -f server`, but `server` does not exist; docs/full-guide.md names `src/report.py`, but no file or folder `src/report.py` exists; docs/full-guide_EN.md runs `docker-compose -f ./docker/docker-compose.yml logs -f server`, but `server` does not exist.
Only 1/2 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `apps/dsa-desktop`.
What to do
Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
Add OpenTelemetry tracing/metrics (opentelemetry-sdk) so requests are traceable across the system, not just health-probable.
Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).
Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.
No static application security testing detected. For this repository's stack, add bandit, `semgrep --config=p/python`, or CodeQL's python pack as a CI step. What was searched, so you can tell an absence from a miss: the 86816 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
What to do
Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
Enable Dependabot/Renovate or a dependency-review gate.
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.
Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.
Readiness · 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.
`requests.post(` 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. — src/notification_sender/discord_sender.py:227
What to do
Pass `timeout=` on every `requests`/`httpx` call (requests has no default and will wait forever), mount an `HTTPAdapter(max_retries=Retry(...))` on shared sessions, and wrap calls to flaky dependencies in `tenacity` retries or a `pybreaker` circuit breaker.
Do you agree with this assessment?
P8 · Schema migrations3.0 / 10Weak✓ Tool-verified
Readiness · Readiness — Whether database schema changes go through versioned migrations rather than being auto-created from the model at startup.
Method: Roslyn scan: EF Core DbContext for a versioned migrations directory versus bare EnsureCreated usage; off .NET, a file scan of dependency manifests, migration histories (Flyway, Liquibase, Alembic, Django, Rails, Prisma, TypeORM, Knex/Sequelize, golang-migrate, goose, Laravel, Doctrine, Diesel/sqlx) and schema auto-create in production source or config. Exhaustive, deterministic.
SQLAlchemy create_all() builds the schema from the model at startup and keeps no migration history, so there is no reviewed, repeatable upgrade path for an existing production database — a renamed column is dropped and re-added rather than migrated. Adopt Alembic (`alembic revision --autogenerate` + `alembic upgrade head`), so every schema change is a versioned file applied the same way in every environment. — REDACTED:1403
What to do
Replace SQLAlchemy create_all() with Alembic (`alembic revision --autogenerate` + `alembic upgrade head`) so the production schema can evolve safely and reproducibly.
Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.
Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from the language model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.
Do you agree with this assessment?
R1 · Type Safety9.8 / 10Exemplary✓ Tool-verified
React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.
Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.
What to do
Migrate the remaining .js/.jsx files to TypeScript.
React / JS · Code Health — Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm over JS/TS tokens, D-386): a block is reported only where its copies still agree on most of their own identifiers and literals, or were renamed as they were pasted but kept most of their constants, and where the copies carry enough code to stand on their own or the copied extent reaches 30 lines — so a re-implementation sharing neither names nor values, and a small pasted declaration, are both found and deliberately not reported, and a clean R10 is not a claim that nothing was copied.
Method: Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm run over JS/TS tokens). Masking finds the candidates; a block is reported when its copies still agree on most of their own identifiers and literals, or when a renamed copy still agrees on most of its constants, AND the copies carry enough code to stand on their own — or when the copied extent reaches 30 lines. So a re-implementation sharing neither names nor values, and a small pasted declaration, are deliberately not counted. Deterministic.
31 duplicated blocks under apps/dsa-web/src/ have copies in at least two of the sibling directories api, components, contexts, hooks, pages, stores (+1 more sibling(s) not listed) — 15 of them are reported below, and 16 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 31 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 31 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 31 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — apps/dsa-web/src/components/alerts/AlertTriggerHistory.tsx:52
7 duplicated blocks under apps/dsa-web/src/components/ have copies in at least two of the sibling directories StockAutocomplete, alerts, common, history, i18n, layout (+3 more sibling(s) not listed) — 3 of them are reported below, and 4 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 7 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 7 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 7 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — apps/dsa-web/src/components/common/PageHeader.tsx:12
apps/dsa-web/src/components/history/HistoryList.tsx:105 · apps/dsa-web/src/components/history/StockBar.tsx:88 — the two spans are one implementation copied and then locally edited — 339 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — apps/dsa-web/src/components/history/HistoryList.tsx:105
apps/dsa-web/src/components/history/HistoryListItem.tsx:55 · apps/dsa-web/src/components/history/StockBarItem.tsx:46 — the two spans are one implementation copied and then locally edited — 241 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — apps/dsa-web/src/components/history/HistoryListItem.tsx:55
apps/dsa-web/src/stores/stockPoolStore.ts:761 · apps/dsa-web/src/stores/stockPoolStore.ts:824 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/stores/stockPoolStore.ts:761
apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:361 · apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:413 — the two spans are one implementation copied and then locally edited — 263 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:361
apps/dsa-web/src/stores/stockPoolStore.ts:477 · apps/dsa-web/src/stores/stockPoolStore.ts:556 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — apps/dsa-web/src/stores/stockPoolStore.ts:477
apps/dsa-web/src/components/alerts/AlertTriggerHistory.tsx:52 · apps/dsa-web/src/pages/AlertsPage.tsx:334 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/alerts/AlertTriggerHistory.tsx:52
apps/dsa-web/src/components/settings/AgentBackendStatusPanel.tsx:69 · apps/dsa-web/src/components/settings/GenerationBackendStatusPanel.tsx:105 — the two spans are one implementation copied and then locally edited — 125 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — apps/dsa-web/src/components/settings/AgentBackendStatusPanel.tsx:69
apps/dsa-web/src/stores/stockPoolStore.ts:1071 · apps/dsa-web/src/stores/stockPoolStore.ts:1095 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — apps/dsa-web/src/stores/stockPoolStore.ts:1071
apps/dsa-web/src/components/report/ReportDetails.tsx:114 · apps/dsa-web/src/components/report/ReportDetails.tsx:140 — all 2 copies are in the same file, and the CITED SPAN is a run of DECLARATIONS inside a construct — the members of a type, or the entries of an object or array literal — with no statement anywhere in it. Do not read this as an extract-a-helper row: nothing here executes, so there is no call site, and a call expression cannot stand where a member declaration or a literal's entry was. What repeats is a SHAPE, and which shape decides the move. Where the copies declare the same members, the repetition is a missing common ancestor: give it a base type, an interface both extend, a generic instantiated twice, or — where the copies are a literal's entries rather than a type's members — one shared constant each site spreads or refers to, so the set is written once. Where they declare DIFFERENT members and only the form is shared — a decorator and its options, an annotation, a registration table's keys — the form is prescribed by a framework or a schema rather than copied, and the only collapse available is to generate the declarations from that schema; where you do not own the generator, this is the cost of the framework and there is nothing to extract. Check which of the two it is before acting: these copies still drift apart the first time only one of them is edited, which is why the repetition is reported, but the sentence to act on is not the same in both cases. — apps/dsa-web/src/components/report/ReportDetails.tsx:114
apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:105 · apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:126 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:105
apps/dsa-web/src/api/backtest.ts:78 · apps/dsa-web/src/api/backtest.ts:107 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/api/backtest.ts:78
apps/dsa-web/src/components/i18n/UiLanguageToggle.tsx:8 · apps/dsa-web/src/components/theme/ThemeToggle.tsx:33 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/i18n/UiLanguageToggle.tsx:8
apps/dsa-web/src/components/report/MarketReviewReportView.tsx:514 · apps/dsa-web/src/components/report/MarketReviewReportView.tsx:533 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/report/MarketReviewReportView.tsx:514
apps/dsa-web/src/pages/ChatPage.tsx:800 · apps/dsa-web/src/pages/ChatPage.tsx:941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — apps/dsa-web/src/pages/ChatPage.tsx:800
apps/dsa-web/src/components/decision-signals/DecisionSignalProfileCalibration.tsx:161 · apps/dsa-web/src/components/decision-signals/DecisionSignalProfileCalibration.tsx:226 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/decision-signals/DecisionSignalProfileCalibration.tsx:161
apps/dsa-web/src/components/common/SectionCard.tsx:4 · apps/dsa-web/src/components/settings/SettingsSectionCard.tsx:4 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/common/SectionCard.tsx:4
apps/dsa-web/src/components/history/HistoryListItem.tsx:29 · apps/dsa-web/src/components/history/StockBarItem.tsx:30 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. — apps/dsa-web/src/components/history/HistoryListItem.tsx:29
apps/dsa-web/src/components/report/ReportDetails.tsx:50 · apps/dsa-web/src/pages/ChatPage.tsx:641 — the two spans are one implementation copied and then locally edited — 82 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — apps/dsa-web/src/components/report/ReportDetails.tsx:50
apps/dsa-web/src/components/settings/IntelligentImport.tsx:310 · apps/dsa-web/src/components/settings/IntelligentImport.tsx: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. — apps/dsa-web/src/components/settings/IntelligentImport.tsx:310
apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:595 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:627 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:669 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:711 — all 4 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:595
apps/dsa-web/src/components/report/ReportMarkdown.tsx:7 · apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:11 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/report/ReportMarkdown.tsx:7
apps/dsa-web/src/components/report/ReportNews.tsx:156 · apps/dsa-web/src/pages/ChatPage.tsx:871 — the two spans are one implementation copied and then locally edited — 54 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — apps/dsa-web/src/components/report/ReportNews.tsx:156
apps/dsa-web/src/hooks/useWatchlist.ts:70 · apps/dsa-web/src/hooks/useWatchlist.ts:86 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/hooks/useWatchlist.ts:70
apps/dsa-web/src/pages/HomePage.tsx:1777 · apps/dsa-web/src/pages/HomePage.tsx:1823 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/pages/HomePage.tsx:1777
apps/dsa-web/src/pages/PortfolioPage.tsx:1113 · apps/dsa-web/src/pages/PortfolioPage.tsx:1136 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/pages/PortfolioPage.tsx:1113
apps/dsa-web/src/components/report/ReportMarkdownDrawer.tsx:67 · apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:157 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/components/report/ReportMarkdownDrawer.tsx:67
apps/dsa-web/src/pages/BacktestPage.tsx:528 · apps/dsa-web/src/pages/HomePage.tsx:1627 — the two spans are one implementation copied and then locally edited — 74 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — apps/dsa-web/src/pages/BacktestPage.tsx:528
apps/dsa-web/src/pages/PortfolioPage.tsx:1090 · apps/dsa-web/src/pages/PortfolioPage.tsx:1117 · apps/dsa-web/src/pages/PortfolioPage.tsx:1140 — all 3 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/pages/PortfolioPage.tsx:1090
apps/dsa-web/src/pages/StockScreeningPage.tsx:75 · apps/dsa-web/src/pages/StockScreeningPage.tsx:774 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/pages/StockScreeningPage.tsx:75
apps/dsa-web/src/pages/StockScreeningPage.tsx:2087 · apps/dsa-web/src/pages/StockScreeningPage.tsx:2101 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/pages/StockScreeningPage.tsx:2087
apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:571 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:593 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:625 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:645 · +3 more site(s) not listed — all 7 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:571
apps/dsa-web/src/components/common/EmptyState.tsx:7 · apps/dsa-web/src/components/common/PageHeader.tsx:7 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/components/common/EmptyState.tsx:7
apps/dsa-web/src/components/settings/AuthSettingsCard.tsx:160 · apps/dsa-web/src/components/settings/AuthSettingsCard.tsx:173 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — apps/dsa-web/src/components/settings/AuthSettingsCard.tsx:160
apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2187 · apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2281 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2187
apps/dsa-web/src/pages/PortfolioPage.tsx:819 · apps/dsa-web/src/pages/PortfolioPage.tsx:833 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/pages/PortfolioPage.tsx:819
apps/dsa-web/src/components/common/Select.tsx:72 · apps/dsa-web/src/pages/ChatPage.tsx:802 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another. — apps/dsa-web/src/components/common/Select.tsx:72
apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:338 · apps/dsa-web/src/components/report/ReportDiagnostics.tsx:305 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. — apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:338
apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2142 · apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2300 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2142
What to do
Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
React / JS · Code Health — Per-function cyclomatic/cognitive complexity from the token-level function scanner (D-386) — real branching, not a regex heuristic.
Method: Per-function cyclomatic/cognitive complexity from a token-level function scanner (real branching, not a regex heuristic), computed over every frontend function. Deterministic.
SettingsPage has cyclomatic complexity 119 and cognitive complexity 101; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/SettingsPage.tsx:688
PortfolioPage has cyclomatic complexity 113 and cognitive complexity 106; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/PortfolioPage.tsx:624
StockScreeningPage has cyclomatic complexity 101 and cognitive complexity 95; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/StockScreeningPage.tsx:841
ChatPage has cyclomatic complexity 63 and cognitive complexity 59; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/ChatPage.tsx:83
ChannelRow has cyclomatic complexity 59 and cognitive complexity 57; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:399
renderReassessPanel has cyclomatic complexity 53 and cognitive complexity 49; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/DecisionSignalsPage.tsx:966
DecisionSignalsPage has cyclomatic complexity 46 and cognitive complexity 43; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/DecisionSignalsPage.tsx:388
HomePage has cyclomatic complexity 43 and cognitive complexity 40; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/HomePage.tsx:252
buildExposureRows has cyclomatic complexity 41 and cognitive complexity 57; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/PortfolioPage.tsx:372
(anonymous) has cyclomatic complexity 41 and cognitive complexity 25; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/utils/decisionAction.ts:94
formatParameters has cyclomatic complexity 39 and cognitive complexity 42; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/components/alerts/AlertRuleList.tsx:30
normalizeStockCode has cyclomatic complexity 36 and cognitive complexity 41; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/utils/stockCode.ts:16
parseApiError has cyclomatic complexity 36 and cognitive complexity 34; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/api/error.ts:310
startStream has cyclomatic complexity 34 and cognitive complexity 44; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/stores/agentChatStore.ts:349
decodeChatState has cyclomatic complexity 34 and cognitive complexity 33; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/api/agent.ts:60
Input has cyclomatic complexity 33 and cognitive complexity 30; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/components/common/Input.tsx:25
buildPortfolioRiskFlags has cyclomatic complexity 32 and cognitive complexity 30; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/pages/PortfolioPage.tsx:444
DesktopUpdateIndicator has cyclomatic complexity 32 and cognitive complexity 28; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/components/layout/DesktopUpdateIndicator.tsx:12
MarketReviewReportView has cyclomatic complexity 32 and cognitive complexity 23; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/components/report/MarketReviewReportView.tsx:363
(anonymous) has cyclomatic complexity 31 and cognitive complexity 43; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:284
What to do
Break down the listed branch-heavy functions; aim P95 cyclomatic ≤ 5.
Do you agree with this assessment?
R3 · Large Files4.7 / 10Weak✓ Tool-verified
React / JS · Code Health — How many source files exceed the large-file threshold.
Method: Components/modules exceeding the large-file threshold, counted exhaustively across the frontend source tree. Deterministic.
apps/dsa-web/src/locales/settingsHelp.ts has 2539 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/locales/settingsHelp.ts:1
apps/dsa-web/src/components/settings/LLMChannelEditor.tsx has 2469 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1
apps/dsa-web/src/pages/PortfolioPage.tsx has 2095 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/pages/PortfolioPage.tsx:1
apps/dsa-web/src/pages/StockScreeningPage.tsx has 2061 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/pages/StockScreeningPage.tsx:1
apps/dsa-web/src/i18n/uiText.ts has 2026 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/i18n/uiText.ts:1
REDACTED has 1900 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — REDACTED:1
apps/dsa-web/src/pages/HomePage.tsx has 1783 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/pages/HomePage.tsx:1
apps/dsa-web/src/pages/SettingsPage.tsx has 1667 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/pages/SettingsPage.tsx:1
apps/dsa-web/src/pages/DecisionSignalsPage.tsx has 1538 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/pages/DecisionSignalsPage.tsx:1
apps/dsa-web/src/pages/ChatPage.tsx has 1481 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/pages/ChatPage.tsx:1
apps/dsa-web/src/stores/stockPoolStore.ts has 999 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/stores/stockPoolStore.ts:1
apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx has 772 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:1
apps/dsa-web/src/components/alerts/AlertRuleForm.tsx has 741 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:1
apps/dsa-web/src/components/report/MarketReviewReportView.tsx has 702 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/report/MarketReviewReportView.tsx:1
apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx has 691 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:1
apps/dsa-web/src/pages/BacktestPage.tsx has 683 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/pages/BacktestPage.tsx:1
apps/dsa-web/src/utils/systemConfigI18n.ts has 596 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/utils/systemConfigI18n.ts:1
apps/dsa-web/src/types/analysis.ts has 582 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/types/analysis.ts:1
apps/dsa-web/src/stores/agentChatStore.ts has 543 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/stores/agentChatStore.ts:1
apps/dsa-web/src/api/error.ts has 493 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/api/error.ts:1
apps/dsa-web/src/hooks/useRunFlowSnapshot.ts has 483 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/hooks/useRunFlowSnapshot.ts:1
apps/dsa-web/src/components/report/AnalysisContextSummary.tsx has 477 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:1
apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx has 461 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx:1
apps/dsa-web/src/api/screening.ts has 453 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/api/screening.ts:1
apps/dsa-web/src/components/settings/IntelligentImport.tsx has 420 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/settings/IntelligentImport.tsx:1
apps/dsa-web/src/components/report/ReportDiagnostics.tsx has 412 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — apps/dsa-web/src/components/report/ReportDiagnostics.tsx:1
What to do
Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
Do you agree with this assessment?
R4 · Test Coverage9.9 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Static test reachability (D-386): the share of production files reachable from any test via the import graph — measured without running anything.
Method: Static test reachability: the share of production files reachable from any test via the import graph — measured without running anything. Deterministic.
No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one. (×2) — apps/dsa-desktop/scripts/afterPackMacos.js:1, apps/dsa-web/src/main.tsx:1
What to do
Add tests that import the unreached modules (directly or through their public entry).
React / JS · Readiness — How outdated the npm dependencies are (a maturity signal). JS/npm CVEs are scored separately in D30 (JS/npm Dependency Vulnerabilities).
Method: npm dependency staleness from manifest/registry metadata (a maturity signal; JS/npm CVEs are scored separately in D30, which answers dependency vulnerabilities for every ecosystem). Deterministic.
What to do
Bump outdated dependencies to current versions to limit upgrade debt.
Do you agree with this assessment?
R6 · Tooling10.0 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each package.json script's COMMAND (eslint / tsc / vitest / jest / playwright), not just its name, and corroborated against CI-workflow invocations so a tool run only in CI still counts.
Method: package.json scanned for test/lint/typecheck script wiring. Deterministic presence check.
Do you agree with this assessment?
R7 · Dead Code8.7 / 10Strong✓ Tool-verified
React / JS · Code Health — Files unreachable from every application/tooling/test entry point, and exports nothing imports (module-graph reachability, D-386).
Method: Dead code: files unreachable from every application/tooling/test entry point plus exports nothing imports, via module-graph reachability. Deterministic, exhaustive over the import graph.
Unreachable from the 20 application, 8 tooling and 119 test entry point(s) detected in this repo. Gate removals on `npm run build` — an undetected custom entry would make these reachable.
no import path from any entry point (20 application, 8 tooling, 119 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make (×2) — apps/dsa-desktop/scripts/afterPackMacos.js, apps/dsa-web/src/components/report/index.ts
Nothing imports this binding — it is safe to review for removal. (×18) — apps/dsa-web/src/api/error.ts:306, apps/dsa-web/src/api/error.ts:555, apps/dsa-web/src/components/StockAutocomplete/StockAutocomplete.tsx:325, …
Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/common/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/common/index.ts in the same commit, or the barrel will import a name that no longer exists. (×6) — apps/dsa-web/src/components/common/Collapsible.tsx:15, apps/dsa-web/src/components/common/SectionCard.tsx:12, apps/dsa-web/src/components/common/StickyActionBar.tsx:9, …
Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/tasks/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/tasks/index.ts in the same commit, or the barrel will import a name that no longer exists. — apps/dsa-web/src/components/tasks/TaskPanel.tsx:299
Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/stores/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/stores/index.ts in the same commit, or the barrel will import a name that no longer exists. — apps/dsa-web/src/stores/analysisStore.ts:24
What to do
Delete the dead files and unused exports — every line is maintenance cost and rebuild-estimate inflation with zero runtime value.
React / JS · Readiness — npm dependency truthfulness (D-386): unused dependencies, imports not declared anywhere, and type-/test-only packages shipped as production deps.
Method: npm dependency truthfulness: unused dependencies, imports declared nowhere, and type-/test-only packages shipped as production deps — from the manifest + import graph. Deterministic.
Declared in apps/dsa-web/package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
What to do
Remove unused dependencies, declare unlisted imports explicitly, and demote type-/test-only packages to devDependencies.
React / JS · Architecture — Import cycles in the module graph (D-386) — files that can only be understood and changed together.
Method: Import cycles in the module graph, detected exhaustively over JS/TS imports (the same cycle detection as the .NET coupling dimension). Deterministic.
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.
The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception. — bot/handler.py:189
Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.
Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.
Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.
Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.
Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.
Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.
Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X17 · Uncapped recursion over a caller-supplied document3.5 / 10Weak✓ Tool-verified
Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.
Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.
`strip_trace_metadata` is public, takes a document from its caller (line 229) and hands it to `_strip_trace_metadata_value`, which calls itself at line 272 (`_strip_trace_metadata_value`) with a piece of `value` (and at line 277) — and nowhere in `_strip_trace_metadata_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_strip_trace_metadata_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — src/agent/provider_trace.py:272
`attach_legacy_message_stability_audit` is public, takes a document from its caller (line 485) and hands it to `_plain_value`, which calls itself at line 843 (`_plain_value`) with a piece of `value` (and at line 845, line 853) — and nowhere in `_plain_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_plain_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — src/llm/usage.py:843
`find_sniper_points` is public and takes `data: Mapping[str, Any]` from its caller, and it calls itself at line 119 (`find_sniper_points`) with a piece of `data` — and nowhere in `find_sniper_points` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `find_sniper_points` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — src/utils/sniper_points.py:119
`redact_sensitive_mapping` is public and takes `obj: Any` from its caller, and it calls itself at line 102 (`redact_sensitive_mapping`) with a piece of `obj` (and at line 105) — and nowhere in `redact_sensitive_mapping` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `redact_sensitive_mapping` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — src/utils/sanitize.py:102
What to do
Each finding names the externally-callable member that accepts the document and the self-call that descends, and states that no depth parameter or counter exists anywhere in the walk. Confirm from the two, then thread a depth argument through the walk and reject documents past a fixed maximum, or rewrite it with an explicit stack.
Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.
Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.
Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether async functions that make a cancellable request accept or pass on an AbortSignal (adoption curve).
Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.
Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.
Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.
Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.
Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.
`debug` at line 94 is called with an argument built by `json.dumps(data, ensure_ascii = False)` (line 94), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — bot/handler.py:94
`debug` at line 169 is called with an argument built by `json.dumps(data, ensure_ascii = False)` (line 169), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — bot/handler.py:169
`debug` at line 1871 is called with an argument built by `list(df.columns)` (line 1871), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — REDACTED:1871
`debug` at line 1550 is called with an argument built by `list(data.keys())` (line 1550), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/search_service.py:1550
What to do
In Python, put the construction behind the logger's own check (`if logger.isEnabledFor(logging.DEBUG):`), or pass the collection itself with a `%s` placeholder (`logger.debug("Items %s", items)`) so the logging module renders it only when the record is emitted. The placeholder alone is not the fix when the argument is still built first: it defers the formatting, not a `json.dumps`, a `join` or a comprehension in the argument, and an f-string defers nothing at all.
Do you agree with this assessment?
X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.
Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.
Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.
Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.
Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.
Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.
Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.
Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.
`except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×17) — api/v1/schemas/history.py:294, api/v1/schemas/history.py:304, data_provider/yfinance_fundamental_adapter.py:304, …
An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. (×22) — REDACTED:464, REDACTED:956, REDACTED:1035, …
An empty catch block silently discards the error — failures vanish with no log and no rethrow. On a teardown path letting it propagate is not an option (throwing out of `__del__()` masks the failure already in flight and abandons the rest of the cleanup), so make the swallow deliberate instead: narrow the catch to the exception this release can actually raise, and record it through whatever this codebase already uses to report problems — or, if it truly cannot matter, say why in a comment on the catch. — data_provider/tickflow_fetcher.py:150
What to do
Swallowed exception (caught, then discarded)
Do you agree with this assessment?
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.
Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.
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.
`info` at line 791 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:791
`warning` at line 797 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.warning("order moved", order_id=order_id, status=status)` with structlog. — main.py:797
`info` at line 1084 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1084
`info` at line 1178 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1178
`info` at line 1216 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1216
`error` at line 1225 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — main.py:1225
`exception` at line 1236 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.exception("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.exception("order moved", order_id=order_id, status=status)` with structlog. — main.py:1236
`info` at line 1380 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1380
`info` at line 1389 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1389
`error` at line 1418 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — main.py:1418
`error` at line 1433 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — main.py:1433
`info` at line 1586 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1586
`info` at line 1625 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1625
`info` at line 1650 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1650
`error` at line 1720 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — main.py:1720
`info` at line 1731 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1731
`info` at line 1733 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1733
`info` at line 1754 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1754
`info` at line 1814 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1814
`info` at line 1825 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1825
`info` at line 1834 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — main.py:1834
`exception` at line 1941 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.exception("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.exception("order moved", order_id=order_id, status=status)` with structlog. — main.py:1941
`error` at line 52 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/middlewares/error_handler.py:52
`error` at line 116 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/middlewares/error_handler.py:116
`warning` at line 177 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.warning("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/stocks.py:177
`error` at line 197 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/stocks.py:197
`error` at line 339 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/stocks.py:339
`error` at line 372 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/stocks.py:372
`error` at line 407 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/stocks.py:407
`error` at line 507 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/stocks.py:507
`error` at line 588 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/stocks.py:588
`error` at line 58 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/portfolio.py:58
`error` at line 307 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/history.py:307
`error` at line 363 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/history.py:363
`error` at line 405 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/history.py:405
`error` at line 511 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/history.py:511
`error` at line 684 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/history.py:684
`error` at line 727 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/history.py:727
`error` at line 770 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/history.py:770
`error` at line 828 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — api/v1/endpoints/history.py:828
Other · Code Health — Whether strict null checking is enabled and not undermined by heavy `!` assertion — TypeScript's `strictNullChecks` (which `strict` turns on) is what makes `string` exclude `null` and `undefined`, and the postfix `!` is the operator that silences it.
Method: Roslyn compiler-options scan: NullableContextOptions per project; null-forgiving (!) suppression density per 1k syntax nodes. Deterministic, adoption plus suppression penalty.
~0.1 `!` null assertions per 1k TypeScript source lines — 5 assertion(s) across the 50244 source line(s) of the 190 TypeScript file(s) read, which is the only code the operator asserts anything in (a `!` in a `.js` file is not this operator and was not counted, and one in a file whose null checking is off silences nothing). Densest: apps/dsa-web/src/stores/agentChatStore.ts (3), apps/dsa-web/src/components/settings/IntelligentImport.tsx (1), apps/dsa-web/src/main.tsx (1). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce.
What to do
The findings name the configuration each number was taken from and, for the assertions, the files that hold them. Turn null checking on where it is off — `"strict": true` in the base tsconfig that the others extend switches `strictNullChecks` on with the rest of the family — and then resolve the assertions rather than adding to them. A `!` on a value the checker could show to be null is a promise the author cannot check from where they are standing, and each one is a `TypeError: Cannot read properties of null` waiting for the path that makes it true; where the value genuinely cannot be null, say something the checker can see instead (narrow it with a test, make the property required, drop the `?`).
Do you agree with this assessment?
WCAG coverage — what static analysis assessed
Statically assessed 15 of 55 WCAG 2.2 Level A/AA success criteria (27%; ≈30% of the 50 WCAG 2.1 AA criteria for EN 301 549). The other 40 require runtime or manual evaluation. Partial signal only (a clean result is necessary, not sufficient; static analysis fully verifies none). This is accessibility readiness, not a conformance claim — a WCAG conformance claim requires manual evaluation (WCAG-EM 1.0).
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Unscored — 2 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 37 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 1 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 42 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.
AX1 Captive dependencies — 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
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AX9 CQS / query purity — no CQRS query handlers detected — query purity is not applicable to this codebase
AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
AXR1 Runtime accessibility — compose up failed (exit 14 — a file the compose project references is missing) — env file .env not found: stat .env: no such file or directory; runtime evidence skipped This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
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 Django, SQLAlchemy, SQLModel, Peewee, Tortoise or MongoEngine model, a migration or a SQL schema — and no database or data-store client (Django ORM, SQLAlchemy, psycopg, PyMongo, …) 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 on a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or mongoengine model, in a migration or in a SQL schema — and no database or data-store client (django.db, sqlalchemy, psycopg2, pymongo, sqlite3, …) imported 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 on a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or mongoengine model, in a migration or in a SQL schema — and no database or data-store client (django.db, sqlalchemy, psycopg2, pymongo, sqlite3, …) imported either, so this repository keeps no personal data for a data subject to erase, export or consent over.
D11 Test Reliability — Test reliability not measured — JavaScript/TypeScript suite did not run
D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
D22 Internal API Consistency — The exposed public-API surface could not be collected — no C#/VB projects loaded.
D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ projects each declaring an entity of their own. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — No inline comments to assess — comment value is not applicable here.
D25 ADR Conformance — no ADRs to check
D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.py), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D32 Data Compliance (PII/GDPR) — 1 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
D8 Code Coverage — Coverage not measured — polyglot repository, one half has no runner
DM1 Domain Modelling — not scored — this repository shows only 1 of the 3 signals this lens looks for (163 value object(s))
ED1 Event-Driven — not scored — this repository shows none of the 3 signals this lens looks for
ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
P9 Domain vs controller coverage — coverage data present for 4 file(s), but no domain-layer files were identified: no covered file's path contains any of the markers this check keys on (/domain/, /aggregates/, /valueobjects/, /domainmodel/, .domain/, /entities/), which are matched case-insensitively anywhere in the path. With no domain partition there is nothing to compare the web/controller layer against — if this repository keeps its business rules under a folder named none of those, that naming is what the check cannot see, not the domain logic.
PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for a pytest-benchmark or pytest-codspeed dependency with tests taking the `benchmark` fixture, an asv.conf.json with its `time_`/`mem_`/`peakmem_` benchmarks, or a pyperf Runner, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
PF2 Allocation hygiene — Not applicable: Python and TypeScript/JavaScript runs on a garbage-collected runtime that gives a program no allocation-control idiom to choose on a hot path — no pools, stack allocation or value types — so allocation awareness is not something this code can be rated on.
R11 Import Boundaries — No recognizable feature-sliced/layered src layout — boundary rules not applicable.
S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
AC2 · Forms & labels· <input> without a programmatic label · ×26
<input> without a programmatic label apps/dsa-web/src/components/history/HistoryListItem.tsx:47— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/components/history/StockBar.tsx:167— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/components/settings/IntelligentImport.tsx:408— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:475— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2495— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/pages/BacktestPage.tsx:443— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/BacktestPage.tsx:463— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1568— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1574— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1580— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1906— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1909— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1918— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1920— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1924— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1926— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1938— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1946— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1948— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1957— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1960— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1969— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1973— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:2053— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<input> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:2054— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
+ 1 more in this group — see findings.md.
AC2 · Forms & labels· <select> without a programmatic label · ×11
<select> without a programmatic label apps/dsa-web/src/pages/BacktestPage.tsx:476— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1444— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1459— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1586— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1911— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1940— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1962— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:1994— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:2043— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:2061— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<select> without a programmatic label apps/dsa-web/src/pages/PortfolioPage.tsx:2068— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
AC2 · Forms & labels· <textarea> without a programmatic label · ×2
<textarea> without a programmatic label apps/dsa-web/src/components/settings/IntelligentImport.tsx:345— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
<textarea> without a programmatic label apps/dsa-web/src/pages/ChatPage.tsx:1514— This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
AC4 · Keyboard semantics· Click handler on a non-interactive <div> · ×2
Click handler on a non-interactive <div> apps/dsa-web/src/pages/ChatPage.tsx:909— A click handler on a plain element with no role and no tabindex: even where another element's key handler can reach it, assistive tech can neither focus it nor announce what it is. Use a <button>, or add role + tabIndex={0}.
Click handler on a non-interactive <div> apps/dsa-web/src/pages/HomePage.tsx:1712— A click handler on a plain element with no role and no tabindex: even where another element's key handler can reach it, assistive tech can neither focus it nor announce what it is. Use a <button>, or add role + tabIndex={0}.
AC4 · Keyboard semantics· Clickable role="option" that no keyboard user can reach · ×1
Clickable role="option" that no keyboard user can reach apps/dsa-web/src/components/StockAutocomplete/SuggestionsList.tsx:47— This <li> announces itself as a role="option" and binds a click, but nothing can put focus on it: no tabIndex={0} in any spelling, no key handler, and nothing in this file moves focus or sets aria-activedescendant. The role tells assistive tech what the control IS; it does not make the control reachable, so a keyboard user cannot operate it at all (WCAG 2.1.1). Give it tabIndex={0}="0" and an Enter/Space key handler, or make it a native <button>. If a parent widget owns the keyboard model, that parent must move focus onto the active role="option" or point aria-activedescendant at it.
AC4 · Keyboard semantics· Click handler on a non-interactive <tr> · ×1
Click handler on a non-interactive <tr> apps/dsa-web/src/components/history/StockHistoryTrendDrawer.tsx:328— A click handler on a plain element isn't keyboard-operable. Use a <button>, or add role + tabIndex={0} + a key handler.
Project dependency cycle — The projects (root) → api → src/services → (root) (one cycle inside a mutually-dependent group of 14 projects) form a reference cycle. Cyclic dependencies prevent independent build/test/deploy, blur ownership, and tend to grow into a big ball of mud. Break the cycle by extracting the shared types into a separate project both can reference.
Orphaned knowledge src/agent/skills/deliberation.py:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
FileTooLong: services/system_config_service.py src/services/system_config_service.py— FileTooLong — 4597 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 4097 over it, 9.19× 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/analyzer.py src/analyzer.py— FileTooLong — 4134 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3634 over it, 8.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.
FileTooLong: REDACTED REDACTED— FileTooLong — 3631 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3131 over it, 7.26× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/search_service.py src/search_service.py— FileTooLong — 3618 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3118 over it, 7.24× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: data_provider/base.py data_provider/base.py— FileTooLong — 3576 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3076 over it, 7.15× 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: core/pipeline.py src/core/pipeline.py— FileTooLong — 3412 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 2912 over it, 6.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: REDACTED REDACTED— FileTooLong — 3379 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 2879 over it, 6.76× 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/config.py src/config.py— FileTooLong — 2796 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 2296 over it, 5.59× 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/notification.py src/notification.py— FileTooLong — 2233 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1733 over it, 4.47× 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: settings/LLMChannelEditor.tsx apps/dsa-web/src/components/settings/LLMChannelEditor.tsx— FileTooLong — 2131 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1631 over it, 4.26× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: llm/local_cli_backend.py src/llm/local_cli_backend.py— FileTooLong — 2076 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1576 over it, 4.15× 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: pages/PortfolioPage.tsx apps/dsa-web/src/pages/PortfolioPage.tsx— FileTooLong — 1877 significant lines (blank, comment-only and punctuation-only lines excluded), about 73% of them inside a single declaration: PortfolioPage (624-2210). The bar is 500 significant lines; this is 1377 over it, 3.75× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: pages/StockScreeningPage.tsx apps/dsa-web/src/pages/StockScreeningPage.tsx— FileTooLong — 1737 significant lines (blank, comment-only and punctuation-only lines excluded), about 66% of them inside a single declaration: StockScreeningPage (841-2190). The bar is 500 significant lines; this is 1237 over it, 3.47× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: agent/orchestrator.py src/agent/orchestrator.py— FileTooLong — 1724 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1224 over it, 3.45× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: REDACTED REDACTED— FileTooLong — 1702 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1202 over it, 3.40× 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/share_image.py src/share_image.py— FileTooLong — 1694 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1194 over it, 3.39× 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: pages/HomePage.tsx apps/dsa-web/src/pages/HomePage.tsx— FileTooLong — 1512 significant lines (blank, comment-only and punctuation-only lines excluded), about 88% of them inside a single declaration: HomePage (252-1916). The bar is 500 significant lines; this is 1012 over it, 3.02× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: src/market_analyzer.py src/market_analyzer.py— FileTooLong — 1506 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1006 over it, 3.01× 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: pages/SettingsPage.tsx apps/dsa-web/src/pages/SettingsPage.tsx— FileTooLong — 1505 significant lines (blank, comment-only and punctuation-only lines excluded), about 61% of them inside a single declaration: SettingsPage (688-1750). The bar is 500 significant lines; this is 1005 over it, 3.01× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: screening/hotspot.py src/services/screening/hotspot.py— FileTooLong — 1481 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 981 over it, 2.96× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: REDACTED REDACTED— FileTooLong — 1480 significant lines (blank, comment-only and punctuation-only lines excluded; the length bar is tripled for a single-responsibility module of 4 or fewer top-level units). The bar is 500 significant lines; this is 980 over it, 2.96× 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: services/portfolio_service.py src/services/portfolio_service.py— FileTooLong — 1468 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 968 over it, 2.94× 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: pages/DecisionSignalsPage.tsx apps/dsa-web/src/pages/DecisionSignalsPage.tsx— FileTooLong — 1389 significant lines (blank, comment-only and punctuation-only lines excluded), about 79% of them inside a single declaration: DecisionSignalsPage (388-1631). The bar is 500 significant lines; this is 889 over it, 2.78× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: agent/web_intent_resolver.py src/agent/web_intent_resolver.py— FileTooLong — 1330 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 830 over it, 2.66× 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: pages/ChatPage.tsx apps/dsa-web/src/pages/ChatPage.tsx— FileTooLong — 1317 significant lines (blank, comment-only and punctuation-only lines excluded), about 95% of them inside a single declaration: ChatPage (83-1556). The bar is 500 significant lines; this is 817 over it, 2.63× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FunctionTooLong: PortfolioPage.PortfolioPage apps/dsa-web/src/pages/PortfolioPage.tsx:624— FunctionTooLong — PortfolioPage runs 1373 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 1273 over it, 13.73× 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: HomePage.HomePage apps/dsa-web/src/pages/HomePage.tsx:252— FunctionTooLong — HomePage runs 1324 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 1224 over it, 13.24× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ChatPage.ChatPage apps/dsa-web/src/pages/ChatPage.tsx:83— FunctionTooLong — ChatPage runs 1248 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 1148 over it, 12.48× 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: StockScreeningPage.StockScreeningPage apps/dsa-web/src/pages/StockScreeningPage.tsx:841— FunctionTooLong — StockScreeningPage runs 1141 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 1041 over it, 11.41× 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: DecisionSignalsPage.DecisionSignalsPage apps/dsa-web/src/pages/DecisionSignalsPage.tsx:388— FunctionTooLong — DecisionSignalsPage runs 1091 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 991 over it, 10.91× 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: SettingsPage.SettingsPage apps/dsa-web/src/pages/SettingsPage.tsx:688— FunctionTooLong — SettingsPage runs 918 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 818 over it, 9.18× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: LLMChannelEditor.LLMChannelEditor apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1667— FunctionTooLong — LLMChannelEditor runs 804 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 704 over it, 8.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.
FunctionTooLong: AlertRuleForm.AlertRuleForm apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:127— FunctionTooLong — AlertRuleForm runs 582 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 482 over it, 5.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: LLMChannelEditor.ChannelRow apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:399— FunctionTooLong — ChannelRow runs 462 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 362 over it, 4.62× 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: RunFlowGraph.RunFlowGraph apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:314— FunctionTooLong — RunFlowGraph runs 439 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 339 over it, 4.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: BacktestPage.BacktestPage apps/dsa-web/src/pages/BacktestPage.tsx:246— FunctionTooLong — BacktestPage runs 414 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 314 over it, 4.14× 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: stockPoolStore.useStockPoolStore apps/dsa-web/src/stores/stockPoolStore.ts:615— FunctionTooLong — useStockPoolStore runs 339 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 239 over it, 3.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: MarketReviewReportView.MarketReviewReportView apps/dsa-web/src/components/report/MarketReviewReportView.tsx:363— FunctionTooLong — MarketReviewReportView runs 331 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 231 over it, 3.31× 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: IntelligentImport.IntelligentImport apps/dsa-web/src/components/settings/IntelligentImport.tsx:100— FunctionTooLong — IntelligentImport runs 295 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 195 over it, 2.95× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: HomeStockWorkspace.HomeStockWorkspace apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:388— FunctionTooLong — HomeStockWorkspace runs 295 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 195 over it, 2.95× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: agentChatStore.useAgentChatStore apps/dsa-web/src/stores/agentChatStore.ts:206— FunctionTooLong — useAgentChatStore runs 286 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 186 over it, 2.86× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: useSystemConfig.useSystemConfig apps/dsa-web/src/hooks/useSystemConfig.ts:71— FunctionTooLong — useSystemConfig runs 260 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 160 over it, 2.60× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: SettingsPage.SchedulerSettingsCard apps/dsa-web/src/pages/SettingsPage.tsx:419— FunctionTooLong — SchedulerSettingsCard runs 236 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 136 over it, 2.36× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: RunFlowNodeDetails.RunFlowNodeDetails apps/dsa-web/src/components/run-flow/RunFlowNodeDetails.tsx:111— FunctionTooLong — RunFlowNodeDetails runs 232 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 132 over it, 2.32× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: AlertsPage.AlertsPage apps/dsa-web/src/pages/AlertsPage.tsx:101— FunctionTooLong — AlertsPage runs 232 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 132 over it, 2.32× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ReportDiagnostics.ReportDiagnostics apps/dsa-web/src/components/report/ReportDiagnostics.tsx:165— FunctionTooLong — ReportDiagnostics runs 229 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 129 over it, 2.29× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ReportOverview.ReportOverview apps/dsa-web/src/components/report/ReportOverview.tsx:165— FunctionTooLong — ReportOverview runs 217 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 117 over it, 2.17× 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: LoginPage.LoginPage REDACTED:15— FunctionTooLong — LoginPage runs 215 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 115 over it, 2.15× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: StockHistoryTrendDrawer.StockHistoryTrendDrawer apps/dsa-web/src/components/history/StockHistoryTrendDrawer.tsx:174— FunctionTooLong — StockHistoryTrendDrawer runs 206 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 106 over it, 2.06× 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: error.parseApiError apps/dsa-web/src/api/error.ts:310— FunctionTooLong — parseApiError runs 177 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 77 over it, 1.77× 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.
+ 32 more in this group — see findings.md.
AC6 · Visual & motion safety· Animation without a prefers-reduced-motion guard · ×37
Animation without a prefers-reduced-motion guard apps/dsa-desktop/renderer/loading.html:98— `.dot` moves (`animation: pulse 1.5s ease-in-out infinite`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/StockAutocomplete/StockAutocomplete.tsx:288— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/common/Button.tsx:78— <svg> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/common/Loading.tsx:15— <svg> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/dashboard/DashboardStateBlock.tsx:40— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/history/HistoryList.tsx:188— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/layout/RouteBoundary.tsx:19— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/report/MarketReviewReportView.tsx:714— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/report/ReportDiagnostics.tsx:320— <span> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/report/ReportMarkdownDrawer.tsx:58— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:154— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/components/run-flow/RunFlowPanel.tsx:93— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/pages/BacktestPage.tsx:537— <svg> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/pages/ChatPage.tsx:1036— <svg> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/pages/ChatPage.tsx:1262— <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/pages/HomePage.tsx:1636— <svg> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard REDACTED:245— <div> moves — its `animate-[shimmer_1.5s_infinite]` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/index.css:712— `.input-surface` moves (`transition: border-color 0.2s ease,
box-shadow 0.2s ease,
transform 0.2s ease,
color 0.2s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/index.css:934— `.animate-fade-in` moves (`animation: fadeIn 0.3s ease-out`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/index.css:938— `.animate-slide-up` moves (`animation: slideUp 0.4s ease-out`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/index.css:942— `.animate-slide-in-right` moves (`animation: slideInRight 0.3s ease-out`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/index.css:950— `.animate-spin` moves (`animation: spin 1s linear infinite`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/index.css:968— `.fade-in` moves (`animation-name: fadeIn`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/index.css:972— `.zoom-in` moves (`animation-name: zoomIn`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard apps/dsa-web/src/index.css:976— `.slide-in-from-top-1` moves (`animation-name: slideInFromTopSm`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Hotspot: src/config.py src/config.py:1492— src/config.py changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 130 in Config._load_from_env at line 1492. 4 of those changes were fix/bug commits, and the other 13 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/config.py`: 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: apps/dsa-web/src/pages/SettingsPage.tsx apps/dsa-web/src/pages/SettingsPage.tsx:688— apps/dsa-web/src/pages/SettingsPage.tsx changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 174 in SettingsPage.SettingsPage at line 688. 5 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/pages/SettingsPage.tsx`: 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: apps/dsa-web/src/pages/HomePage.tsx apps/dsa-web/src/pages/HomePage.tsx:252— apps/dsa-web/src/pages/HomePage.tsx changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 213 in HomePage.HomePage at line 252. 2 of those changes were fix/bug commits, and the other 4 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/pages/HomePage.tsx`: 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: apps/dsa-web/src/pages/StockScreeningPage.tsx apps/dsa-web/src/pages/StockScreeningPage.tsx:841— apps/dsa-web/src/pages/StockScreeningPage.tsx changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 251 in StockScreeningPage.StockScreeningPage at line 841. 3 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/pages/StockScreeningPage.tsx`: 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: data_provider/base.py data_provider/base.py:2432— data_provider/base.py changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 87 in DataFetcherManager.get_realtime_quote at line 2432. 7 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- data_provider/base.py`: 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: main.py main.py:800— main.py changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 86 in main.run_full_analysis at line 800. 4 of those changes were fix/bug commits, and the other 5 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- main.py`: 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: apps/dsa-web/src/pages/ChatPage.tsx apps/dsa-web/src/pages/ChatPage.tsx:83— apps/dsa-web/src/pages/ChatPage.tsx changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 211 in ChatPage.ChatPage at line 83. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/pages/ChatPage.tsx`: 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: apps/dsa-web/src/components/settings/LLMChannelEditor.tsx apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1667— apps/dsa-web/src/components/settings/LLMChannelEditor.tsx changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 143 in LLMChannelEditor.LLMChannelEditor at line 1667. 1 of those changes was a fix/bug commit, and the other 3 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/components/settings/LLMChannelEditor.tsx`: 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: src/search_service.py src/search_service.py:4021— src/search_service.py changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 54 in SearchService.search_stock_news at line 4021. 5 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/search_service.py`: 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: src/core/pipeline.py src/core/pipeline.py:434— src/core/pipeline.py changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 85 in StockAnalysisPipeline.analyze_stock at line 434. 1 of those changes was a fix/bug commit, and the other 4 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/core/pipeline.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: REDACTED REDACTED:3612— REDACTED changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 45 in screening_service._build_dsa_candidate_context at line 3612. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: src/services/history_service.py src/services/history_service.py:108— src/services/history_service.py changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 44 in HistoryService._history_code_filter_candidates at line 108. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/services/history_service.py`: 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: src/services/system_config_service.py src/services/system_config_service.py:3452— src/services/system_config_service.py changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 48 in SystemConfigService._collect_setup_channel_models at line 3452. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/services/system_config_service.py`: 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: src/services/screening/pipeline.py src/services/screening/pipeline.py:51— src/services/screening/pipeline.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 69 in pipeline.screen at line 51. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/services/screening/pipeline.py`: 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: src/services/stock_code_utils.py src/services/stock_code_utils.py:339— src/services/stock_code_utils.py changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 47 in stock_code_utils.resolve_daily_stock_identity at line 339. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/services/stock_code_utils.py`: 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: src/notification.py src/notification.py:1255— src/notification.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 60 in NotificationService.generate_dashboard_report at line 1255. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/notification.py`: 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: apps/dsa-web/src/stores/stockPoolStore.ts apps/dsa-web/src/stores/stockPoolStore.ts:615— apps/dsa-web/src/stores/stockPoolStore.ts changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 77 in stockPoolStore.useStockPoolStore at line 615. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/stores/stockPoolStore.ts`: 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: apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:388— apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 36 in HomeStockWorkspace.HomeStockWorkspace at line 388. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx`: 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: src/services/stock_list_parser.py src/services/stock_list_parser.py:632— src/services/stock_list_parser.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 46 in stock_list_parser.parse_analysis_target at line 632. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/services/stock_list_parser.py`: 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: apps/dsa-web/src/api/error.ts apps/dsa-web/src/api/error.ts:310— apps/dsa-web/src/api/error.ts changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in error.parseApiError at line 310. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/api/error.ts`: 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: data_provider/yfinance_fundamental_adapter.py data_provider/yfinance_fundamental_adapter.py:158— data_provider/yfinance_fundamental_adapter.py changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 63 in YfinanceFundamentalAdapter.get_fundamental_bundle at line 158. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- data_provider/yfinance_fundamental_adapter.py`: 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: api/v1/endpoints/analysis.py api/v1/endpoints/analysis.py:1170— api/v1/endpoints/analysis.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 40 in analysis.get_analysis_status at line 1170. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- api/v1/endpoints/analysis.py`: 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: src/services/backtest_service.py src/services/backtest_service.py:48— src/services/backtest_service.py changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 29 in BacktestService.run_backtest at line 48. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/services/backtest_service.py`: 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: src/services/runtime_scheduler.py src/services/runtime_scheduler.py:483— src/services/runtime_scheduler.py changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 27 in RuntimeSchedulerService._run_analysis_with_watchdog at line 483. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- src/services/runtime_scheduler.py`: 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: apps/dsa-web/src/components/layout/SidebarNav.tsx apps/dsa-web/src/components/layout/SidebarNav.tsx:42— apps/dsa-web/src/components/layout/SidebarNav.tsx changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 26 in SidebarNav.SidebarNav at line 42. 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-23..2026-10-21, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-23 17:50:50 +08:00' --until='2026-10-21 17:50:50 +08:00' --full-history --no-merges -- apps/dsa-web/src/components/layout/SidebarNav.tsx`: 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.
TooManyMethods: SystemConfigService src/services/system_config_service.py:135— TooManyMethods — 129 methods. The bar is 30 methods; this is 99 over it, 4.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.
TooManyMethods: DatabaseManager REDACTED:1332— TooManyMethods — 93 methods. The bar is 30 methods; this is 63 over it, 3.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: DataFetcherManager data_provider/base.py:619— TooManyMethods — 88 methods. The bar is 30 methods; this is 58 over it, 2.93× 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: NotificationService src/notification.py:257— TooManyMethods — 67 methods. The bar is 30 methods; this is 37 over it, 2.23× 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: DecisionSignalService src/services/decision_signal_service.py:108— TooManyMethods — 64 methods. The bar is 30 methods; this is 34 over it, 2.13× 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: StockAnalysisPipeline src/core/pipeline.py:226— TooManyMethods — 63 methods. The bar is 30 methods; this is 33 over it, 2.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: MarketAnalyzer src/market_analyzer.py:122— TooManyMethods — 61 methods. The bar is 30 methods; this is 31 over it, 2.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: GeminiAnalyzer src/analyzer.py:1928— TooManyMethods — 58 methods. The bar is 30 methods; this is 28 over it, 1.93× 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: SearchService src/search_service.py:2244— TooManyMethods — 55 methods. The bar is 30 methods; this is 25 over it, 1.83× 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: TickFlowFetcher data_provider/tickflow_fetcher.py:84— TooManyMethods — 52 methods. The bar is 30 methods; this is 22 over it, 1.73× 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: PortfolioService src/services/portfolio_service.py:109— TooManyMethods — 49 methods. The bar is 30 methods; this is 19 over it, 1.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: AlertService src/services/alert_service.py:104— TooManyMethods — 48 methods. The bar is 30 methods; this is 18 over it, 1.60× 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: AgentOrchestrator src/agent/orchestrator.py:157— 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: DsaEastMoneyHotspotProvider REDACTED:2021— 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: PortfolioRepository src/repositories/portfolio_repo.py:45— TooManyMethods — 46 methods. The bar is 30 methods; this is 16 over it, 1.53× 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: AlertWorker REDACTED:78— TooManyMethods — 44 methods. The bar is 30 methods; this is 14 over it, 1.47× 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: DecisionSignalOutcomeService src/services/decision_signal_outcome_service.py:90— TooManyMethods — 44 methods. The bar is 30 methods; this is 14 over it, 1.47× 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: DataCapabilityService src/services/data_capability_service.py:228— TooManyMethods — 42 methods. The bar is 30 methods; this is 12 over it, 1.40× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: IntelligenceService REDACTED:122— TooManyMethods — 42 methods. The bar is 30 methods; this is 12 over it, 1.40× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: HistoryService src/services/history_service.py:84— TooManyMethods — 41 methods. The bar is 30 methods; this is 11 over it, 1.37× 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: AkshareFetcher REDACTED:404— TooManyMethods — 37 methods. The bar is 30 methods; this is 7 over it, 1.23× 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: BacktestService src/services/backtest_service.py:38— 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: MarketStructureService src/services/market_structure_service.py:38— TooManyMethods — 31 methods. The bar is 30 methods; this is 1 over it, 1.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Swallowed exception (empty catch) REDACTED:464— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) REDACTED:956— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) REDACTED:1035— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) REDACTED:1329— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/api/screening.ts:337— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/api/screening.ts:350— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/api/screening.ts:480— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/hooks/useWatchlist.ts:41— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/pages/StockScreeningPage.tsx:131— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/pages/StockScreeningPage.tsx:139— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/pages/HomePage.tsx:181— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/pages/HomePage.tsx:864— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/pages/ChatPage.tsx:166— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/stores/stockPoolStore.ts:1037— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/stores/agentChatStore.ts:282— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) apps/dsa-web/src/utils/uiLanguage.ts:43— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) data_provider/yfinance_fundamental_adapter.py:230— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) data_provider/tickflow_fetcher.py:150— An empty catch block silently discards the error — failures vanish with no log and no rethrow. On a teardown path letting it propagate is not an option (throwing out of `__del__()` masks the failure already in flight and abandons the rest of the cleanup), so make the swallow deliberate instead: narrow the catch to the exception this release can actually raise, and record it through whatever this codebase already uses to report problems — or, if it truly cannot matter, say why in a comment on the catch.
Swallowed exception (empty catch) data_provider/tickflow_fetcher.py:535— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) data_provider/tencent_fetcher.py:215— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) REDACTED:124— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) data_provider/futu_fetcher.py:74— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) data_provider/futu_fetcher.py:128— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Duplicated block (11 lines × 2) REDACTED:1129— REDACTED:1129-1139 | data_provider/efinance_fetcher.py:656-666 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `data_provider/efinance_fetcher.py:652` calls `is_available`, `info` and `REDACTED:1127` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 2) REDACTED:1140— REDACTED:1140-1150 | REDACTED:1547-1557 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:1139` calls `info` and `REDACTED:1546` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 2) data_provider/base.py:4983— data_provider/base.py:4983-4993 | data_provider/base.py:5005-5015 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `n` to `int = 10` in one and `int = 20` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (11 lines × 2) data_provider/fundamental_adapter.py:436— data_provider/fundamental_adapter.py:436-446 | data_provider/fundamental_adapter.py:450-460 — both copies are in the same file, so extract the block into 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) src/agent/chat_context.py:305— src/agent/chat_context.py:305-315 | src/agent/chat_context.py:375-386 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agent/chat_context.py:305` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/agent/research.py:154— src/agent/research.py:154-164 | src/agent/research.py:189-199 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agent/research.py:154` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/analyzer.py:5229— src/analyzer.py:5229-5239 | src/analyzer.py:5259-5269 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/analyzer.py:5229` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11 lines × 2) src/formatters.py:517— src/formatters.py:517-527 | src/formatters.py:808-818 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/llm/local_cli_backend.py:1472— src/llm/local_cli_backend.py:1472-1482 | src/llm/local_cli_backend.py:1497-1507 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/schemas/decision_scale.py:118— src/schemas/decision_scale.py:118-128 | src/services/decision_signal_reassess_service.py:353-363 — 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) src/search_service.py:370— src/search_service.py:370-380 | src/search_service.py:523-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/search_service.py:4199— src/search_service.py:4199-4209 | src/search_service.py:4271-4281 — both copies are in the same file, so extract the block into 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) src/services/decision_signal_reassess_service.py:362— src/services/decision_signal_reassess_service.py:362-372 | src/services/decision_signal_service.py:590-601 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/decision_signal_reassess_service.py:362` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/services/decision_signal_service.py:719— src/services/decision_signal_service.py:719-729 | src/services/decision_signal_service.py:959-969 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/services/portfolio_service.py:539— src/services/portfolio_service.py:539-549 | src/services/portfolio_service.py:570-580 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/portfolio_service.py:539` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) src/services/screening/daily.py:401— src/services/screening/daily.py:401-411 | src/services/screening/snapshot.py:178-188 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/services/screening/daily.py:415— src/services/screening/daily.py:415-425 | src/services/screening/snapshot.py:192-202 — 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) src/services/screening/daily.py:429— src/services/screening/daily.py:429-439 | src/services/screening/snapshot.py:206-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 (11 lines × 2) src/services/screening/filter.py:425— src/services/screening/filter.py:425-435 | src/services/screening/filter.py:445-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) src/services/system_config_service.py:1722— src/services/system_config_service.py:1722-1732 | src/services/system_config_service.py:1785-1795 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/system_config_service.py:1722` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) bot/platforms/dingtalk_stream.py:297— bot/platforms/dingtalk_stream.py:297-307 | bot/platforms/feishu_stream.py:709-719 — 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) bot/platforms/dingtalk_stream.py:325— bot/platforms/dingtalk_stream.py:325-335 | bot/platforms/feishu_stream.py:739-749 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) REDACTED:1888— REDACTED:1888-1895 | data_provider/tushare_fetcher.py:1217-1224 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1888` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) data_provider/base.py:2644— data_provider/base.py:2644-2651 | data_provider/base.py:2684-2691 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:2644` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) scripts/generate_index_from_csv.py:839— scripts/generate_index_from_csv.py:839-846 | src/data/stock_index_loader.py:639-646 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `scripts/generate_index_from_csv.py:847` calls `get` and `src/data/stock_index_loader.py:647` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) src/agent/runner.py:188— src/agent/runner.py:188-197 | src/agent/skills/deliberation.py:976-983 — 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) src/agent/skills/base.py:98— src/agent/skills/base.py:98-105 | REDACTED:2791-2798 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `value` to `object` in one and `Any` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (8 lines × 2) src/core/market_review.py:742— src/core/market_review.py:742-749 | src/core/market_review.py:754-761 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) src/llm/hermes.py:112— src/llm/hermes.py:112-119 | src/services/system_config_service.py:4079-4086 — 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) src/llm/local_cli_backend.py:1754— src/llm/local_cli_backend.py:1754-1761 | src/utils/sanitize.py:171-178 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) src/notification.py:963— src/notification.py:963-970 | src/notification.py:1675-1682 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/notification.py:963` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) src/notification.py:1719— src/notification.py:1719-1726 | src/notification.py:1729-1736 — both copies are in the same file, so extract the block into 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) src/report_language.py:1270— src/report_language.py:1270-1277 | src/report_language.py:1289-1296 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) src/services/image_stock_extractor.py:118— src/services/image_stock_extractor.py:118-125 | src/services/image_stock_extractor.py:155-162 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) src/services/screening/filter.py:212— src/services/screening/filter.py:212-219 | src/services/screening/filter.py:312-319 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) src/services/screening/scorer.py:213— src/services/screening/scorer.py:213-220 | src/services/screening/scorer.py:382-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) src/services/screening/scorer.py:295— src/services/screening/scorer.py:295-302 | src/services/screening/scorer.py:305-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.
Duplicated block (8 lines × 2) src/services/screening/scorer.py:351— src/services/screening/scorer.py:351-358 | src/services/screening/scorer.py:363-370 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/screening/scorer.py:351` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) src/services/social_sentiment_service.py:306— src/services/social_sentiment_service.py:306-313 | src/services/social_sentiment_service.py:323-330 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/social_sentiment_service.py:306` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) src/utils/sniper_points.py:38— src/utils/sniper_points.py:38-45 | src/utils/sniper_points.py:58-65 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) src/analysis_context_pack_overview.py:269— src/analysis_context_pack_overview.py:269-276 | src/market_phase_summary.py:314-321 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Swallowed exception (caught, then discarded) api/v1/schemas/history.py:294— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) api/v1/schemas/history.py:304— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) data_provider/yfinance_fundamental_adapter.py:304— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) data_provider/yfinance_fundamental_adapter.py:318— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:610— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:619— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:748— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:887— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) data_provider/tickflow_fetcher.py:811— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:150— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:155— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) REDACTED:516— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) data_provider/futu_fundamental_adapter.py:213— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) data_provider/futu_fetcher.py:91— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) data_provider/fundamental_adapter.py:77— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) data_provider/fundamental_adapter.py:83— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Swallowed exception (caught, then discarded) data_provider/fundamental_adapter.py:163— `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
Duplicated block (9 lines × 2) api/v1/endpoints/analysis.py:1334— api/v1/endpoints/analysis.py:1334-1342 | api/v1/endpoints/analysis.py:1643-1651 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `api/v1/endpoints/analysis.py:1334` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) data_provider/base.py:2674— data_provider/base.py:2674-2682 | data_provider/base.py:2684-2692 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:2674` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) data_provider/base.py:3834— data_provider/base.py:3834-3842 | data_provider/base.py:3849-3857 — both copies are in the same file, so extract the block into 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) scripts/generate_index_from_csv.py:849— scripts/generate_index_from_csv.py:849-857 | src/data/stock_index_loader.py:647-655 — 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) scripts/generate_index_from_csv.py:930— scripts/generate_index_from_csv.py:930-938 | scripts/generate_stock_index.py:315-323 — 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) src/agent/events.py:495— src/agent/events.py:495-503 | src/agent/events.py:505-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 (9 lines × 2) src/analysis_context_pack_overview.py:126— src/analysis_context_pack_overview.py:126-134 | src/market_phase_summary.py:267-275 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) src/formatters.py:743— src/formatters.py:743-751 | src/formatters.py:839-847 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) src/notification.py:1326— src/notification.py:1326-1334 | src/notification.py:1670-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 (9 lines × 2) src/notification_sender/pushover_sender.py:226— src/notification_sender/pushover_sender.py:226-236 | src/notification_sender/pushplus_sender.py:146-154 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `src/notification_sender/pushover_sender.py:226` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (9 lines × 2) src/repositories/alert_repo.py:47— src/repositories/alert_repo.py:47-55 | src/repositories/portfolio_repo.py:111-119 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `src/repositories/alert_repo.py:47` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) src/services/agent_backend_status_service.py:52— src/services/agent_backend_status_service.py:52-60 | src/services/agent_backend_status_service.py:69-77 — both copies are in the same file, so extract the block into 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) src/analysis_context_pack_overview.py:257— src/analysis_context_pack_overview.py:257-265 | src/analysis_context_pack_prompt.py:508-516 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) src/analysis_context_pack_overview.py:288— src/analysis_context_pack_overview.py:288-296 | src/analysis_context_pack_prompt.py:455-463 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) src/repositories/portfolio_repo.py:946— src/repositories/portfolio_repo.py:946-954 | REDACTED:2363-2371 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) bot/dispatcher.py:315— bot/dispatcher.py:315-320 | bot/dispatcher.py:356-361 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) data_provider/baostock_fetcher.py:364— data_provider/baostock_fetcher.py:364-369 | data_provider/tushare_fetcher.py:688-693 — 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) main.py:364— main.py:364-388 | scripts/check_env.py:471-476 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `main.py:364` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 2) src/agent/tools/data_tools.py:232— src/agent/tools/data_tools.py:232-237 | src/agent/tools/data_tools.py:239-244 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agent/tools/data_tools.py:232` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) src/analyzer.py:4168— src/analyzer.py:4168-4173 | src/analyzer.py:4219-4226 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/analyzer.py:4219` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 2) src/notification.py:1686— src/notification.py:1686-1691 | src/notification.py:1976-1981 — both copies are in the same file, so extract the block into 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) src/notification.py:2015— src/notification.py:2015-2020 | src/notification.py:2022-2027 — both copies are in the same file, so extract the block into 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) src/search_service.py:251— src/search_service.py:251-256 | src/search_service.py:4683-4688 — both copies are in the same file, so extract the block into 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) src/services/generation_backend_status_service.py:868— src/services/generation_backend_status_service.py:868-873 | src/services/system_config_service.py:3486-3491 — 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) src/services/screening/filter.py:241— src/services/screening/filter.py:241-246 | src/services/screening/filter.py:341-346 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) src/services/screening/scorer.py:229— src/services/screening/scorer.py:229-234 | src/services/screening/scorer.py:240-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. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/screening/scorer.py:229` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) REDACTED:4047— REDACTED:4047-4052 | REDACTED:4338-4345 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:4047` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 2) src/share_image.py:1480— src/share_image.py:1480-1485 | src/share_image.py:1487-1492 — both copies are in the same file, so extract the block into 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) src/share_image.py:1908— src/share_image.py:1908-1913 | src/share_image.py:1926-1931 — both copies are in the same file, so extract the block into 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) src/services/import_parser.py:160— src/services/import_parser.py:160-165 | src/services/import_parser.py:207-212 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) REDACTED:1205— REDACTED:1205-1209 | REDACTED:1608-1612 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1205` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:1204` calls `safe_float`, `get` and `REDACTED:1607` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 2) data_provider/efinance_fetcher.py:449— data_provider/efinance_fetcher.py:449-453 | data_provider/efinance_fetcher.py:542-546 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/efinance_fetcher.py:449` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) src/agent/skills/synthesis.py:48— src/agent/skills/synthesis.py:48-52 | src/agent/skills/synthesis.py:70-74 — both copies are in the same file, so extract the block into 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) src/repositories/intelligence_repo.py:71— src/repositories/intelligence_repo.py:71-75 | src/repositories/intelligence_repo.py:183-187 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/repositories/intelligence_repo.py:71` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) src/services/alert_indicators.py:414— src/services/alert_indicators.py:414-418 | src/stock_analyzer.py:322-329 — 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) src/services/run_diagnostics.py:1175— src/services/run_diagnostics.py:1175-1179 | src/services/run_diagnostics.py:1286-1290 — both copies are in the same file, so extract the block into 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) REDACTED:3792— REDACTED:3792-3796 | REDACTED:3799-3803 — both copies are in the same file, so extract the block into 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) src/services/system_config_service.py:3479— src/services/system_config_service.py:3479-3483 | src/services/system_config_service.py:4701-4705 — both copies are in the same file, so extract the block into 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) data_provider/alphavantage_fetcher.py:32— data_provider/alphavantage_fetcher.py:32-36 | data_provider/finnhub_fetcher.py:32-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 (5 lines × 2) src/agent/disagreement.py:126— src/agent/disagreement.py:126-130 | src/agent/runtime_facts.py:241-245 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) src/agent/skills/deliberation.py:927— src/agent/skills/deliberation.py:927-931 | src/agent/skills/scheduler.py:172-176 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) src/services/decision_signal_extractor.py:286— src/services/decision_signal_extractor.py:286-290 | src/services/decision_signal_reassess_service.py:330-334 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) src/services/screening/post_analysis.py:344— src/services/screening/post_analysis.py:344-348 | src/services/screening/risk.py:276-280 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) REDACTED:2955— REDACTED:2955-2959 | REDACTED:2977-2981 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) src/stock_analyzer.py:352— src/stock_analyzer.py:352-356 | src/stock_analyzer.py:371-375 — both copies are in the same file, so extract the block into 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) api/v1/endpoints/agent.py:493— api/v1/endpoints/agent.py:493-508 | bot/commands/research.py:90-105 — 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) api/v1/endpoints/analysis.py:1643— api/v1/endpoints/analysis.py:1643-1658 | api/v1/endpoints/history.py:664-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. Read the line range as the matched WINDOW rather than a finished unit: at `api/v1/endpoints/analysis.py:1643` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) REDACTED:2196— REDACTED:2196-2211 | data_provider/tushare_fetcher.py:1097-1112 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16 lines × 2) REDACTED:668— REDACTED:668-683 | REDACTED:774-789 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:668` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16 lines × 2) src/agent/orchestrator.py:244— src/agent/orchestrator.py:244-259 | src/agent/orchestrator.py:288-303 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agent/orchestrator.py:244` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/agent/orchestrator.py:242` calls `join` and `src/agent/orchestrator.py:287` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16 lines × 2) src/core/pipeline.py:3924— src/core/pipeline.py:3924-3939 | src/core/pipeline.py:4322-4337 — both copies are in the same file, so extract the block into 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) src/market_analyzer.py:1304— src/market_analyzer.py:1304-1319 | src/market_analyzer.py:1327-1342 — both copies are in the same file, so extract the block into 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) src/notification.py:115— src/notification.py:115-130 | src/services/history_service.py:1473-1488 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) src/repositories/portfolio_repo.py:327— src/repositories/portfolio_repo.py:327-342 | src/repositories/portfolio_repo.py:399-414 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/repositories/portfolio_repo.py:327` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) src/repositories/portfolio_repo.py:367— src/repositories/portfolio_repo.py:367-382 | src/repositories/portfolio_repo.py:402-417 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/repositories/portfolio_repo.py:367` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16 lines × 2) src/services/alert_indicators.py:247— src/services/alert_indicators.py:247-262 | src/services/alert_indicators.py:340-355 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) src/services/alert_indicators.py:277— src/services/alert_indicators.py:277-292 | src/services/alert_indicators.py:309-324 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) api/v1/endpoints/stocks.py:367— api/v1/endpoints/stocks.py:367-376 | api/v1/endpoints/stocks.py:402-411 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) REDACTED:383— REDACTED:383-392 | src/search_service.py:82-91 — 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) src/agent/orchestrator.py:420— src/agent/orchestrator.py:420-429 | src/agent/orchestrator.py:552-561 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agent/orchestrator.py:420` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) src/analysis_context_pack_overview.py:300— src/analysis_context_pack_overview.py:300-309 | src/analysis_context_pack_prompt.py:467-476 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) src/core/config_manager.py:38— src/core/config_manager.py:38-47 | src/core/config_manager.py:53-62 — both copies are in the same file, so extract the block into 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) src/market_phase_summary.py:203— src/market_phase_summary.py:203-212 | src/market_phase_summary.py:214-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 (10 lines × 2) REDACTED:476— REDACTED:476-485 | REDACTED:540-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) src/services/portfolio_service.py:1268— src/services/portfolio_service.py:1268-1277 | src/services/portfolio_service.py:1291-1300 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) src/services/run_flow.py:95— src/services/run_flow.py:95-104 | src/services/run_flow.py:216-225 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/run_flow.py:95` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) src/services/screening/config.py:510— src/services/screening/config.py:510-519 | src/services/screening/ranker.py:1138-1147 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `protocol` to `str = "openai"` in one and `str` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (10 lines × 2) src/core/market_profile.py:97— src/core/market_profile.py:97-106 | src/core/market_strategy.py:233-242 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) src/repositories/decision_signal_outcome_repo.py:99— src/repositories/decision_signal_outcome_repo.py:99-108 | src/repositories/skill_opinion_outcome_repo.py:193-202 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) REDACTED:811— REDACTED:811-822 | REDACTED:970-981 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) data_provider/base.py:2903— data_provider/base.py:2903-2914 | data_provider/base.py:3194-3205 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:2903` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) data_provider/base.py:4104— data_provider/base.py:4104-4115 | data_provider/base.py:4517-4528 — both copies are in the same file, so extract the block into 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) data_provider/tickflow_fetcher.py:382— data_provider/tickflow_fetcher.py:382-393 | src/llm/provider_cache.py:495-506 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) src/agent/tools/data_tools.py:130— src/agent/tools/data_tools.py:130-141 | src/services/history_loader.py:76-87 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) src/analysis_context_pack_prompt.py:209— src/analysis_context_pack_prompt.py:209-220 | src/analysis_context_pack_prompt.py:222-233 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (12 lines × 2) src/llm/usage.py:1027— src/llm/usage.py:1027-1038 | REDACTED:4724-4735 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) src/services/run_diagnostics.py:588— src/services/run_diagnostics.py:588-599 | src/services/run_flow.py:1460-1471 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) src/services/screening/industry.py:536— src/services/screening/industry.py:536-547 | src/services/screening/industry.py:561-572 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) REDACTED:4251— REDACTED:4251-4262 | REDACTED:4266-4277 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) src/services/system_config_service.py:3487— src/services/system_config_service.py:3487-3498 | src/services/system_config_service.py:4994-5005 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
ClassTooLong: PortfolioPage apps/dsa-web/src/pages/PortfolioPage.tsx:1— ClassTooLong — 1373 significant lines (blank, comment-only and punctuation-only lines excluded), 24 methods. The bar is 400 significant lines; this is 973 over it, 3.43× 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: HomePage apps/dsa-web/src/pages/HomePage.tsx:1— ClassTooLong — 1324 significant lines (blank, comment-only and punctuation-only lines excluded), 12 methods. The bar is 400 significant lines; this is 924 over it, 3.31× 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: ChatPage apps/dsa-web/src/pages/ChatPage.tsx:1— ClassTooLong — 1248 significant lines (blank, comment-only and punctuation-only lines excluded), 6 methods. The bar is 400 significant lines; this is 848 over it, 3.12× 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: StockScreeningPage apps/dsa-web/src/pages/StockScreeningPage.tsx:1— ClassTooLong — 1141 significant lines (blank, comment-only and punctuation-only lines excluded), 58 methods. The bar is 400 significant lines; this is 741 over it, 2.85× 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: DecisionSignalsPage apps/dsa-web/src/pages/DecisionSignalsPage.tsx:1— ClassTooLong — 1091 significant lines (blank, comment-only and punctuation-only lines excluded), 20 methods. The bar is 400 significant lines; this is 691 over it, 2.73× 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: SettingsPage apps/dsa-web/src/pages/SettingsPage.tsx:1— ClassTooLong — 918 significant lines (blank, comment-only and punctuation-only lines excluded), 16 methods. The bar is 400 significant lines; this is 518 over it, 2.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.
ClassTooLong: LLMChannelEditor apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1— ClassTooLong — 804 significant lines (blank, comment-only and punctuation-only lines excluded), 56 methods. The bar is 400 significant lines; this is 404 over it, 2.01× 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: AlertRuleForm apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:1— ClassTooLong — 582 significant lines (blank, comment-only and punctuation-only lines excluded), 4 methods. The bar is 400 significant lines; this is 182 over it, 1.46× 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: RunFlowGraph apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:1— ClassTooLong — 439 significant lines (blank, comment-only and punctuation-only lines excluded), 24 methods. The bar is 400 significant lines; this is 39 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.
ClassTooLong: BacktestPage apps/dsa-web/src/pages/BacktestPage.tsx:1— ClassTooLong — 414 significant lines (blank, comment-only and punctuation-only lines excluded), 14 methods. The bar is 400 significant lines; this is 14 over it, 1.04× 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.
Change coupling: HomePage.tsx ↔ stockPoolStore.ts apps/dsa-web/src/pages/HomePage.tsx:1— `apps/dsa-web/src/pages/HomePage.tsx` and `apps/dsa-web/src/stores/stockPoolStore.ts` change together 92% of the time (11 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 11 shared commits counted here, the most recent 3 are `ae19329d` fix: stabilize watchlist details and workspace state (#2126); `01ebf70a` feat: add reliable home watchlist workspace (#1984); `5eec5336` fix: refresh report after reanalysis completes (#1809) — run `git show` on any of them.
Change coupling: settingsHelp.ts ↔ REDACTED apps/dsa-web/src/locales/settingsHelp.ts:1— `apps/dsa-web/src/locales/settingsHelp.ts` and `REDACTED` change together 81% of the time (21 of the 26 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 21 shared commits counted here, the most recent 3 are `280cdb66` feat: integrate Miaoxiang data provider with safe monetary parsing (#…; `fb4735a1` feat: add Futu OpenD as optional HK realtime and fundamental data sou…; `5bb31392` fix: isolate runtime scheduler with portable watchdog (#2219) — run `git show` on any of them.
Change coupling: systemConfig.ts ↔ system_config_service.py apps/dsa-web/src/api/systemConfig.ts:1— `apps/dsa-web/src/api/systemConfig.ts` and `src/services/system_config_service.py` change together 80% of the time (8 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `7b39b73b` feat: add generation backend status diagnostics (#1883); `62adb5c4` feat: add Hermes local HTTP generation (#1824); `fef9dfca` feat: expose env config backup in web settings (#1253) — run `git show` on any of them.
Change coupling: systemConfig.ts ↔ system_config_service.py apps/dsa-web/src/types/systemConfig.ts:1— `apps/dsa-web/src/types/systemConfig.ts` and `src/services/system_config_service.py` change together 79% of the time (11 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 11 shared commits counted here, the most recent 3 are `7b39b73b` feat: add generation backend status diagnostics (#1883); `62adb5c4` feat: add Hermes local HTTP generation (#1824); `a75a0c50` feat: complete p6 notification channel cleanup (#1275) — run `git show` on any of them.
Change coupling: systemConfigI18n.ts ↔ config.py apps/dsa-web/src/utils/systemConfigI18n.ts:1— `apps/dsa-web/src/utils/systemConfigI18n.ts` and `src/config.py` change together 77% of the time (27 of the 35 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 27 shared commits counted here, the most recent 3 are `b740beea` fix: 公共 SearXNG 实例发现默认关闭 (#2226); `831ada53` feat: apply Bayesian skill outcome weights (#2123); `2643d47a` fix: 让 Agent Chat 默认遵循 REPORT_LANGUAGE (#2102) — run `git show` on any of them.
Change coupling: StockScreeningPage.tsx ↔ REDACTED apps/dsa-web/src/pages/StockScreeningPage.tsx:1— `apps/dsa-web/src/pages/StockScreeningPage.tsx` and `REDACTED` change together 55% of the time (6 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `5fa42fd9` feat: explain screening selections with evidence provenance (#2305); `e126c791` fix: 增强 AlphaSift 热点题材缓存回退 (#1691) (at that commit the file was still `src/services/alphasift_service.py`); `a81dc3b4` fix: optimize alphasift hotspot details (#1677) (at that commit the file was still `src/services/alphasift_service.py`) — run `git show` on any of them.
Change coupling: router.py ↔ REDACTED api/v1/router.py:1— `api/v1/router.py` and `REDACTED` change together 55% of the time (6 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `cd376085` feat: add intelligence source ingestion baseline (#1708); `ad15ebce` feat: 新增 DecisionSignal 持久化 API(#1390 P1) (#1645); `00028d41` feat: 新增告警 API MVP ( P1 )(#1202) (#1314) — run `git show` on any of them.
Change coupling: router.py ↔ __init__.py api/v1/router.py:1— `api/v1/router.py` and `api/v1/schemas/__init__.py` change together 55% of the time (6 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `0709b17e` feat: add data capability contract (#2289); `ad15ebce` feat: 新增 DecisionSignal 持久化 API(#1390 P1) (#1645); `00028d41` feat: 新增告警 API MVP ( P1 )(#1202) (#1314) — run `git show` on any of them.
Change coupling: systemConfig.ts ↔ REDACTED apps/dsa-web/src/types/systemConfig.ts:1— `apps/dsa-web/src/types/systemConfig.ts` and `REDACTED` change together 50% of the time (7 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `189b2fc3` fix: 补齐 Web 钉钉群机器人配置 (#2106); `a75a0c50` feat: complete p6 notification channel cleanup (#1275); `9f562384` feat: 支持 ntfy 一等通知渠道(P6-A) (#1271) — run `git show` on any of them.
Change coupling: screening.ts ↔ config.py apps/dsa-web/src/api/screening.ts:1— `apps/dsa-web/src/api/screening.ts` and `src/config.py` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 5 shared commits counted here, the most recent 3 are `29fa0504` fix: harden AlphaSift source stability (#1832) (at that commit the file was still `apps/dsa-web/src/api/alphasift.ts`); `0ed60102` fix: 升级 AlphaSift 并兼容热点详情龙头股字段 (#1714) (at that commit the file was still `apps/dsa-web/src/api/alphasift.ts`); `ecc370e5` feat: adapt AlphaSift hotspot contract (#1675) (at that commit the file was still `apps/dsa-web/src/api/alphasift.ts`) — run `git show` on any of them.
Duplicated block (13 lines × 2) bot/platforms/dingtalk.py:298— bot/platforms/dingtalk.py:298-310 | REDACTED:142-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. Read the line range as the matched WINDOW rather than a finished unit: at `bot/platforms/dingtalk.py:298` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) REDACTED:1653— REDACTED:1653-1665 | REDACTED:1796-1808 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1653` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) data_provider/efinance_fetcher.py:455— data_provider/efinance_fetcher.py:455-467 | data_provider/efinance_fetcher.py:548-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. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/efinance_fetcher.py:455` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) src/search_service.py:1123— src/search_service.py:1123-1136 | src/search_service.py:1317-1329 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/search_service.py:1137` calls `get` and `src/search_service.py:1330` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13 lines × 2) src/services/system_config_service.py:654— src/services/system_config_service.py:654-666 | src/services/system_config_service.py:678-690 — both copies are in the same file, so extract the block into 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) src/services/system_config_service.py:1169— src/services/system_config_service.py:1169-1181 | src/services/system_config_service.py:1188-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) src/services/system_config_service.py:3487— src/services/system_config_service.py:3487-3499 | src/services/system_config_service.py:4868-4880 — both copies are in the same file, so extract the block into 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) src/services/system_config_service.py:4169— src/services/system_config_service.py:4169-4181 | src/services/system_config_service.py:4316-4328 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) src/utils/data_processing.py:55— src/utils/data_processing.py:55-67 | src/utils/data_processing.py:107-119 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) data_provider/alphavantage_fetcher.py:108— data_provider/alphavantage_fetcher.py:108-114 | data_provider/finnhub_fetcher.py:91-97 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (7 lines × 2) data_provider/fundamental_adapter.py:486— data_provider/fundamental_adapter.py:486-492 | data_provider/fundamental_adapter.py:498-504 — both copies are in the same file, so extract the block into 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) scripts/generate_index_from_csv.py:815— scripts/generate_index_from_csv.py:815-821 | src/data/stock_index_loader.py:615-621 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 2) src/agent/orchestrator.py:1855— src/agent/orchestrator.py:1855-1861 | src/agent/orchestrator.py:1883-1889 — both copies are in the same file, so extract the block into 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) src/services/screening/config.py:531— src/services/screening/config.py:531-537 | src/services/screening/config.py:544-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) src/services/task_queue.py:873— src/services/task_queue.py:873-879 | src/services/task_queue.py:960-968 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/task_queue.py:960` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) src/share_image.py:792— src/share_image.py:792-798 | src/share_image.py:802-808 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (7 lines × 2) src/notification_sender/custom_webhook_sender.py:265— src/notification_sender/custom_webhook_sender.py:265-271 | src/services/system_config_service.py:3231-3237 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Skipped test: (unnamed test) apps/dsa-web/e2e/smoke.spec.ts:6— Skipped — switched off by test.skip
Skipped test: (unnamed test) apps/dsa-web/e2e/smoke.spec.ts:23— Skipped — switched off by test.skip
Skipped test: (unnamed test) apps/dsa-web/e2e/report-markdown.spec.ts:6— Skipped — switched off by test.skip
Skipped test: (unnamed test) apps/dsa-web/e2e/report-markdown.spec.ts:14— Skipped — switched off by test.skip
Skipped test: (unnamed test) REDACTED:230— Skipped — switched off by test.skip
Skipped test: renders navigation, theme toggle and completion badge apps/dsa-web/src/components/layout/__tests__/Shell.test.tsx:41— Skipped — switched off by it.skip
Skipped test: opens the theme menu from the sidebar toggle apps/dsa-web/src/components/layout/__tests__/Shell.test.tsx:60— Skipped — switched off by it.skip
Duplicated block (18 lines × 2) data_provider/base.py:4747— data_provider/base.py:4747-4764 | data_provider/base.py:4798-4815 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:4747` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 2) src/analyzer.py:342— src/analyzer.py:342-359 | src/analyzer.py:409-426 — both copies are in the same file, so extract the block into 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) src/market_phase_prompt.py:97— src/market_phase_prompt.py:97-114 | src/market_phase_prompt.py:118-135 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18 lines × 2) src/services/alert_service.py:314— src/services/alert_service.py:314-331 | src/services/alert_service.py:378-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `rule` to `PriceAlert` in one and `PriceChangeAlert` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (18 lines × 2) src/services/daily_market_context.py:664— src/services/daily_market_context.py:664-681 | src/services/daily_market_context.py:684-701 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18 lines × 2) REDACTED:4092— REDACTED:4092-4109 | REDACTED:4112-4129 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:4092` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) src/agent/codex_tool_process.py:409— src/agent/codex_tool_process.py:409-422 | src/agent/codex_tool_process.py:425-438 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) src/analysis_context_pack_prompt.py:168— src/analysis_context_pack_prompt.py:168-181 | src/analysis_context_pack_prompt.py:185-198 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (14 lines × 2) src/notification.py:1274— src/notification.py:1274-1287 | src/services/history_service.py:1133-1146 — 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) src/services/skill_opinion_outcome_service.py:211— src/services/skill_opinion_outcome_service.py:211-224 | src/services/skill_opinion_performance_service.py:163-176 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (14 lines × 2) src/services/system_config_service.py:1687— src/services/system_config_service.py:1687-1700 | src/services/system_config_service.py:1883-1896 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/system_config_service.py:1687` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/services/system_config_service.py:1702` calls `loads` and `src/services/system_config_service.py:1897` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 2) src/services/screening/daily.py:819— src/services/screening/daily.py:819-832 | src/services/screening/snapshot.py:621-634 — 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) bot/platforms/dingtalk_stream.py:278— bot/platforms/dingtalk_stream.py:278-294 | bot/platforms/feishu_stream.py:690-706 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) REDACTED:1270— REDACTED:1270-1286 | REDACTED:1420-1436 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1270` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) REDACTED:1288— REDACTED:1288-1304 | REDACTED:1438-1454 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1288` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) REDACTED:2020— REDACTED:2020-2036 | REDACTED:2063-2079 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:2020` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 2) src/services/system_config_service.py:4710— src/services/system_config_service.py:4710-4726 | src/services/system_config_service.py:4863-4879 — both copies are in the same file, so extract the block into 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) scripts/generate_index_from_csv.py:891— scripts/generate_index_from_csv.py:891-905 | src/data/stock_index_loader.py:686-700 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) src/agent/factory.py:611— src/agent/factory.py:611-625 | src/agent/factory.py:672-686 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agent/factory.py:611` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) src/analyzer.py:5211— src/analyzer.py:5211-5225 | src/analyzer.py:5241-5255 — both copies are in the same file, so extract the block into 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) src/services/portfolio_service.py:352— src/services/portfolio_service.py:352-366 | src/services/portfolio_service.py:434-448 — both copies are in the same file, so extract the block into 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) scripts/generate_index_from_csv.py:270— scripts/generate_index_from_csv.py:270-284 | scripts/generate_stock_index.py:38-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 both call sites, so a change lands once.
Off the main sequence: src/patches — src/patches: 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: src/utils — src/utils: 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: src/data — src/data: abstractness 0.00, instability 0.14, distance 0.86 — zone of pain — concrete and depended on by 6 project(s), so it's rigid to change.
Off the main sequence: src/llm — src/llm: abstractness 0.03, instability 0.20, distance 0.77 — zone of pain — concrete and depended on by 4 project(s), so it's rigid to change.
Off the main sequence: src/schemas — src/schemas: abstractness 0.00, instability 0.25, distance 0.75 — zone of pain — concrete and depended on by 6 project(s), so it's rigid to change.
Duplicated block (24 lines × 2) src/core/backtest_engine.py:177— src/core/backtest_engine.py:177-201 | src/core/backtest_engine.py:288-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (24 lines × 2) src/notification.py:1230— src/notification.py:1230-1253 | src/services/history_service.py:1521-1544 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (24 lines × 2) src/notification.py:1571— src/notification.py:1571-1594 | src/services/history_service.py:1430-1453 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (24 lines × 2) src/search_service.py:3236— src/search_service.py:3236-3259 | src/search_service.py:3288-3311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20–21 lines × 2) REDACTED:1172— REDACTED:1172-1191 | REDACTED:1577-1597 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1172` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:1170` calls `info` and `REDACTED:1575` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (20–21 lines × 2) data_provider/efinance_fetcher.py:709— data_provider/efinance_fetcher.py:709-729 | data_provider/efinance_fetcher.py:892-911 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/efinance_fetcher.py:709` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20–21 lines × 2) src/services/alert_service.py:446— src/services/alert_service.py:446-465 | src/services/alert_service.py:546-566 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20–21 lines × 2) src/services/daily_market_context.py:213— src/services/daily_market_context.py:213-233 | src/services/daily_market_context.py:528-547 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/daily_market_context.py:213` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19 lines × 2) REDACTED:454— REDACTED:454-472 | data_provider/efinance_fetcher.py:332-350 — 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 (19 lines × 2) src/config.py:265— src/config.py:265-283 | src/config.py:310-328 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (19 lines × 2) src/core/pipeline.py:1719— src/core/pipeline.py:1719-1737 | src/core/pipeline.py:1747-1765 — both copies are in the same file, so extract the block into 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) src/services/screening/filter.py:256— src/services/screening/filter.py:256-274 | src/services/screening/filter.py:356-374 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15 lines × 2 locations) apps/dsa-web/src/components/report/ReportMarkdown.tsx:7— apps/dsa-web/src/components/report/ReportMarkdown.tsx:7 · apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:11 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Duplicated block (15 lines × 2 locations) apps/dsa-web/src/hooks/useWatchlist.ts:70— apps/dsa-web/src/hooks/useWatchlist.ts:70 · apps/dsa-web/src/hooks/useWatchlist.ts:86 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (15 lines × 2 locations) apps/dsa-web/src/pages/HomePage.tsx:1777— apps/dsa-web/src/pages/HomePage.tsx:1777 · apps/dsa-web/src/pages/HomePage.tsx:1823 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Duplicated block (15 lines × 2 locations) apps/dsa-web/src/pages/PortfolioPage.tsx:1113— apps/dsa-web/src/pages/PortfolioPage.tsx:1113 · apps/dsa-web/src/pages/PortfolioPage.tsx:1136 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (13 lines × 2 locations) apps/dsa-web/src/components/common/EmptyState.tsx:7— apps/dsa-web/src/components/common/EmptyState.tsx:7 · apps/dsa-web/src/components/common/PageHeader.tsx:7 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (13 lines × 2 locations) apps/dsa-web/src/components/settings/AuthSettingsCard.tsx:160— apps/dsa-web/src/components/settings/AuthSettingsCard.tsx:160 · apps/dsa-web/src/components/settings/AuthSettingsCard.tsx:173 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Duplicated block (13 lines × 2 locations) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2187— apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2187 · apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2281 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (13 lines × 2 locations) apps/dsa-web/src/pages/PortfolioPage.tsx:819— apps/dsa-web/src/pages/PortfolioPage.tsx:819 · apps/dsa-web/src/pages/PortfolioPage.tsx:833 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
X17 · Uncapped recursion over a caller-supplied document· Recursive walk over a caller-supplied document has no depth cap · ×4
Recursive walk over a caller-supplied document has no depth cap src/agent/provider_trace.py:272— `strip_trace_metadata` is public, takes a document from its caller (line 229) and hands it to `_strip_trace_metadata_value`, which calls itself at line 272 (`_strip_trace_metadata_value`) with a piece of `value` (and at line 277) — and nowhere in `_strip_trace_metadata_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_strip_trace_metadata_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
Recursive walk over a caller-supplied document has no depth cap src/llm/usage.py:843— `attach_legacy_message_stability_audit` is public, takes a document from its caller (line 485) and hands it to `_plain_value`, which calls itself at line 843 (`_plain_value`) with a piece of `value` (and at line 845, line 853) — and nowhere in `_plain_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_plain_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
Recursive walk over a caller-supplied document has no depth cap src/utils/sniper_points.py:119— `find_sniper_points` is public and takes `data: Mapping[str, Any]` from its caller, and it calls itself at line 119 (`find_sniper_points`) with a piece of `data` — and nowhere in `find_sniper_points` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `find_sniper_points` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
Recursive walk over a caller-supplied document has no depth cap src/utils/sanitize.py:102— `redact_sensitive_mapping` is public and takes `obj: Any` from its caller, and it calls itself at line 102 (`redact_sensitive_mapping`) with a piece of `obj` (and at line 105) — and nowhere in `redact_sensitive_mapping` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `redact_sensitive_mapping` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
AC4 · Keyboard semantics· Modal dialog does not manage focus · ×3
Modal dialog does not manage focus apps/dsa-web/src/components/common/Drawer.tsx:79— This <div role="dialog"> is a modal dialog, but nothing moves focus into it when it opens and nothing keeps focus inside it while it is open, so a keyboard or screen-reader user keeps acting on the content behind it (WCAG 2.4.3). Use a native <dialog> opened with showModal(), a dialog component that traps focus, or move focus to the dialog on open, trap Tab inside it (or make the page behind inert) and return focus to the control that opened it on close.
Modal dialog does not manage focus apps/dsa-web/src/components/layout/DesktopUpdateIndicator.tsx:101— This <div role="dialog"> is a modal dialog, but nothing moves focus into it when it opens and nothing keeps focus inside it while it is open, so a keyboard or screen-reader user keeps acting on the content behind it (WCAG 2.4.3). Use a native <dialog> opened with showModal(), a dialog component that traps focus, or move focus to the dialog on open, trap Tab inside it (or make the page behind inert) and return focus to the control that opened it on close.
Modal dialog does not manage focus apps/dsa-web/src/components/market-review/MarketReviewRegionSelector.tsx:122— This <div role="dialog"> is a modal dialog, but focus is moved into it, but nothing keeps it there: Tab walks out to the page behind, so a keyboard or screen-reader user keeps acting on the content behind it (WCAG 2.4.3). Use a native <dialog> opened with showModal(), a dialog component that traps focus, or move focus to the dialog on open, trap Tab inside it (or make the page behind inert) and return focus to the control that opened it on close.
Change-coupling hub: portfolio_service.py → portfolio.py, PortfolioPage.tsx, portfolio.ts src/services/portfolio_service.py— `src/services/portfolio_service.py` changes together with 3 other files — `api/v1/schemas/portfolio.py`, `apps/dsa-web/src/pages/PortfolioPage.tsx`, `apps/dsa-web/src/types/portfolio.ts` — none of which declares a dependency on it: one file is the hub of 3 separate couplings, not 3 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 3.
Change-coupling hub: market.py → main.py, pipeline.py, search_service.py bot/commands/market.py— `bot/commands/market.py` changes together with 3 other files — `main.py`, `src/core/pipeline.py`, `src/search_service.py` — none of which declares a dependency on it: one file is the hub of 3 separate couplings, not 3 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 3.
Change-coupling hub: system_config.py → systemConfig.ts, LLMChannelEditor.tsx, SettingsPage.tsx api/v1/endpoints/system_config.py— `api/v1/endpoints/system_config.py` changes together with 3 other files — `apps/dsa-web/src/api/systemConfig.ts`, `apps/dsa-web/src/components/settings/LLMChannelEditor.tsx`, `apps/dsa-web/src/pages/SettingsPage.tsx` — none of which declares a dependency on it: one file is the hub of 3 separate couplings, not 3 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 3.
Duplicated block (26 lines × 2) REDACTED:1900— REDACTED:1900-1925 | data_provider/efinance_fetcher.py:1278-1304 — 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 (26 lines × 2) data_provider/base.py:4015— data_provider/base.py:4015-4040 | data_provider/base.py:4372-4397 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:4015` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `data_provider/base.py:4371` calls `_consume_budget` and `data_provider/base.py:4015` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (26 lines × 2) src/agent/skills/aggregator.py:178— src/agent/skills/aggregator.py:178-203 | src/agent/skills/engine.py:221-246 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17–18 lines × 2) data_provider/base.py:2645— data_provider/base.py:2645-2662 | data_provider/base.py:2665-2681 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (17–18 lines × 2) src/repositories/backtest_repo.py:207— src/repositories/backtest_repo.py:207-223 | src/repositories/backtest_repo.py:249-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. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (17–18 lines × 2) src/services/system_config_service.py:3456— src/services/system_config_service.py:3456-3472 | src/services/system_config_service.py:4841-4858 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14–15 lines × 2) src/market_phase_prompt.py:144— src/market_phase_prompt.py:144-158 | src/market_phase_prompt.py:170-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. Read the line range as the matched WINDOW rather than a finished unit: at `src/market_phase_prompt.py:144` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14–15 lines × 2) src/services/portfolio_service.py:536— src/services/portfolio_service.py:536-549 | src/services/portfolio_service.py:551-565 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/portfolio_service.py:536` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (14–15 lines × 2) src/services/screening/ranker.py:342— src/services/screening/ranker.py:342-355 | src/services/screening/ranker.py:362-376 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/screening/ranker.py:362` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/services/screening/ranker.py:339` calls `max`, `_truncate_prompt_text`, `_render_ranking_prompt` and `src/services/screening/ranker.py:362` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 3) api/v1/endpoints/portfolio.py:242— api/v1/endpoints/portfolio.py:242-250 | api/v1/endpoints/portfolio.py:320-328 | api/v1/endpoints/portfolio.py:403-411 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 3) REDACTED:801— REDACTED:801-809 | REDACTED:862-870 | REDACTED:960-968 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:801` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) REDACTED:817— REDACTED:817-825 | REDACTED:912-920 | REDACTED:976-984 — 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 (19 lines × 2 locations) apps/dsa-web/src/components/i18n/UiLanguageToggle.tsx:8— apps/dsa-web/src/components/i18n/UiLanguageToggle.tsx:8 · apps/dsa-web/src/components/theme/ThemeToggle.tsx:33 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Duplicated block (19 lines × 2 locations) apps/dsa-web/src/components/report/MarketReviewReportView.tsx:514— apps/dsa-web/src/components/report/MarketReviewReportView.tsx:514 · apps/dsa-web/src/components/report/MarketReviewReportView.tsx:533 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Duplicated block (19 lines × 2 locations) apps/dsa-web/src/pages/ChatPage.tsx:800— apps/dsa-web/src/pages/ChatPage.tsx:800 · apps/dsa-web/src/pages/ChatPage.tsx:941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2 locations) apps/dsa-web/src/components/common/SectionCard.tsx:4— apps/dsa-web/src/components/common/SectionCard.tsx:4 · apps/dsa-web/src/components/settings/SettingsSectionCard.tsx:4 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Duplicated block (16 lines × 2 locations) apps/dsa-web/src/components/history/HistoryListItem.tsx:29— apps/dsa-web/src/components/history/HistoryListItem.tsx:29 · apps/dsa-web/src/components/history/StockBarItem.tsx:30 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it.
Duplicated block (16 lines × 2 locations) apps/dsa-web/src/components/settings/IntelligentImport.tsx:310— apps/dsa-web/src/components/settings/IntelligentImport.tsx:310 · apps/dsa-web/src/components/settings/IntelligentImport.tsx: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 (14 lines × 2 locations) apps/dsa-web/src/components/report/ReportMarkdownDrawer.tsx:67— apps/dsa-web/src/components/report/ReportMarkdownDrawer.tsx:67 · apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:157 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (14 lines × 2 locations) apps/dsa-web/src/pages/StockScreeningPage.tsx:75— apps/dsa-web/src/pages/StockScreeningPage.tsx:75 · apps/dsa-web/src/pages/StockScreeningPage.tsx:774 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (14 lines × 2 locations) apps/dsa-web/src/pages/StockScreeningPage.tsx:2087— apps/dsa-web/src/pages/StockScreeningPage.tsx:2087 · apps/dsa-web/src/pages/StockScreeningPage.tsx:2101 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Duplicated block (12 lines × 2 locations) apps/dsa-web/src/components/common/Select.tsx:72— apps/dsa-web/src/components/common/Select.tsx:72 · apps/dsa-web/src/pages/ChatPage.tsx:802 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another.
Duplicated block (12 lines × 2 locations) apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:338— apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:338 · apps/dsa-web/src/components/report/ReportDiagnostics.tsx:305 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it.
Duplicated block (12 lines × 2 locations) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2142— apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2142 · apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2300 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Near-duplicate member pair (52 shared lines) REDACTED:1118— REDACTED:1118-1216 | REDACTED:1523-1619 — These two members are variants of one another: 52 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (52 shared lines) REDACTED:694— REDACTED:694-792 | REDACTED:795-945 — These two members are variants of one another: 52 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.
Duplicated block (36 lines × 3) REDACTED:2111— REDACTED:2111-2146 | data_provider/efinance_fetcher.py:1077-1112 | data_provider/tushare_fetcher.py:976-1011 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (36 lines × 3) REDACTED:2148— REDACTED:2148-2183 | data_provider/efinance_fetcher.py:1114-1149 | data_provider/tushare_fetcher.py:1013-1048 — 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. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (30 lines × 2) main.py:338— main.py:338-367 | main.py:399-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. Read the line range as the matched WINDOW rather than a finished unit: at `main.py:338` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (30 lines × 2) src/formatters.py:664— src/formatters.py:664-693 | src/formatters.py:1068-1097 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/formatters.py:664` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (21 lines × 2) api/v1/endpoints/auth.py:267— api/v1/endpoints/auth.py:267-287 | api/v1/endpoints/auth.py:295-315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (21 lines × 2) src/llm/local_cli_backend.py:876— src/llm/local_cli_backend.py:876-896 | src/llm/local_cli_backend.py:1253-1273 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19–20 lines × 2) api/v1/endpoints/analysis.py:221— api/v1/endpoints/analysis.py:221-239 | api/v1/endpoints/history.py:201-220 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19–20 lines × 2) bot/dispatcher.py:498— bot/dispatcher.py:498-517 | bot/dispatcher.py:564-582 — both copies are in the same file, so extract the block into 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) bot/dispatcher.py:519— bot/dispatcher.py:519-536 | bot/dispatcher.py:584-599 — both copies are in the same file, so extract the block into 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) src/agent/orchestrator.py:1390— src/agent/orchestrator.py:1390-1407 | src/agent/orchestrator.py:1419-1434 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 3) src/search_service.py:1104— src/search_service.py:1104-1116 | src/search_service.py:1287-1299 | src/search_service.py:1704-1716 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/search_service.py:1104` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 3) src/services/market_hotspot_service.py:663— src/services/market_hotspot_service.py:663-675 | src/services/market_structure_service.py:667-679 | src/utils/data_processing.py:82-94 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12–13 lines × 2) src/repositories/backtest_repo.py:238— src/repositories/backtest_repo.py:238-250 | src/repositories/backtest_repo.py:309-320 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/repositories/backtest_repo.py:238` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–13 lines × 2) REDACTED:3691— REDACTED:3691-3702 | REDACTED:3711-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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:3711` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 2) data_provider/tencent_fetcher.py:210— data_provider/tencent_fetcher.py:210-221 | data_provider/tickflow_fetcher.py:530-540 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–12 lines × 2) scripts/fetch_tushare_stock_list.py:127— scripts/fetch_tushare_stock_list.py:127-137 | scripts/fetch_tushare_stock_list.py:346-357 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10–11 lines × 2) src/core/pipeline.py:878— src/core/pipeline.py:878-888 | src/core/pipeline.py:1613-1622 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/core/pipeline.py:878` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) src/services/portfolio_risk_service.py:288— src/services/portfolio_risk_service.py:288-297 | src/services/portfolio_risk_service.py:343-353 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/services/portfolio_risk_service.py:342` calls `str`, `get`, `strip` and `src/services/portfolio_risk_service.py:287` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 3) src/repositories/portfolio_repo.py:600— src/repositories/portfolio_repo.py:600-609 | src/repositories/portfolio_repo.py:644-653 | src/repositories/portfolio_repo.py:691-700 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/repositories/portfolio_repo.py:600` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) src/services/run_diagnostics.py:589— src/services/run_diagnostics.py:589-598 | src/services/run_flow.py:1461-1470 | src/services/run_flow.py:1479-1488 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 3) REDACTED:2100— REDACTED:2100-2107 | data_provider/efinance_fetcher.py:1066-1073 | data_provider/tushare_fetcher.py:965-972 — 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.
Duplicated block (8 lines × 3) src/services/screening/post_analysis.py:374— src/services/screening/post_analysis.py:374-381 | src/services/screening/ranker.py:1162-1169 | src/services/screening/risk.py:324-331 — 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. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (6–8 lines × 2) data_provider/base.py:284— data_provider/base.py:284-291 | src/services/stock_code_utils.py:138-143 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6–8 lines × 2) REDACTED:719— REDACTED:719-724 | REDACTED:847-854 — both copies are in the same file, so extract the block into 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–7 lines × 2) REDACTED:151— REDACTED:151-157 | data_provider/base.py:174-179 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6–7 lines × 2) src/analyzer.py:3399— src/analyzer.py:3399-3405 | src/services/system_config_service.py:2013-2018 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (21 lines × 2 locations) apps/dsa-web/src/components/report/ReportDetails.tsx:114— apps/dsa-web/src/components/report/ReportDetails.tsx:114 · apps/dsa-web/src/components/report/ReportDetails.tsx:140 — all 2 copies are in the same file, and the CITED SPAN is a run of DECLARATIONS inside a construct — the members of a type, or the entries of an object or array literal — with no statement anywhere in it. Do not read this as an extract-a-helper row: nothing here executes, so there is no call site, and a call expression cannot stand where a member declaration or a literal's entry was. What repeats is a SHAPE, and which shape decides the move. Where the copies declare the same members, the repetition is a missing common ancestor: give it a base type, an interface both extend, a generic instantiated twice, or — where the copies are a literal's entries rather than a type's members — one shared constant each site spreads or refers to, so the set is written once. Where they declare DIFFERENT members and only the form is shared — a decorator and its options, an annotation, a registration table's keys — the form is prescribed by a framework or a schema rather than copied, and the only collapse available is to generate the declarations from that schema; where you do not own the generator, this is the cost of the framework and there is nothing to extract. Check which of the two it is before acting: these copies still drift apart the first time only one of them is edited, which is why the repetition is reported, but the sentence to act on is not the same in both cases.
Duplicated block (21 lines × 2 locations) apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:105— apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:105 · apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:126 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
R4 · Test Coverage· No test reaches this file · ×2
No test reaches this file apps/dsa-desktop/scripts/afterPackMacos.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file apps/dsa-web/src/main.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
AC1 · Text alternatives· <canvas> without a text alternative · ×1
<canvas> without a text alternative apps/dsa-web/src/components/common/ParticleBackground.tsx:152— A <canvas> with no aria-label/title and no inner fallback content can't be described by assistive tech. Add a name or fallback content.
AC2 · Forms & labels· <Select> field component without a label · ×1
<Select> field component without a label apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2415— This UI-library field component is named only by a placeholder — a placeholder is not a label (it vanishes as soon as the user types, and many assistive technologies ignore it). Give it a real name whichever way this library supports: a label prop, an aria-label, or an id on the rendered control with a <label htmlFor> pointing at it. For a group of controls, name the group itself (aria-label, or a fieldset with a legend) — labelling each item leaves the set unnamed.
AC3 · Page structure· Page without a main landmark · ×1
Page without a main landmark apps/dsa-desktop/renderer/loading.html:2— No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
AC3 · Page structure· Heading level jumps from h2 to h4 · ×1
Heading level jumps from h2 to h4 apps/dsa-web/src/components/report/ReportOverview.tsx:334— Skipping heading levels breaks the document outline assistive tech relies on. Don't jump levels — increase by at most one.
Focus outline removed inline apps/dsa-web/src/components/common/Input.tsx:135— <input> takes keyboard focus, and its outline-none utility removes the focus ring with no focus-state ring, shadow, border or outline utility in its place. Add one (e.g. focus-visible:ring-2).
AC7 · A11y enforcement· Accessibility enforcement below the top rung · ×1
Accessibility enforcement below the top rung — No accessibility enforcement found — no a11y linter (eslint-plugin-jsx-a11y) and no axe/pa11y/Lighthouse in tests or CI. Start with the linter to catch issues at author time. What was searched, so you can tell an absence from a miss: the 105 markup file(s) this pass actually assessed, the linter configuration checked in beside them, and this repository's test and CI files — matched by name against the accessibility checkers this dimension carries. An audit run outside the repository, a hosted scanner, or a check whose name is not one of those, is not seen here.
PortfolioPage.PortfolioPage (cyclomatic 253) apps/dsa-web/src/pages/PortfolioPage.tsx:624— PortfolioPage.PortfolioPage has cyclomatic complexity 253 (threshold 15). Of this number, 105 points are the body's own statements and 148 belong to 40 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.
StockScreeningPage.StockScreeningPage (cyclomatic 251) apps/dsa-web/src/pages/StockScreeningPage.tsx:841— StockScreeningPage.StockScreeningPage has cyclomatic complexity 251 (threshold 15). Of this number, 94 points are the body's own statements and 157 belong to 41 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.
HomePage.HomePage (cyclomatic 213) apps/dsa-web/src/pages/HomePage.tsx:252— HomePage.HomePage has cyclomatic complexity 213 (threshold 15). Of this number, 43 points are the body's own statements and 170 belong to 59 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SettingsPage.SettingsPage (cyclomatic 174) apps/dsa-web/src/pages/SettingsPage.tsx:688— SettingsPage.SettingsPage has cyclomatic complexity 174 (threshold 15). Of this number, 117 points are the body's own statements and 57 belong to 20 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.
Config._load_from_env (cyclomatic 130) src/config.py:1492— Config._load_from_env has cyclomatic complexity 130 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Config.validate_structured (cyclomatic 123) src/config.py:3241— Config.validate_structured has cyclomatic complexity 123 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
GeminiAnalyzer._format_prompt (cyclomatic 109) src/analyzer.py:4313— GeminiAnalyzer._format_prompt has cyclomatic complexity 109 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RunFlowGraph.RunFlowGraph (cyclomatic 94) apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:314— RunFlowGraph.RunFlowGraph has cyclomatic complexity 94 (threshold 15). Most of this is not in the body itself: 6 of the 94 points are its own statements and the rest belongs to 25 function literals inside it that branch (lines 568, 746, 392, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
DataFetcherManager.get_realtime_quote (cyclomatic 87) data_provider/base.py:2432— DataFetcherManager.get_realtime_quote 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.
main.run_full_analysis (cyclomatic 86) main.py:800— main.run_full_analysis has cyclomatic complexity 86 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StockAnalysisPipeline.analyze_stock (cyclomatic 85) src/core/pipeline.py:434— StockAnalysisPipeline.analyze_stock has cyclomatic complexity 85 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StockAnalysisPipeline._analyze_with_agent (cyclomatic 80) src/core/pipeline.py:1460— StockAnalysisPipeline._analyze_with_agent 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.
main.main (cyclomatic 78) main.py:1549— main.main has cyclomatic complexity 78 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
stockPoolStore.useStockPoolStore (cyclomatic 77) apps/dsa-web/src/stores/stockPoolStore.ts:615— stockPoolStore.useStockPoolStore has cyclomatic complexity 77 (threshold 15). Most of this is not in the body itself: 1 of the 77 points is its own statement and the rest belongs to 22 function literals inside it that branch (lines 886, 714, 851, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
StockAnalysisPipeline._send_notifications (cyclomatic 75) src/core/pipeline.py:3805— StockAnalysisPipeline._send_notifications has cyclomatic complexity 75 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AgentOrchestrator._finalize_dashboard_payload (cyclomatic 73) src/agent/orchestrator.py:1414— AgentOrchestrator._finalize_dashboard_payload has cyclomatic complexity 73 (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.
pipeline.screen (cyclomatic 69) src/services/screening/pipeline.py:51— pipeline.screen 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.
ChatPage.ChatPage (cyclomatic 64) apps/dsa-web/src/pages/ChatPage.tsx:83— ChatPage.ChatPage has cyclomatic complexity 64 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (ChatPage.ChatPage::getCurrentStage) 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.
YfinanceFundamentalAdapter.get_fundamental_bundle (cyclomatic 63) data_provider/yfinance_fundamental_adapter.py:158— YfinanceFundamentalAdapter.get_fundamental_bundle 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.
LLMChannelEditor.ChannelRow (cyclomatic 63) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:399— LLMChannelEditor.ChannelRow has cyclomatic complexity 63 (threshold 15). Of this number, 59 points are the body's own statements and 4 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NotificationService.generate_dashboard_report (cyclomatic 60) src/notification.py:1255— NotificationService.generate_dashboard_report 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.
BacktestPage.BacktestPage (cyclomatic 60) apps/dsa-web/src/pages/BacktestPage.tsx:246— BacktestPage.BacktestPage has cyclomatic complexity 60 (threshold 15). Of this number, 23 points are the body's own statements and 37 belong to 6 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.
share_image._market_data (cyclomatic 59) src/share_image.py:1407— share_image._market_data 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.
HistoryService._generate_single_stock_markdown (cyclomatic 57) src/services/history_service.py:1112— HistoryService._generate_single_stock_markdown 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.
Config._parse_llm_channels_with_issues (cyclomatic 55) src/config.py:2492— Config._parse_llm_channels_with_issues 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.
screening_service._attach_candidate_explanations (cyclomatic 55) REDACTED:3984— screening_service._attach_candidate_explanations 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.
SearchService.search_stock_news (cyclomatic 54) src/search_service.py:4021— SearchService.search_stock_news 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.
IntelligentImport.IntelligentImport (cyclomatic 54) apps/dsa-web/src/components/settings/IntelligentImport.tsx:100— IntelligentImport.IntelligentImport has cyclomatic complexity 54 (threshold 15). Of this number, 20 points are the body's own statements and 34 belong to 14 function literals inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
GeminiAnalyzer._call_litellm_impl (cyclomatic 52) src/analyzer.py:3604— GeminiAnalyzer._call_litellm_impl 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.
MarketReviewReportView.MarketReviewReportView (cyclomatic 52) apps/dsa-web/src/components/report/MarketReviewReportView.tsx:363— MarketReviewReportView.MarketReviewReportView has cyclomatic complexity 52 (threshold 15). Of this number, 29 points are the body's own statements and 23 belong to 10 function literals inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
RunFlowNodeDetails.RunFlowNodeDetails (cyclomatic 52) apps/dsa-web/src/components/run-flow/RunFlowNodeDetails.tsx:111— RunFlowNodeDetails.RunFlowNodeDetails has cyclomatic complexity 52 (threshold 15). Of this number, 28 points are the body's own statements and 24 belong to 10 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.
CodexToolProcessRunner.execute (cyclomatic 51) src/agent/codex_tool_process.py:327— CodexToolProcessRunner.execute has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SystemConfigService._validate_value (cyclomatic 51) src/services/system_config_service.py:2560— SystemConfigService._validate_value has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DataFetcherManager.get_daily_data (cyclomatic 50) data_provider/base.py:1919— DataFetcherManager.get_daily_data 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.
chat_object_decision.decide_chat_object (cyclomatic 50) src/agent/chat_object_decision.py:165— chat_object_decision.decide_chat_object 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.
DataFetcherManager.get_fundamental_context (cyclomatic 49) data_provider/base.py:4295— DataFetcherManager.get_fundamental_context has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
generate_index_from_csv.validate_index_registry (cyclomatic 49) scripts/generate_index_from_csv.py:774— generate_index_from_csv.validate_index_registry has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
usage.normalize_litellm_usage (cyclomatic 49) src/llm/usage.py:275— usage.normalize_litellm_usage has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NotificationService.generate_daily_report (cyclomatic 49) src/notification.py:902— NotificationService.generate_daily_report has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
GenerationBackendStatusService._parse_llm_channels_from_map (cyclomatic 49) src/services/generation_backend_status_service.py:835— GenerationBackendStatusService._parse_llm_channels_from_map has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StockAnalysisPipeline.run (cyclomatic 48) src/core/pipeline.py:3398— StockAnalysisPipeline.run 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.
NotificationService.generate_wechat_dashboard (cyclomatic 48) src/notification.py:1624— NotificationService.generate_wechat_dashboard 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.
hotspot.get_hotspot_detail (cyclomatic 48) src/services/screening/hotspot.py:417— hotspot.get_hotspot_detail 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.
SystemConfigService._collect_setup_channel_models (cyclomatic 48) src/services/system_config_service.py:3452— SystemConfigService._collect_setup_channel_models 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.
DataFetcherManager._build_offshore_fundamental_context (cyclomatic 47) data_provider/base.py:3949— DataFetcherManager._build_offshore_fundamental_context has cyclomatic complexity 47 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
stock_code_utils.resolve_daily_stock_identity (cyclomatic 47) src/services/stock_code_utils.py:339— stock_code_utils.resolve_daily_stock_identity has cyclomatic complexity 47 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ReportDiagnostics.ReportDiagnostics (cyclomatic 47) apps/dsa-web/src/components/report/ReportDiagnostics.tsx:165— ReportDiagnostics.ReportDiagnostics has cyclomatic complexity 47 (threshold 15). Of this number, 29 points are the body's own statements and 18 belong to 8 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
stock_list_parser.parse_analysis_target (cyclomatic 46) src/services/stock_list_parser.py:632— stock_list_parser.parse_analysis_target 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.
SystemConfigService._validate_llm_channel_map (cyclomatic 46) src/services/system_config_service.py:4642— SystemConfigService._validate_llm_channel_map 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.
StockAnalysisPipeline._enhance_context (cyclomatic 45) src/core/pipeline.py:1002— StockAnalysisPipeline._enhance_context 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.
run_flow._append_active_flow_events (cyclomatic 45) src/services/run_flow.py:935— run_flow._append_active_flow_events 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.
screening_service._build_dsa_candidate_context (cyclomatic 45) REDACTED:3612— screening_service._build_dsa_candidate_context 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.
MarketAnalyzer._build_review_prompt (cyclomatic 44) src/market_analyzer.py:1652— MarketAnalyzer._build_review_prompt 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.
HistoryService._history_code_filter_candidates (cyclomatic 44) src/services/history_service.py:108— HistoryService._history_code_filter_candidates 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.
web_intent_resolver._classify_rule (cyclomatic 43) src/agent/web_intent_resolver.py:527— web_intent_resolver._classify_rule 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.
web_intent_resolver._consume_confirmations (cyclomatic 43) src/agent/web_intent_resolver.py:975— web_intent_resolver._consume_confirmations 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.
PortfolioPage.buildExposureRows (cyclomatic 43) apps/dsa-web/src/pages/PortfolioPage.tsx:372— PortfolioPage.buildExposureRows has cyclomatic complexity 43 (threshold 15). Of this number, 41 points are the body's own statements and 2 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
analysis_tools._handle_analyze_pattern (cyclomatic 42) src/agent/tools/analysis_tools.py:324— analysis_tools._handle_analyze_pattern 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.
SystemConfigService._validate_llm_runtime_selection (cyclomatic 42) src/services/system_config_service.py:5099— SystemConfigService._validate_llm_runtime_selection 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.
SystemConfigService._collect_llm_channel_models_from_map (cyclomatic 41) src/services/system_config_service.py:4832— SystemConfigService._collect_llm_channel_models_from_map 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.
decisionAction.getLegacyDecisionAction (cyclomatic 41) apps/dsa-web/src/utils/decisionAction.ts:94— decisionAction.getLegacyDecisionAction has cyclomatic complexity 41 (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.
analysis.get_analysis_status (cyclomatic 40) api/v1/endpoints/analysis.py:1170— analysis.get_analysis_status 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.
BacktestEngine.compute_summary (cyclomatic 40) src/core/backtest_engine.py:367— BacktestEngine.compute_summary 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.
SearchService._score_news_relevance (cyclomatic 40) src/search_service.py:3186— SearchService._score_news_relevance 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.
share_image._stock_data_from_payload (cyclomatic 40) src/share_image.py:1123— share_image._stock_data_from_payload 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.
DecisionSignalsPage.DecisionSignalsPage::renderReassessPanel (cyclomatic 40) apps/dsa-web/src/pages/DecisionSignalsPage.tsx:966— DecisionSignalsPage.DecisionSignalsPage::renderReassessPanel 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. This shape REPEATS in the file: one other method here (DecisionSignalsPage.DecisionSignalsPage) 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.
AgentOrchestrator._execute_pipeline (cyclomatic 39) src/agent/orchestrator.py:567— AgentOrchestrator._execute_pipeline 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.
stock_index_loader._validate_index_rows_semantics (cyclomatic 39) src/data/stock_index_loader.py:597— stock_index_loader._validate_index_rows_semantics 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.
PortfolioService._replay_account (cyclomatic 39) src/services/portfolio_service.py:781— PortfolioService._replay_account 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.
share_image._stock_data (cyclomatic 39) src/share_image.py:953— share_image._stock_data 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.
web_intent_resolver._merge_llm_result (cyclomatic 38) src/agent/web_intent_resolver.py:1292— web_intent_resolver._merge_llm_result 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.
StockAnalysisPipeline._agent_result_to_analysis_result (cyclomatic 38) src/core/pipeline.py:2133— StockAnalysisPipeline._agent_result_to_analysis_result 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.
share_image._market_data_from_payload (cyclomatic 38) src/share_image.py:1586— share_image._market_data_from_payload 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.
AuthSettingsCard.AuthSettingsCard (cyclomatic 38) apps/dsa-web/src/components/settings/AuthSettingsCard.tsx:22— AuthSettingsCard.AuthSettingsCard has cyclomatic complexity 38 (threshold 15). Of this number, 22 points are the body's own statements and 16 belong to 2 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DecisionSignalsPage.DecisionSignalsPage (cyclomatic 38) apps/dsa-web/src/pages/DecisionSignalsPage.tsx:388— DecisionSignalsPage.DecisionSignalsPage 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. This shape REPEATS in the file: one other method here (DecisionSignalsPage.DecisionSignalsPage::renderReassessPanel) 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.
YfinanceFetcher.get_realtime_quote (cyclomatic 37) REDACTED:794— YfinanceFetcher.get_realtime_quote has cyclomatic complexity 37 (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.
web_intent_resolver._token_facts (cyclomatic 37) src/agent/web_intent_resolver.py:368— web_intent_resolver._token_facts 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.
analyzer.stabilize_decision_with_structure (cyclomatic 37) src/analyzer.py:1043— analyzer.stabilize_decision_with_structure has cyclomatic complexity 37 (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.
LocalCliGenerationBackend.generate (cyclomatic 37) src/llm/local_cli_backend.py:2095— LocalCliGenerationBackend.generate 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.
runner.run_agent_loop (cyclomatic 36) src/agent/runner.py:326— runner.run_agent_loop 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.
screening_service._normalize_candidate (cyclomatic 36) REDACTED:3861— screening_service._normalize_candidate has cyclomatic complexity 36 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
stockCode.normalizeStockCode (cyclomatic 36) apps/dsa-web/src/utils/stockCode.ts:16— stockCode.normalizeStockCode 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.
DesktopUpdateIndicator.DesktopUpdateIndicator (cyclomatic 36) apps/dsa-web/src/components/layout/DesktopUpdateIndicator.tsx:12— DesktopUpdateIndicator.DesktopUpdateIndicator has cyclomatic complexity 36 (threshold 15). Of this number, 32 points are the body's own statements and 4 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HomeStockWorkspace.HomeStockWorkspace (cyclomatic 36) apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:388— HomeStockWorkspace.HomeStockWorkspace has cyclomatic complexity 36 (threshold 15). Of this number, 18 points are the body's own statements and 18 belong to 7 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.
TickFlowFetcher.get_sector_rankings (cyclomatic 35) data_provider/tickflow_fetcher.py:1137— TickFlowFetcher.get_sector_rankings 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.
notification_diagnostics.run_notification_diagnostics (cyclomatic 35) src/services/notification_diagnostics.py:314— notification_diagnostics.run_notification_diagnostics has cyclomatic complexity 35 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
web_intent_resolver._reclaim_orphan_entities (cyclomatic 34) src/agent/web_intent_resolver.py:1529— web_intent_resolver._reclaim_orphan_entities 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.
GeminiAnalyzer.analyze (cyclomatic 34) src/analyzer.py:3989— GeminiAnalyzer.analyze 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.
StockTrendAnalyzer._generate_signal (cyclomatic 34) src/stock_analyzer.py:585— StockTrendAnalyzer._generate_signal 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.
Input.Input (cyclomatic 34) apps/dsa-web/src/components/common/Input.tsx:25— Input.Input has cyclomatic complexity 34 (threshold 15). Of this number, 29 points are the body's own statements and 5 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
error.parseApiError (cyclomatic 34) apps/dsa-web/src/api/error.ts:310— error.parseApiError 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.
agent.decodeChatState (cyclomatic 34) apps/dsa-web/src/api/agent.ts:60— agent.decodeChatState has cyclomatic complexity 34 (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.
ShareImageButton.ShareImageButton (cyclomatic 34) apps/dsa-web/src/components/report/ShareImageButton.tsx:38— ShareImageButton.ShareImageButton has cyclomatic complexity 34 (threshold 15). Most of this is not in the body itself: 15 of the 34 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 92, 62, 73). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
formatters.chunk_markdown_preserving_blocks (cyclomatic 33) src/formatters.py:361— formatters.chunk_markdown_preserving_blocks 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.
local_cli_backend._redact_multiline_sensitive_fields (cyclomatic 33) src/llm/local_cli_backend.py:1055— local_cli_backend._redact_multiline_sensitive_fields 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.
NotificationService.generate_single_stock_report (cyclomatic 33) src/notification.py:1959— NotificationService.generate_single_stock_report 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.
base.normalize_stock_code (cyclomatic 32) data_provider/base.py:71— base.normalize_stock_code 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.
LongbridgeFetcher.get_realtime_quote (cyclomatic 32) REDACTED:743— LongbridgeFetcher.get_realtime_quote 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.
ToolSurface.execute_tool (cyclomatic 32) src/agent/tool_surface.py:71— ToolSurface.execute_tool has cyclomatic complexity 32 (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.
analyzer.apply_placeholder_fill (cyclomatic 32) src/analyzer.py:406— analyzer.apply_placeholder_fill 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.
MarketAnalyzer._generate_template_review (cyclomatic 32) src/market_analyzer.py:1892— MarketAnalyzer._generate_template_review has cyclomatic complexity 32 (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.
import_parser.parse_import_from_bytes (cyclomatic 32) src/services/import_parser.py:128— import_parser.parse_import_from_bytes 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.
SystemConfigService.discover_llm_channel_models (cyclomatic 32) src/services/system_config_service.py:946— SystemConfigService.discover_llm_channel_models has cyclomatic complexity 32 (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.
SystemConfigService.test_llm_channel (cyclomatic 32) src/services/system_config_service.py:1216— SystemConfigService.test_llm_channel has cyclomatic complexity 32 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
main.createWindow (cyclomatic 32) REDACTED:1883— main.createWindow has cyclomatic complexity 32 (threshold 15). Most of this is not in the body itself: 13 of the 32 points are its own statements and the rest belongs to 3 function items inside it that branch (onHealthProgress, a function literal at line 2049, applyThemeBackground). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
agentChatStore.useAgentChatStore.startStream (cyclomatic 32) apps/dsa-web/src/stores/agentChatStore.ts:349— agentChatStore.useAgentChatStore.startStream 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. This shape REPEATS in the file: one other method here (agentChatStore.useAgentChatStore.startStream::processLine) 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.
ReportOverview.ReportOverview (cyclomatic 32) apps/dsa-web/src/components/report/ReportOverview.tsx:165— ReportOverview.ReportOverview has cyclomatic complexity 32 (threshold 15). Of this number, 19 points are the body's own statements and 13 belong to 5 function items inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
AnalysisContextSummary.AnalysisContextSummary (cyclomatic 32) apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:307— AnalysisContextSummary.AnalysisContextSummary has cyclomatic complexity 32 (threshold 15). Of this number, 24 points are the body's own statements and 8 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SettingsPage.SchedulerSettingsCard (cyclomatic 32) apps/dsa-web/src/pages/SettingsPage.tsx:419— SettingsPage.SchedulerSettingsCard has cyclomatic complexity 32 (threshold 15). Of this number, 22 points are the body's own statements and 10 belong to 8 function items inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AlertsPage.AlertsPage (cyclomatic 32) apps/dsa-web/src/pages/AlertsPage.tsx:101— AlertsPage.AlertsPage has cyclomatic complexity 32 (threshold 15). Most of this is not in the body itself: 15 of the 32 points are its own statements and the rest belongs to 9 function items inside it that branch (a function literal at line 132, handleToggleEnabled, a function literal at line 169, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
metrics.compute_stage_trajectory_metrics (cyclomatic 31) evals/agent_trajectory/metrics.py:376— metrics.compute_stage_trajectory_metrics 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.
AgentChatSessionService._resolve_session_turn (cyclomatic 31) src/services/agent_chat_session_service.py:196— AgentChatSessionService._resolve_session_turn 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.
image_stock_extractor._call_litellm_vision (cyclomatic 31) src/services/image_stock_extractor.py:270— image_stock_extractor._call_litellm_vision 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.
AlertRuleForm.AlertRuleForm::buildParameters (cyclomatic 31) apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:284— AlertRuleForm.AlertRuleForm::buildParameters 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. This shape REPEATS in the file: one other method here (AlertRuleForm.AlertRuleForm) 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.
MarketStructureCard.MarketStructureCard (cyclomatic 31) apps/dsa-web/src/components/report/MarketStructureCard.tsx:173— MarketStructureCard.MarketStructureCard has cyclomatic complexity 31 (threshold 15). Of this number, 29 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
auth.auth_update_settings (cyclomatic 30) api/v1/endpoints/auth.py:208— auth.auth_update_settings 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.
CodexToolProcessRunner._terminate (cyclomatic 30) src/agent/codex_tool_process.py:542— CodexToolProcessRunner._terminate has cyclomatic complexity 30 (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.
GeminiAnalyzer._build_integrity_complement_prompt (cyclomatic 30) src/analyzer.py:5207— GeminiAnalyzer._build_integrity_complement_prompt 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.
run_flow.build_history_run_flow_snapshot (cyclomatic 30) src/services/run_flow.py:183— run_flow.build_history_run_flow_snapshot 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.
runtime_scheduler._terminate_analysis_process_tree (cyclomatic 30) src/services/runtime_scheduler.py:125— runtime_scheduler._terminate_analysis_process_tree has cyclomatic complexity 30 (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.
ScreeningService.hotspots (cyclomatic 30) REDACTED:968— ScreeningService.hotspots 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.
RunFlowPanel.RunFlowPanel (cyclomatic 30) apps/dsa-web/src/components/run-flow/RunFlowPanel.tsx:19— RunFlowPanel.RunFlowPanel has cyclomatic complexity 30 (threshold 15). Of this number, 16 points are the body's own statements and 14 belong to 8 function items inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
DataFetcherManager._normalize_belong_boards (cyclomatic 29) data_provider/base.py:1683— DataFetcherManager._normalize_belong_boards 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.
SerpAPISearchProvider._do_search (cyclomatic 29) src/search_service.py:626— SerpAPISearchProvider._do_search 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.
BacktestService.run_backtest (cyclomatic 29) src/services/backtest_service.py:48— BacktestService.run_backtest 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.
useRunFlowSnapshot.appendDerivedEdge (cyclomatic 29) apps/dsa-web/src/hooks/useRunFlowSnapshot.ts:200— useRunFlowSnapshot.appendDerivedEdge has cyclomatic complexity 29 (threshold 15). Of this number, 23 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TickFlowFetcher.get_main_indices (cyclomatic 28) data_provider/tickflow_fetcher.py:986— TickFlowFetcher.get_main_indices 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.
runner._execute_tools (cyclomatic 28) src/agent/runner.py:709— runner._execute_tools 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.
market_review.run_market_review (cyclomatic 28) src/core/market_review.py:174— market_review.run_market_review 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.
NotificationService.send_with_results (cyclomatic 28) src/notification.py:2645— NotificationService.send_with_results 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.
PortfolioPage.buildPortfolioRiskFlags (cyclomatic 28) apps/dsa-web/src/pages/PortfolioPage.tsx:444— PortfolioPage.buildPortfolioRiskFlags has cyclomatic complexity 28 (threshold 15). Of this number, 27 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: 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.
AskCommand._analyze_multi (cyclomatic 27) bot/commands/ask.py:259— AskCommand._analyze_multi 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.
LongbridgeFetcher._get_ctx (cyclomatic 27) REDACTED:497— LongbridgeFetcher._get_ctx 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.
chat_context._build_visible_history_state (cyclomatic 27) src/agent/chat_context.py:238— chat_context._build_visible_history_state 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.
StockAnalysisPipeline._augment_historical_with_realtime (cyclomatic 27) src/core/pipeline.py:2733— StockAnalysisPipeline._augment_historical_with_realtime 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.
PortfolioImportService.commit_trade_records (cyclomatic 27) src/services/portfolio_import_service.py:182— PortfolioImportService.commit_trade_records 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.
RuntimeSchedulerService._run_analysis_with_watchdog (cyclomatic 27) src/services/runtime_scheduler.py:483— RuntimeSchedulerService._run_analysis_with_watchdog 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.
daily.fetch_daily_history (cyclomatic 27) src/services/screening/daily.py:170— daily.fetch_daily_history 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.
SystemConfigService._collect_non_hermes_channel_models_from_map (cyclomatic 27) src/services/system_config_service.py:4964— SystemConfigService._collect_non_hermes_channel_models_from_map 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.
updateState.getDesktopUpdateNotice (cyclomatic 27) apps/dsa-web/src/desktop/updateState.ts:45— updateState.getDesktopUpdateNotice 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.
topologyViewModel.buildRunFlowTopologyModel (cyclomatic 27) apps/dsa-web/src/components/run-flow/topologyViewModel.ts:218— topologyViewModel.buildRunFlowTopologyModel has cyclomatic complexity 27 (threshold 15). Most of this is not in the body itself: 1 of the 27 points is its own statement and the rest belongs to 5 function literals inside it that branch (lines 306, 329, 235, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
FeishuStreamHandler._parse_event_message (cyclomatic 26) bot/platforms/feishu_stream.py:432— FeishuStreamHandler._parse_event_message has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FutuFundamentalAdapter._dividends_and_splits (cyclomatic 26) data_provider/futu_fundamental_adapter.py:138— FutuFundamentalAdapter._dividends_and_splits 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.
YfinanceFetcher._get_us_index_realtime_quote (cyclomatic 26) REDACTED:688— YfinanceFetcher._get_us_index_realtime_quote has cyclomatic complexity 26 (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.
chat_object_decision.object_mentions (cyclomatic 26) src/agent/chat_object_decision.py:52— chat_object_decision.object_mentions 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.
local_cli_backend._redact_yaml_explicit_sensitive_fields (cyclomatic 26) src/llm/local_cli_backend.py:1183— local_cli_backend._redact_yaml_explicit_sensitive_fields 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.
NotificationService._send_to_static_channel (cyclomatic 26) src/notification.py:2578— NotificationService._send_to_static_channel has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
import_parser._parse_dataframe (cyclomatic 26) src/services/import_parser.py:70— import_parser._parse_dataframe 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.
hotspot._coerce_hotspot_summary (cyclomatic 26) src/services/screening/hotspot.py:1013— hotspot._coerce_hotspot_summary has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
snapshot._read_last_good_snapshot (cyclomatic 26) src/services/screening/snapshot.py:281— snapshot._read_last_good_snapshot 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.
sniper_points.parse_sniper_value (cyclomatic 26) src/utils/sniper_points.py:14— sniper_points.parse_sniper_value 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.
SidebarNav.SidebarNav (cyclomatic 26) apps/dsa-web/src/components/layout/SidebarNav.tsx:42— SidebarNav.SidebarNav has cyclomatic complexity 26 (threshold 15). Of this number, 20 points are the body's own statements and 6 belong to 2 function literals inside it that branch. To reduce it, split the body: 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.
SettingsHelpButton.SettingsHelpButton (cyclomatic 26) apps/dsa-web/src/components/settings/SettingsHelpButton.tsx:93— SettingsHelpButton.SettingsHelpButton has cyclomatic complexity 26 (threshold 15). Of this number, 14 points are the body's own statements and 12 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
analysis._build_analysis_report (cyclomatic 25) api/v1/endpoints/analysis.py:1465— analysis._build_analysis_report 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.
EfinanceFetcher.get_realtime_quote (cyclomatic 25) data_provider/efinance_fetcher.py:624— EfinanceFetcher.get_realtime_quote 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.
EfinanceFetcher.get_main_indices (cyclomatic 25) data_provider/efinance_fetcher.py:924— EfinanceFetcher.get_main_indices 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.
AkshareFundamentalAdapter.get_fundamental_bundle (cyclomatic 25) data_provider/fundamental_adapter.py:372— AkshareFundamentalAdapter.get_fundamental_bundle 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.
provider_trace.extract_provider_trace_turns (cyclomatic 25) src/agent/provider_trace.py:142— provider_trace.extract_provider_trace_turns 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.
analyzer.check_content_integrity (cyclomatic 25) src/analyzer.py:327— analyzer.check_content_integrity 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.
portfolio._filter_stock_codes (cyclomatic 25) src/brokers/futu/portfolio.py:358— portfolio._filter_stock_codes 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.
NotificationService.detect_configured_channels (cyclomatic 25) src/notification.py:495— NotificationService.detect_configured_channels 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.
notification_noise._evaluate_notification_noise (cyclomatic 25) src/notification_noise.py:246— notification_noise._evaluate_notification_noise has cyclomatic complexity 25 (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.
PortfolioService._build_symbol_filter_values (cyclomatic 25) src/services/portfolio_service.py:1303— PortfolioService._build_symbol_filter_values 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.
industry.load_industry_map (cyclomatic 25) src/services/screening/industry.py:119— industry.load_industry_map 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.
SocialSentimentService._format_social_intel (cyclomatic 25) src/services/social_sentiment_service.py:244— SocialSentimentService._format_social_intel 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.
SystemConfigService._validate_cross_field (cyclomatic 25) src/services/system_config_service.py:4504— SystemConfigService._validate_cross_field has cyclomatic complexity 25 (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.
share_image._market_body (cyclomatic 25) src/share_image.py:1863— share_image._market_body 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.
SettingsPage.FirstRunSetupCard (cyclomatic 25) apps/dsa-web/src/pages/SettingsPage.tsx:207— SettingsPage.FirstRunSetupCard has cyclomatic complexity 25 (threshold 15). Of this number, 24 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StatusCommand._collect_status (cyclomatic 24) bot/commands/status.py:59— StatusCommand._collect_status has cyclomatic complexity 24 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
metrics.compute_trajectory_metrics (cyclomatic 24) evals/agent_trajectory/metrics.py:236— metrics.compute_trajectory_metrics has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
metrics.validate_golden_sample (cyclomatic 24) evals/agent_trajectory/metrics.py:588— metrics.validate_golden_sample has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
web_intent_tokenizer._split_by_codes (cyclomatic 24) src/agent/web_intent_tokenizer.py:560— web_intent_tokenizer._split_by_codes 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.
etf_rotation.run_backtest (cyclomatic 24) src/core/etf_rotation.py:167— etf_rotation.run_backtest 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.
stock_index_loader._build_stock_code_candidates (cyclomatic 24) src/data/stock_index_loader.py:152— stock_index_loader._build_stock_code_candidates 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.
NotificationService._get_fundamental_blocks (cyclomatic 24) src/notification.py:2229— NotificationService._get_fundamental_blocks has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MarketStructureService.build_context (cyclomatic 24) src/services/market_structure_service.py:51— MarketStructureService.build_context has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ScreeningService.screen (cyclomatic 24) REDACTED:1212— ScreeningService.screen has cyclomatic complexity 24 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SystemConfigService._resolve_hermes_saved_secret (cyclomatic 24) src/services/system_config_service.py:769— SystemConfigService._resolve_hermes_saved_secret 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.
SystemConfigService._classify_llm_exception (cyclomatic 24) src/services/system_config_service.py:4310— SystemConfigService._classify_llm_exception has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ThemeToggle.ThemeToggle (cyclomatic 24) apps/dsa-web/src/components/theme/ThemeToggle.tsx:43— ThemeToggle.ThemeToggle has cyclomatic complexity 24 (threshold 15). Of this number, 19 points are the body's own statements and 5 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LLMChannelEditor.LLMChannelEditor::handleSave (cyclomatic 24) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2024— LLMChannelEditor.LLMChannelEditor::handleSave has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (LLMChannelEditor.LLMChannelEditor) 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.
AgentBackendStatusPanel.AgentBackendStatusPanel (cyclomatic 24) apps/dsa-web/src/components/settings/AgentBackendStatusPanel.tsx:49— AgentBackendStatusPanel.AgentBackendStatusPanel has cyclomatic complexity 24 (threshold 15). Of this number, 18 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AlertRuleForm.AlertRuleForm (cyclomatic 24) apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:127— AlertRuleForm.AlertRuleForm has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (AlertRuleForm.AlertRuleForm::buildParameters) 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.
DataCenterPage.DataCenterPage (cyclomatic 24) apps/dsa-web/src/pages/DataCenterPage.tsx:52— DataCenterPage.DataCenterPage has cyclomatic complexity 24 (threshold 15). Of this number, 13 points are the body's own statements and 11 belong to 4 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
analysis.trigger_analysis (cyclomatic 23) api/v1/endpoints/analysis.py:345— analysis.trigger_analysis 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.
analysis._build_task_analysis_result (cyclomatic 23) api/v1/endpoints/analysis.py:1067— analysis._build_task_analysis_result has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DataFetcherManager.get_stock_name (cyclomatic 23) data_provider/base.py:3061— DataFetcherManager.get_stock_name 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.
DataFetcherManager.get_capital_flow_context (cyclomatic 23) data_provider/base.py:4655— DataFetcherManager.get_capital_flow_context has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FutuFundamentalAdapter._financials (cyclomatic 23) data_provider/futu_fundamental_adapter.py:76— FutuFundamentalAdapter._financials 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.
longbridge_fetcher._longbridge_config_kwargs (cyclomatic 23) REDACTED:145— longbridge_fetcher._longbridge_config_kwargs 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.
DecisionAgent.build_user_message (cyclomatic 23) src/agent/agents/decision_agent.py:159— DecisionAgent.build_user_message 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.
executor.prepare_agent_chat (cyclomatic 23) src/agent/executor.py:538— executor.prepare_agent_chat 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.
LLMToolAdapter._call_litellm_model (cyclomatic 23) src/agent/llm_adapter.py:678— LLMToolAdapter._call_litellm_model has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
stock_scope.resolve_stock_scope (cyclomatic 23) src/agent/stock_scope.py:313— stock_scope.resolve_stock_scope 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.
web_intent_tokenizer._dfs_match (cyclomatic 23) src/agent/web_intent_tokenizer.py:413— web_intent_tokenizer._dfs_match 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.
local_cli_backend._extract_opencode_json_events (cyclomatic 23) src/llm/local_cli_backend.py:1857— local_cli_backend._extract_opencode_json_events 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.
MarketAnalyzer._resolve_recorded_provider (cyclomatic 23) src/market_analyzer.py:196— MarketAnalyzer._resolve_recorded_provider 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.
SearchService._normalize_news_publish_date (cyclomatic 23) src/search_service.py:3601— SearchService._normalize_news_publish_date has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DecisionSignalService._backfill_analysis_signal_from_history (cyclomatic 23) src/services/decision_signal_service.py:448— DecisionSignalService._backfill_analysis_signal_from_history has cyclomatic complexity 23 (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.
filter.check_hard_filters (cyclomatic 23) src/services/screening/filter.py:125— filter.check_hard_filters 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.
screening_service._build_dsa_analysis_summary (cyclomatic 23) REDACTED:3773— screening_service._build_dsa_analysis_summary 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.
agentChatStore.useAgentChatStore.startStream::processLine (cyclomatic 23) apps/dsa-web/src/stores/agentChatStore.ts:414— agentChatStore.useAgentChatStore.startStream::processLine 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. This shape REPEATS in the file: one other method here (agentChatStore.useAgentChatStore.startStream) 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.
LLMChannelEditor.buildChangedItemKeys (cyclomatic 23) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:310— LLMChannelEditor.buildChangedItemKeys 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.
AlertRuleList.formatParameters (cyclomatic 23) apps/dsa-web/src/components/alerts/AlertRuleList.tsx:30— AlertRuleList.formatParameters 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.
HistoryCommand.execute (cyclomatic 22) bot/commands/history.py:67— HistoryCommand.execute 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.
EfinanceFetcher._get_etf_realtime_quote (cyclomatic 22) data_provider/efinance_fetcher.py:830— EfinanceFetcher._get_etf_realtime_quote has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CodexAppServerTransport._terminate_process (cyclomatic 22) src/agent/codex_app_server_transport.py:1003— CodexAppServerTransport._terminate_process 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.
LLMDeliberationMediator._coerce_responses (cyclomatic 22) src/agent/skills/deliberation.py:452— LLMDeliberationMediator._coerce_responses 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.
portfolio._load_position_codes (cyclomatic 22) src/brokers/futu/portfolio.py:233— portfolio._load_position_codes 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.
Config._channels_to_model_list (cyclomatic 22) src/config.py:2745— Config._channels_to_model_list 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.
StockAnalysisPipeline._load_persisted_intelligence_context (cyclomatic 22) src/core/pipeline.py:3019— StockAnalysisPipeline._load_persisted_intelligence_context 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.
hermes.parse_hermes_channel (cyclomatic 22) src/llm/hermes.py:275— hermes.parse_hermes_channel has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
local_cli_backend._consume_authorization_param_list (cyclomatic 22) src/llm/local_cli_backend.py:1634— local_cli_backend._consume_authorization_param_list 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.
market_phase_summary.format_public_phase_pack_excerpt (cyclomatic 22) src/market_phase_summary.py:181— market_phase_summary.format_public_phase_pack_excerpt 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.
BochaSearchProvider._do_search (cyclomatic 22) src/search_service.py:1027— BochaSearchProvider._do_search has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SearchService._stock_code_identity_terms (cyclomatic 22) src/search_service.py:2827— SearchService._stock_code_identity_terms 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.
SearchService._parse_relative_news_date (cyclomatic 22) src/search_service.py:3547— SearchService._parse_relative_news_date 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.
SearchService.search_topic_news (cyclomatic 22) src/search_service.py:3866— SearchService.search_topic_news has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
SearchService.search_comprehensive_intel (cyclomatic 22) src/search_service.py:4384— SearchService.search_comprehensive_intel 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.
DailyMarketContextService.get_context (cyclomatic 22) src/services/daily_market_context.py:103— DailyMarketContextService.get_context 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.
PortfolioRiskService._build_decision_signal_risk (cyclomatic 22) src/services/portfolio_risk_service.py:103— PortfolioRiskService._build_decision_signal_risk 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.
SystemConfigService._build_explainability_warnings (cyclomatic 22) src/services/system_config_service.py:2152— SystemConfigService._build_explainability_warnings has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
DatabaseManager._ensure_chat_session_schema (cyclomatic 22) REDACTED:1459— DatabaseManager._ensure_chat_session_schema 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.
agentChatStore.mergeChatState (cyclomatic 22) apps/dsa-web/src/stores/agentChatStore.ts:178— agentChatStore.mergeChatState 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.
TaskPanel.TaskItem (cyclomatic 22) apps/dsa-web/src/components/tasks/TaskPanel.tsx:21— TaskPanel.TaskItem 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.
SettingsField.renderFieldControl (cyclomatic 22) apps/dsa-web/src/components/settings/SettingsField.tsx:71— SettingsField.renderFieldControl has cyclomatic complexity 22 (threshold 15). Of this number, 16 points are the body's own statements and 6 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PortfolioPage.hasCompleteSectorCoverage (cyclomatic 22) apps/dsa-web/src/pages/PortfolioPage.tsx:298— PortfolioPage.hasCompleteSectorCoverage has cyclomatic complexity 22 (threshold 15). Of this number, 15 points are the body's own statements and 7 belong to 2 function literals inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
stocks.parse_import (cyclomatic 21) api/v1/endpoints/stocks.py:215— stocks.parse_import 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.
AskCommand._format_stock_result (cyclomatic 21) bot/commands/ask.py:510— AskCommand._format_stock_result 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.
AkshareFetcher._get_stock_realtime_quote_tencent (cyclomatic 21) REDACTED:1369— AkshareFetcher._get_stock_realtime_quote_tencent 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.
AkshareFetcher._calc_market_stats (cyclomatic 21) REDACTED:2096— AkshareFetcher._calc_market_stats 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.
EfinanceFetcher._calc_market_stats (cyclomatic 21) data_provider/efinance_fetcher.py:1062— EfinanceFetcher._calc_market_stats 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.
TushareFetcher._calc_market_stats (cyclomatic 21) data_provider/tushare_fetcher.py:961— TushareFetcher._calc_market_stats 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.
CodexAppServerTransport._route_message (cyclomatic 21) src/agent/codex_app_server_transport.py:760— CodexAppServerTransport._route_message 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.
events.validate_event_alert_rule (cyclomatic 21) src/agent/events.py:463— events.validate_event_alert_rule 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.
AgentOrchestrator._build_data_perspective (cyclomatic 21) src/agent/orchestrator.py:1760— AgentOrchestrator._build_data_perspective 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.
analysis_tools._handle_get_volume_analysis (cyclomatic 21) src/agent/tools/analysis_tools.py:207— analysis_tools._handle_get_volume_analysis 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.
analyzer.fill_price_position_if_needed (cyclomatic 21) src/analyzer.py:992— analyzer.fill_price_position_if_needed 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.
usage._infer_provider (cyclomatic 21) src/llm/usage.py:934— usage._infer_provider 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.
MarketAnalyzer.generate_market_review (cyclomatic 21) src/market_analyzer.py:779— MarketAnalyzer.generate_market_review 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.
SearchService._has_low_quality_news_page_signal (cyclomatic 21) src/search_service.py:3030— SearchService._has_low_quality_news_page_signal has cyclomatic complexity 21 (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.
PortfolioImportService._normalize_trade_row (cyclomatic 21) src/services/portfolio_import_service.py:294— PortfolioImportService._normalize_trade_row has cyclomatic complexity 21 (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.
daily.enrich_daily_features (cyclomatic 21) src/services/screening/daily.py:63— daily.enrich_daily_features 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.
industry.fetch_akshare_board_map (cyclomatic 21) src/services/screening/industry.py:177— industry.fetch_akshare_board_map 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.
ranker._format_dsa_context_for_prompt (cyclomatic 21) src/services/screening/ranker.py:493— ranker._format_dsa_context_for_prompt 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.
share_image._stock_body (cyclomatic 21) src/share_image.py:1817— share_image._stock_body 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.
DatabaseManager._backfill_canonical_ids (cyclomatic 21) REDACTED:1954— DatabaseManager._backfill_canonical_ids 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.
stockPoolStore.fetchHistory (cyclomatic 21) apps/dsa-web/src/stores/stockPoolStore.ts:456— stockPoolStore.fetchHistory 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.
HistoryList.HistoryList (cyclomatic 21) apps/dsa-web/src/components/history/HistoryList.tsx:32— HistoryList.HistoryList has cyclomatic complexity 21 (threshold 15). Of this number, 12 points are the body's own statements and 9 belong to 3 function literals inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
useRunFlowSnapshot.useRunFlowSnapshot (cyclomatic 21) apps/dsa-web/src/hooks/useRunFlowSnapshot.ts:423— useRunFlowSnapshot.useRunFlowSnapshot has cyclomatic complexity 21 (threshold 15). Most of this is not in the body itself: 9 of the 21 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 484, 456, 496, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
LLMChannelEditor.parseChannelsFromItems (cyclomatic 21) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1469— LLMChannelEditor.parseChannelsFromItems has cyclomatic complexity 21 (threshold 15). Most of this is not in the body itself: 9 of the 21 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 1483, 1491). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
configureElectronAutoUpdater (cyclomatic 21) REDACTED:1684— configureElectronAutoUpdater has cyclomatic complexity 21 (threshold 15). Most of this is not in the body itself: 6 of the 21 points are its own statements and the rest belongs to 6 function literals inside it that branch (lines 1726, 1744, 1758, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
CommandDispatcher._try_nl_routing (cyclomatic 20) bot/dispatcher.py:457— CommandDispatcher._try_nl_routing 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. This shape REPEATS in the file: one other method here (CommandDispatcher._try_nl_routing_sync) 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.
CommandDispatcher._try_nl_routing_sync (cyclomatic 20) bot/dispatcher.py:541— CommandDispatcher._try_nl_routing_sync 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. This shape REPEATS in the file: one other method here (CommandDispatcher._try_nl_routing) 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.
DataFetcherManager.get_board_context (cyclomatic 20) data_provider/base.py:4797— DataFetcherManager.get_board_context 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.
generate_index_from_csv.load_index_registry_seed (cyclomatic 20) scripts/generate_index_from_csv.py:634— generate_index_from_csv.load_index_registry_seed 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.
chat_context.build_agent_chat_context_bundle (cyclomatic 20) src/agent/chat_context.py:141— chat_context.build_agent_chat_context_bundle 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.
CodexAgentBackend.run (cyclomatic 20) src/agent/codex_agent_backend.py:75— CodexAgentBackend.run 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.
CodexAppServerTransport._write_message (cyclomatic 20) src/agent/codex_app_server_transport.py:918— CodexAppServerTransport._write_message 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.
WebIntentResolver.resolve (cyclomatic 20) src/agent/web_intent_resolver.py:1953— WebIntentResolver.resolve 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.
web_intent_tokenizer._identify_one_code (cyclomatic 20) src/agent/web_intent_tokenizer.py:723— web_intent_tokenizer._identify_one_code 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.
decision_action.normalize_decision_action (cyclomatic 20) src/schemas/decision_action.py:306— decision_action.normalize_decision_action 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.
SearchService.__init__ (cyclomatic 20) src/search_service.py:2404— SearchService.__init__ 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.
AlertService._coerce_datetime (cyclomatic 20) src/services/alert_service.py:778— AlertService._coerce_datetime 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.
AlertService.build_runtime_payloads (cyclomatic 20) src/services/alert_service.py:1005— AlertService.build_runtime_payloads 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.
AlertWorker.run_once (cyclomatic 20) REDACTED:107— AlertWorker.run_once 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.
IntelligenceService._validate_url (cyclomatic 20) REDACTED:392— IntelligenceService._validate_url 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.
MarketHotspotService.get_hotspots (cyclomatic 20) src/services/market_hotspot_service.py:76— MarketHotspotService.get_hotspots 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.
PortfolioService._calculate_available_quantity (cyclomatic 20) src/services/portfolio_service.py:702— PortfolioService._calculate_available_quantity 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.
PortfolioService._build_positions (cyclomatic 20) src/services/portfolio_service.py:1011— PortfolioService._build_positions 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.
candidate_context._collect_candidate_context_row (cyclomatic 20) src/services/screening/candidate_context.py:134— candidate_context._collect_candidate_context_row 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.
daily._read_daily_history_cache (cyclomatic 20) src/services/screening/daily.py:553— daily._read_daily_history_cache 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.
pipeline._daily_source_health_notes (cyclomatic 20) src/services/screening/pipeline.py:703— pipeline._daily_source_health_notes 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.
risk.assess_pick_risk (cyclomatic 20) src/services/screening/risk.py:141— risk.assess_pick_risk 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.
screening_service._enrich_hotspot_rows_from_provider (cyclomatic 20) REDACTED:593— screening_service._enrich_hotspot_rows_from_provider 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.
screening_service._normalize_screening_hotspot_detail (cyclomatic 20) REDACTED:1341— screening_service._normalize_screening_hotspot_detail has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SkillOpinionWeightService.compute_weights (cyclomatic 20) src/services/skill_opinion_weight_service.py:48— SkillOpinionWeightService.compute_weights 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.
SystemConfigService._infer_setup_legacy_primary_model (cyclomatic 20) src/services/system_config_service.py:3543— SystemConfigService._infer_setup_legacy_primary_model 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.
SystemConfigService._build_setup_agent_llm_check (cyclomatic 20) src/services/system_config_service.py:3660— SystemConfigService._build_setup_agent_llm_check 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.
SystemConfigService._collect_hermes_channel_models_from_map (cyclomatic 20) src/services/system_config_service.py:4922— SystemConfigService._collect_hermes_channel_models_from_map has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
SystemConfigService._has_legacy_key_for_provider (cyclomatic 20) src/services/system_config_service.py:5060— SystemConfigService._has_legacy_key_for_provider has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
share_image._merge_sector_rankings (cyclomatic 20) src/share_image.py:513— share_image._merge_sector_rankings 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.
main.restorePackagedRuntimeStateFromBackup (cyclomatic 20) REDACTED:525— main.restorePackagedRuntimeStateFromBackup has cyclomatic complexity 20 (threshold 15). Of this number, 16 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, 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.
StockAutocomplete.StockAutocompleteInner (cyclomatic 20) apps/dsa-web/src/components/StockAutocomplete/StockAutocomplete.tsx:105— StockAutocomplete.StockAutocompleteInner has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 8 of the 20 points are its own statements and the rest belongs to 6 function items inside it that branch (handleKeyDown, updateDropdownPosition, a function literal at line 156, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
StockBar.StockBar (cyclomatic 20) apps/dsa-web/src/components/history/StockBar.tsx:24— StockBar.StockBar has cyclomatic complexity 20 (threshold 15). Of this number, 11 points are the body's own statements and 9 belong to 5 function literals inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ReportMarkdownPanel.ReportMarkdownPanel (cyclomatic 20) apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:19— ReportMarkdownPanel.ReportMarkdownPanel has cyclomatic complexity 20 (threshold 15). Of this number, 11 points are the body's own statements and 9 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HomeStockWorkspace.WatchlistRowItem (cyclomatic 20) apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:247— HomeStockWorkspace.WatchlistRowItem 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.
analysis._handle_async_analysis_batch (cyclomatic 19) api/v1/endpoints/analysis.py:453— analysis._handle_async_analysis_batch 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.
DataFetcherManager.batch_get_stock_names (cyclomatic 19) data_provider/base.py:3249— DataFetcherManager.batch_get_stock_names 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.
fundamental_adapter._build_dividend_payload (cyclomatic 19) data_provider/fundamental_adapter.py:212— fundamental_adapter._build_dividend_payload 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.
TickFlowFetcher.get_market_stats (cyclomatic 19) data_provider/tickflow_fetcher.py:1055— TickFlowFetcher.get_market_stats 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.
YfinanceFetcher._convert_stock_code (cyclomatic 19) REDACTED:97— YfinanceFetcher._convert_stock_code 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.
YfinanceFetcher._get_us_stock_quote_from_stooq (cyclomatic 19) REDACTED:537— YfinanceFetcher._get_us_stock_quote_from_stooq 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.
CodexAppServerTransport.run_turn (cyclomatic 19) src/agent/codex_app_server_transport.py:478— CodexAppServerTransport.run_turn 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.
CodexAppServerTransport.inspect_external_tool_isolation (cyclomatic 19) src/agent/codex_app_server_transport.py:596— CodexAppServerTransport.inspect_external_tool_isolation 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.
AgentOrchestrator._build_context (cyclomatic 19) src/agent/orchestrator.py:1251— AgentOrchestrator._build_context 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.
runner.try_parse_json (cyclomatic 19) src/agent/runner.py:175— runner.try_parse_json 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.
web_intent_resolver._narrow_group_entities (cyclomatic 19) src/agent/web_intent_resolver.py:817— web_intent_resolver._narrow_group_entities 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.
market_review._render_sector_payload_block (cyclomatic 19) src/core/market_review.py:730— market_review._render_sector_payload_block 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.
StockAnalysisPipeline._backfill_agent_dashboard_fields (cyclomatic 19) src/core/pipeline.py:2537— StockAnalysisPipeline._backfill_agent_dashboard_fields 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.
pipeline._symbol_scope_lookup_values (cyclomatic 19) src/core/pipeline.py:161— pipeline._symbol_scope_lookup_values 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.
hermes.canonicalize_hermes_base_url (cyclomatic 19) src/llm/hermes.py:159— hermes.canonicalize_hermes_base_url 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.
MarketAnalyzer.build_market_review_payload (cyclomatic 19) src/market_analyzer.py:991— MarketAnalyzer.build_market_review_payload 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.
MarketAnalyzer._merge_persisted_market_intelligence (cyclomatic 19) src/market_analyzer.py:2069— MarketAnalyzer._merge_persisted_market_intelligence 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.
SignalAttribution.validate_and_normalize_contributions (cyclomatic 19) src/schemas/report_schema.py:140— SignalAttribution.validate_and_normalize_contributions 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.
AnspireSearchProvider._do_search (cyclomatic 19) src/search_service.py:1223— AnspireSearchProvider._do_search 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.
agent_backend_status_service._terminate_probe_process_group (cyclomatic 19) src/services/agent_backend_status_service.py:40— agent_backend_status_service._terminate_probe_process_group 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.
daily_market_context.format_daily_market_context_prompt_section (cyclomatic 19) src/services/daily_market_context.py:635— daily_market_context.format_daily_market_context_prompt_section 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.
decision_signal_extractor.build_decision_signal_payload_from_report (cyclomatic 19) src/services/decision_signal_extractor.py:43— decision_signal_extractor.build_decision_signal_payload_from_report 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.
DecisionSignalService.list_signals (cyclomatic 19) src/services/decision_signal_service.py:197— DecisionSignalService.list_signals 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.
DecisionSignalService._normalize_payload (cyclomatic 19) src/services/decision_signal_service.py:786— DecisionSignalService._normalize_payload 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.
etf_rotation_service.load_closes (cyclomatic 19) src/services/etf_rotation_service.py:96— etf_rotation_service.load_closes 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.
image_stock_extractor._parse_items_from_text (cyclomatic 19) src/services/image_stock_extractor.py:150— image_stock_extractor._parse_items_from_text 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.
market_light_service.load_previous_snapshot (cyclomatic 19) src/services/market_light_service.py:48— market_light_service.load_previous_snapshot 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.
name_to_code_resolver.resolve_name_to_code (cyclomatic 19) src/services/name_to_code_resolver.py:737— name_to_code_resolver.resolve_name_to_code 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.
run_diagnostics.build_run_diagnostic_summary (cyclomatic 19) src/services/run_diagnostics.py:1412— run_diagnostics.build_run_diagnostic_summary 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.
context.summarize_candidate_profile (cyclomatic 19) src/services/screening/context.py:199— context.summarize_candidate_profile 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.
hotspot.classify_hotspot_stage (cyclomatic 19) src/services/screening/hotspot.py:157— hotspot.classify_hotspot_stage 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.
post_analysis._scorecard_delta (cyclomatic 19) src/services/screening/post_analysis.py:289— post_analysis._scorecard_delta 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.
screening_service._enrich_candidates_with_dsa (cyclomatic 19) REDACTED:3513— screening_service._enrich_candidates_with_dsa 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.
SkillOpinionSampleService.persist (cyclomatic 19) src/services/skill_opinion_sample_service.py:30— SkillOpinionSampleService.persist 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.
SystemConfigService._classify_llm_http_error (cyclomatic 19) src/services/system_config_service.py:4152— SystemConfigService._classify_llm_http_error 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.
MarketReviewRegionSelector.MarketReviewRegionSelector (cyclomatic 19) apps/dsa-web/src/components/market-review/MarketReviewRegionSelector.tsx:17— MarketReviewRegionSelector.MarketReviewRegionSelector has cyclomatic complexity 19 (threshold 15). Of this number, 10 points are the body's own statements and 9 belong to 6 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.
ReportNews.ReportNews (cyclomatic 19) apps/dsa-web/src/components/report/ReportNews.tsx:35— ReportNews.ReportNews has cyclomatic complexity 19 (threshold 15). Of this number, 15 points are the body's own statements and 4 belong to 2 function literals inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
chatStockCode.extractStockCodesFromMessage (cyclomatic 19) apps/dsa-web/src/utils/chatStockCode.ts:57— chatStockCode.extractStockCodesFromMessage has cyclomatic complexity 19 (threshold 15). Of this number, 14 points are the body's own statements and 5 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StrategiesCommand.execute (cyclomatic 18) bot/commands/strategies.py:42— StrategiesCommand.execute 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.
DataFetcherManager._supplement_capital_flow_from_fetchers (cyclomatic 18) data_provider/base.py:4602— DataFetcherManager._supplement_capital_flow_from_fetchers 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.
TushareFetcher.get_market_stats (cyclomatic 18) data_provider/tushare_fetcher.py:880— TushareFetcher.get_market_stats 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.
llm_adapter.resolve_fallback_litellm_wire_models (cyclomatic 18) src/agent/llm_adapter.py:299— llm_adapter.resolve_fallback_litellm_wire_models 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.
stock_scope.extract_stock_code_spans (cyclomatic 18) src/agent/stock_scope.py:238— stock_scope.extract_stock_code_spans has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
web_intent_resolver._split_sub_messages (cyclomatic 18) src/agent/web_intent_resolver.py:326— web_intent_resolver._split_sub_messages 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.
analysis_context_pack_overview._sanitize_persisted_overview (cyclomatic 18) src/analysis_context_pack_overview.py:137— analysis_context_pack_overview._sanitize_persisted_overview has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
trading_calendar.infer_market_phase (cyclomatic 18) src/core/trading_calendar.py:375— trading_calendar.infer_market_phase 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.
local_cli_backend._redact_double_quoted_yaml_sensitive_field (cyclomatic 18) src/llm/local_cli_backend.py:941— local_cli_backend._redact_double_quoted_yaml_sensitive_field 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.
local_cli_backend._extract_claude_code_json (cyclomatic 18) src/llm/local_cli_backend.py:1783— local_cli_backend._extract_claude_code_json 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.
MarketAnalyzer._build_stats_block (cyclomatic 18) src/market_analyzer.py:1196— MarketAnalyzer._build_stats_block 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.
SearXNGSearchProvider._do_search (cyclomatic 18) src/search_service.py:2034— SearXNGSearchProvider._do_search 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.
IntelligenceService._normalize_source_fields (cyclomatic 18) REDACTED:360— IntelligenceService._normalize_source_fields has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
PortfolioService.record_trade (cyclomatic 18) src/services/portfolio_service.py:186— PortfolioService.record_trade has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
hotspot.discover_hotspots (cyclomatic 18) src/services/screening/hotspot.py:297— hotspot.discover_hotspots 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.
screening_service._build_hotspot_event_routes_from_search (cyclomatic 18) REDACTED:346— screening_service._build_hotspot_event_routes_from_search 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.
stock_code_utils._build_market_code_variants (cyclomatic 18) src/services/stock_code_utils.py:273— stock_code_utils._build_market_code_variants 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.
SystemConfigService._mask_notification_target (cyclomatic 18) src/services/system_config_service.py:3176— SystemConfigService._mask_notification_target 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.
storage.persist_llm_usage (cyclomatic 18) REDACTED:4652— storage.persist_llm_usage 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.
main.waitForHealth (cyclomatic 18) REDACTED:1013— main.waitForHealth has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 1 of the 18 points is its own statement and the rest belongs to 6 function literals inside it that branch (lines 1039, 1077, 1029, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
decisionAction.getDecisionActionTone (cyclomatic 18) apps/dsa-web/src/utils/decisionAction.ts:234— decisionAction.getDecisionActionTone 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.
GenerationBackendStatusPanel.GenerationBackendStatusPanel (cyclomatic 18) apps/dsa-web/src/components/settings/GenerationBackendStatusPanel.tsx:84— GenerationBackendStatusPanel.GenerationBackendStatusPanel has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 8 of the 18 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 107, 141, 159). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
LoginPage.LoginPage (cyclomatic 18) REDACTED:15— LoginPage.LoginPage has cyclomatic complexity 18 (threshold 15). Of this number, 14 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatPage.ChatPage::getCurrentStage (cyclomatic 18) apps/dsa-web/src/pages/ChatPage.tsx:677— ChatPage.ChatPage::getCurrentStage has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (ChatPage.ChatPage) 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.
portfolio._resolve_position_analysis_context (cyclomatic 17) api/v1/endpoints/portfolio.py:495— portfolio._resolve_position_analysis_context 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.
AkshareFetcher._get_hk_realtime_quote (cyclomatic 17) REDACTED:1621— AkshareFetcher._get_hk_realtime_quote 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.
DataFetcherManager.prefetch_realtime_quotes (cyclomatic 17) data_provider/base.py:2198— DataFetcherManager.prefetch_realtime_quotes 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.
TushareFetcher._convert_stock_code (cyclomatic 17) data_provider/tushare_fetcher.py:373— TushareFetcher._convert_stock_code 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.
LLMToolAdapter.call_completion (cyclomatic 17) src/agent/llm_adapter.py:586— LLMToolAdapter.call_completion 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.
web_intent_tokenizer._split_by_stock_entities (cyclomatic 17) src/agent/web_intent_tokenizer.py:227— web_intent_tokenizer._split_by_stock_entities 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.
GeminiAnalyzer._init_litellm (cyclomatic 17) src/analyzer.py:2782— GeminiAnalyzer._init_litellm 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.
GeminiAnalyzer._get_hermes_config_error (cyclomatic 17) src/analyzer.py:2945— GeminiAnalyzer._get_hermes_config_error has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
analyzer._capital_flow_bias_with_status (cyclomatic 17) src/analyzer.py:1322— analyzer._capital_flow_bias_with_status 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.
portfolio._discover_real_accounts (cyclomatic 17) src/brokers/futu/portfolio.py:165— portfolio._discover_real_accounts 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.
Config._legacy_keys_to_model_list (cyclomatic 17) src/config.py:2799— Config._legacy_keys_to_model_list 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.
BacktestEngine._first_intent_position (cyclomatic 17) src/core/backtest_engine.py:496— BacktestEngine._first_intent_position 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.
StockAnalysisPipeline.__init__ (cyclomatic 17) src/core/pipeline.py:236— StockAnalysisPipeline.__init__ 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.
provider_cache._model_list_api_surface (cyclomatic 17) src/llm/provider_cache.py:731— provider_cache._model_list_api_surface 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.
MarketAnalyzer._build_market_light_scores (cyclomatic 17) src/market_analyzer.py:1507— MarketAnalyzer._build_market_light_scores 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.
TelegramSender._send_telegram_message (cyclomatic 17) src/notification_sender/telegram_sender.py:121— TelegramSender._send_telegram_message 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.
report_language._first_non_negated_position (cyclomatic 17) src/report_language.py:883— report_language._first_non_negated_position 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.
IntelligenceRepository.upsert_items (cyclomatic 17) src/repositories/intelligence_repo.py:108— IntelligenceRepository.upsert_items has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
agent_chat_session_service._active_from_snapshot (cyclomatic 17) src/services/agent_chat_session_service.py:50— agent_chat_session_service._active_from_snapshot 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.
AlertService._normalize_rule_payload (cyclomatic 17) src/services/alert_service.py:871— AlertService._normalize_rule_payload has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
name_to_code_resolver._fix_name (cyclomatic 17) src/services/name_to_code_resolver.py:535— name_to_code_resolver._fix_name 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.
industry.enrich_industry_concepts (cyclomatic 17) src/services/screening/industry.py:55— industry.enrich_industry_concepts 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.
industry.load_board_heat_trends (cyclomatic 17) src/services/screening/industry.py:636— industry.load_board_heat_trends 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.
DsaEastMoneyHotspotProvider.hotspot_rows (cyclomatic 17) REDACTED:2252— DsaEastMoneyHotspotProvider.hotspot_rows 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.
screening_service._resolve_screening_llm_models (cyclomatic 17) REDACTED:3207— screening_service._resolve_screening_llm_models 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.
stock_daily_start_resolver.resolve_stock_daily_start (cyclomatic 17) src/services/stock_daily_start_resolver.py:37— stock_daily_start_resolver.resolve_stock_daily_start 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.
stock_list_parser._index_entry_from_row (cyclomatic 17) src/services/stock_list_parser.py:465— stock_list_parser._index_entry_from_row 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.
StockProfileService._code_aliases (cyclomatic 17) src/services/stock_profile_service.py:323— StockProfileService._code_aliases 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.
SystemConfigService._validate_llm_channel_definition (cyclomatic 17) src/services/system_config_service.py:5394— SystemConfigService._validate_llm_channel_definition 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.
AnalysisTaskQueue.submit_tasks_batch (cyclomatic 17) src/services/task_queue.py:437— AnalysisTaskQueue.submit_tasks_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.
share_image.build_share_image_html (cyclomatic 17) src/share_image.py:2045— share_image.build_share_image_html 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.
StockTrendAnalyzer._analyze_trend (cyclomatic 17) src/stock_analyzer.py:341— StockTrendAnalyzer._analyze_trend 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.
main.renderDesktopShareImage (cyclomatic 17) REDACTED:1377— main.renderDesktopShareImage has cyclomatic complexity 17 (threshold 15). Of this number, 16 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, 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.
Tooltip.Tooltip (cyclomatic 17) apps/dsa-web/src/components/common/Tooltip.tsx:20— Tooltip.Tooltip has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 7 of the 17 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 35, 71, 85, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
stockPoolStore.consumeCompletedTaskSelection (cyclomatic 17) apps/dsa-web/src/stores/stockPoolStore.ts:280— stockPoolStore.consumeCompletedTaskSelection has cyclomatic complexity 17 (threshold 15). Of this number, 14 points are the body's own statements and 3 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
searchStocks.calculateMatchScore (cyclomatic 17) apps/dsa-web/src/utils/searchStocks.ts:87— searchStocks.calculateMatchScore 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.
RunFlowGraph.buildDataSourceBlocks (cyclomatic 17) apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:258— RunFlowGraph.buildDataSourceBlocks has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 1 of the 17 points is its own statement and the rest belongs to 4 function literals inside it that branch (lines 275, 265, 301, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
TaskPanel.TaskPanel (cyclomatic 17) apps/dsa-web/src/components/tasks/TaskPanel.tsx:172— TaskPanel.TaskPanel has cyclomatic complexity 17 (threshold 15). Of this number, 14 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LLMChannelEditor.LLMChannelEditor (cyclomatic 17) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1667— LLMChannelEditor.LLMChannelEditor 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 shape REPEATS in the file: one other method here (LLMChannelEditor.LLMChannelEditor::handleSave) 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.
DecisionSignalDisplay.DecisionSignalDetails (cyclomatic 17) apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx:331— DecisionSignalDisplay.DecisionSignalDetails has cyclomatic complexity 17 (threshold 15). Of this number, 14 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AlertRuleList.AlertRuleList (cyclomatic 17) apps/dsa-web/src/components/alerts/AlertRuleList.tsx:110— AlertRuleList.AlertRuleList has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 4 of the 17 points are its own statements and the rest belongs to 3 function items inside it that branch (a function literal at line 187, isRuleActionBusy, a function literal at line 274). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
StockScreeningPage.formatScreenMessage (cyclomatic 17) apps/dsa-web/src/pages/StockScreeningPage.tsx:391— StockScreeningPage.formatScreenMessage 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.
DataFetcherManager.get_concept_rankings (cyclomatic 16) data_provider/base.py:4926— DataFetcherManager.get_concept_rankings 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.
AkshareFundamentalAdapter.get_dragon_tiger_flag (cyclomatic 16) data_provider/fundamental_adapter.py:566— AkshareFundamentalAdapter.get_dragon_tiger_flag 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.
TickFlowFetcher.prefetch_daily_klines (cyclomatic 16) data_provider/tickflow_fetcher.py:574— TickFlowFetcher.prefetch_daily_klines 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.
main._prime_daily_market_context (cyclomatic 16) main.py:638— main._prime_daily_market_context 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.
BaseAgent._build_messages (cyclomatic 16) src/agent/agents/base_agent.py:181— BaseAgent._build_messages 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.
disagreement._classify_conflict_type (cyclomatic 16) src/agent/disagreement.py:167— disagreement._classify_conflict_type 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.
litellm_route_resolution.resolve_agent_litellm_route (cyclomatic 16) src/agent/litellm_route_resolution.py:51— litellm_route_resolution.resolve_agent_litellm_route 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.
LLMToolAdapter._init_litellm (cyclomatic 16) src/agent/llm_adapter.py:378— LLMToolAdapter._init_litellm 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.
StrategySynthesizer._consensus_level (cyclomatic 16) src/agent/skills/synthesis.py:325— StrategySynthesizer._consensus_level 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.
execution._normalize_tool_stock_code (cyclomatic 16) src/agent/tools/execution.py:202— execution._normalize_tool_stock_code 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.
execution._resolve_tool_stock_access (cyclomatic 16) src/agent/tools/execution.py:364— execution._resolve_tool_stock_access 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.
GeminiAnalyzer._resolve_configured_response_provider (cyclomatic 16) src/analyzer.py:3146— GeminiAnalyzer._resolve_configured_response_provider 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.
GeminiAnalyzer.generate_text_with_metadata (cyclomatic 16) src/analyzer.py:3926— GeminiAnalyzer.generate_text_with_metadata 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.
BacktestEngine._evaluate_targets (cyclomatic 16) src/core/backtest_engine.py:688— BacktestEngine._evaluate_targets 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.
StockAnalysisPipeline._attach_belong_boards_to_fundamental_context (cyclomatic 16) src/core/pipeline.py:1217— StockAnalysisPipeline._attach_belong_boards_to_fundamental_context 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.
StockAnalysisPipeline._refresh_saved_diagnostic_snapshot (cyclomatic 16) src/core/pipeline.py:2964— StockAnalysisPipeline._refresh_saved_diagnostic_snapshot 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.
MarketAnalyzer._resolve_configured_response_provider (cyclomatic 16) src/market_analyzer.py:162— MarketAnalyzer._resolve_configured_response_provider 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.
market_structure_prompt.format_market_structure_prompt_section (cyclomatic 16) src/market_structure_prompt.py:13— market_structure_prompt.format_market_structure_prompt_section 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.
phase_decision_guardrail.apply_phase_decision_guardrails (cyclomatic 16) src/phase_decision_guardrail.py:116— phase_decision_guardrail.apply_phase_decision_guardrails 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.
AlertService._default_rule_name (cyclomatic 16) src/services/alert_service.py:1298— AlertService._default_rule_name 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.
BacktestService.get_summary (cyclomatic 16) src/services/backtest_service.py:613— BacktestService.get_summary 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.
DataCapabilityService._dataset_from_priority (cyclomatic 16) src/services/data_capability_service.py:936— DataCapabilityService._dataset_from_priority 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.
decision_profile_policy._apply_guardrail (cyclomatic 16) src/services/decision_profile_policy.py:129— decision_profile_policy._apply_guardrail 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.
DecisionSignalOutcomeService.get_stock_review (cyclomatic 16) src/services/decision_signal_outcome_service.py:374— DecisionSignalOutcomeService.get_stock_review 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.
image_stock_extractor._get_api_keys_for_model (cyclomatic 16) src/services/image_stock_extractor.py:244— image_stock_extractor._get_api_keys_for_model 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.
report_renderer.render (cyclomatic 16) src/services/report_renderer.py:93— report_renderer.render 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.
research_artifact_service._build_evidence (cyclomatic 16) src/services/research_artifact_service.py:96— research_artifact_service._build_evidence has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
run_diagnostics._llm_component (cyclomatic 16) src/services/run_diagnostics.py:1279— run_diagnostics._llm_component 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.
run_diagnostics._notification_component (cyclomatic 16) src/services/run_diagnostics.py:1332— run_diagnostics._notification_component 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.
candidate_context.collect_candidate_context (cyclomatic 16) src/services/screening/candidate_context.py:51— candidate_context.collect_candidate_context 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.
context._load_candidate_context_rows (cyclomatic 16) src/services/screening/context.py:409— context._load_candidate_context_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.
daily._latest_daily_bar_date (cyclomatic 16) src/services/screening/daily.py:484— daily._latest_daily_bar_date 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.
daily._fetch_daily_tencent (cyclomatic 16) src/services/screening/daily.py:669— daily._fetch_daily_tencent 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.
hotspot.load_hotspot_timeline (cyclomatic 16) src/services/screening/hotspot.py:681— hotspot.load_hotspot_timeline 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.
ranker.rank_candidates_with_metadata (cyclomatic 16) src/services/screening/ranker.py:122— ranker.rank_candidates_with_metadata 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.
ranker._parse_ranking_response_detail (cyclomatic 16) src/services/screening/ranker.py:746— ranker._parse_ranking_response_detail 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.
ScreeningService.hotspot_detail (cyclomatic 16) REDACTED:1112— ScreeningService.hotspot_detail 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.
SystemConfigService._validate_generation_backend_litellm_runtime_source (cyclomatic 16) src/services/system_config_service.py:2482— SystemConfigService._validate_generation_backend_litellm_runtime_source 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.
SystemConfigService._validate_llm_channel_connection (cyclomatic 16) src/services/system_config_service.py:5519— SystemConfigService._validate_llm_channel_connection 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.
AnalysisTaskQueue._execute_task (cyclomatic 16) src/services/task_queue.py:758— AnalysisTaskQueue._execute_task 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.
share_image._merge_index_cards (cyclomatic 16) src/share_image.py:458— share_image._merge_index_cards 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.
share_image._compact_position (cyclomatic 16) src/share_image.py:629— share_image._compact_position 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.
StockTrendAnalyzer._analyze_macd (cyclomatic 16) src/stock_analyzer.py:482— StockTrendAnalyzer._analyze_macd 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.
sanitize._is_webhook_url (cyclomatic 16) src/utils/sanitize.py:166— sanitize._is_webhook_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.
ReportDetails.ReportDetails (cyclomatic 16) apps/dsa-web/src/components/report/ReportDetails.tsx:17— ReportDetails.ReportDetails has cyclomatic complexity 16 (threshold 15). Of this number, 11 points are the body's own statements and 5 belong to 3 function items inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
RunFlowEventList.RunFlowEventList (cyclomatic 16) apps/dsa-web/src/components/run-flow/RunFlowEventList.tsx:54— RunFlowEventList.RunFlowEventList has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 2 of the 16 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 105, 62, 109, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
LLMChannelEditor.buildFilteredChannelUpdateItems (cyclomatic 16) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1569— LLMChannelEditor.buildFilteredChannelUpdateItems has cyclomatic complexity 16 (threshold 15). Of this number, 10 points are the body's own statements and 6 belong to 2 function literals inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D10 · Test Quality· Fixed-sleep synchronisation · ×1
Fixed-sleep synchronisation: createWindow startup path does not throw ReferenceError after restore result handling apps/dsa-desktop/tests/main.test.js:1336— This test starts work it did not wait for (`mainModule`, still running when the sleep starts) and then orders itself against it with `new Promise((resolve) => {
setTimeout(resolve, 80);
})` — a fixed wait, not a signal that the work is done. Whether it passes depends on how loaded the machine is, which is why a test written this way is green on a developer's box and random in CI. Wait for the event itself instead: the process's own exit or output, a completion handle, or a condition polled to a timeout.
StockScreeningPage.StockScreeningPage (cognitive 358) apps/dsa-web/src/pages/StockScreeningPage.tsx:841— StockScreeningPage.StockScreeningPage has cognitive complexity 358 (threshold 15). Drivers by points: ternaries 97 (199 pts), boolean chains 86, if/else 51 (63 pts), error handling 9 (10 pts) (nesting depth added 115). Of this number, 127 points are the body's own statements and 231 belong to 41 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PortfolioPage.PortfolioPage (cognitive 292) apps/dsa-web/src/pages/PortfolioPage.tsx:624— PortfolioPage.PortfolioPage has cognitive complexity 292 (threshold 15). Drivers by points: ternaries 84 (119 pts), boolean chains 83, if/else 53 (66 pts), error handling 17, loops 5 (7 pts) (nesting depth added 50). Of this number, 117 points are the body's own statements and 175 belong to 40 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HomePage.HomePage (cognitive 246) apps/dsa-web/src/pages/HomePage.tsx:252— HomePage.HomePage has cognitive complexity 246 (threshold 15). Drivers by points: if/else 78 (98 pts), ternaries 53 (82 pts), boolean chains 52, error handling 6 (7 pts), loops 6, match/switch 1 (nesting depth added 50). Of this number, 57 points are the body's own statements and 189 belong to 59 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SettingsPage.SettingsPage (cognitive 236) apps/dsa-web/src/pages/SettingsPage.tsx:688— SettingsPage.SettingsPage has cognitive complexity 236 (threshold 15). Drivers by points: ternaries 64 (137 pts), boolean chains 54, if/else 27 (38 pts), error handling 6, loops 1 (nesting depth added 84). Of this number, 169 points are the body's own statements and 67 belong to 20 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NotificationService.generate_dashboard_report (cognitive 201) src/notification.py:1255— NotificationService.generate_dashboard_report has cognitive complexity 201 (threshold 15). Drivers by points: if/else 42 (143 pts), ternaries 9 (30 pts), loops 6 (24 pts), boolean chains 4 (nesting depth added 140). 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.
DataFetcherManager.get_realtime_quote (cognitive 179) data_provider/base.py:2432— DataFetcherManager.get_realtime_quote has cognitive complexity 179 (threshold 15). Drivers by points: if/else 45 (113 pts), ternaries 12 (28 pts), boolean chains 22, loops 4 (11 pts), error handling 2 (5 pts) (nesting depth added 94). 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.
GeminiAnalyzer._format_prompt (cognitive 166) src/analyzer.py:4313— GeminiAnalyzer._format_prompt has cognitive complexity 166 (threshold 15). Drivers by points: if/else 57 (74 pts), ternaries 34 (69 pts), boolean chains 22, error handling 1 (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.
Config._load_from_env (cognitive 166) src/config.py:1492— Config._load_from_env has cognitive complexity 166 (threshold 15). Drivers by points: if/else 61 (87 pts), boolean chains 62, ternaries 8 (15 pts), loops 2 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Config.validate_structured (cognitive 159) src/config.py:3241— Config.validate_structured has cognitive complexity 159 (threshold 15). Drivers by points: if/else 52 (83 pts), boolean chains 58, loops 5 (8 pts), ternaries 3 (6 pts), error handling 2 (4 pts) (nesting depth added 39). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockAnalysisPipeline._send_notifications (cognitive 156) src/core/pipeline.py:3805— StockAnalysisPipeline._send_notifications has cognitive complexity 156 (threshold 15). Drivers by points: if/else 30 (71 pts), ternaries 8 (36 pts), boolean chains 24, loops 5 (24 pts), error handling 1 (nesting depth added 88). 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.
NotificationService.generate_wechat_dashboard (cognitive 145) src/notification.py:1624— NotificationService.generate_wechat_dashboard has cognitive complexity 145 (threshold 15). Drivers by points: if/else 27 (82 pts), ternaries 13 (43 pts), loops 5 (17 pts), boolean chains 3 (nesting depth added 97). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockAnalysisPipeline.analyze_stock (cognitive 129) src/core/pipeline.py:434— StockAnalysisPipeline.analyze_stock has cognitive complexity 129 (threshold 15). Drivers by points: if/else 51 (73 pts), boolean chains 21, error handling 10 (17 pts), ternaries 10 (15 pts), loops 1 (3 pts) (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.run_full_analysis (cognitive 127) main.py:800— main.run_full_analysis has cognitive complexity 127 (threshold 15). Drivers by points: if/else 47 (80 pts), boolean chains 31, loops 3 (7 pts), ternaries 5 (7 pts), error handling 2 (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.
main.main (cognitive 123) main.py:1549— main.main has cognitive complexity 123 (threshold 15). Drivers by points: if/else 40 (67 pts), boolean chains 18, error handling 10 (16 pts), ternaries 6 (14 pts), loops 4 (8 pts) (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockAnalysisPipeline._analyze_with_agent (cognitive 114) src/core/pipeline.py:1460— StockAnalysisPipeline._analyze_with_agent has cognitive complexity 114 (threshold 15). Drivers by points: if/else 45 (65 pts), boolean chains 22, ternaries 13 (19 pts), error handling 5 (8 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.
pipeline.screen (cognitive 112) src/services/screening/pipeline.py:51— pipeline.screen has cognitive complexity 112 (threshold 15). Drivers by points: if/else 36 (60 pts), ternaries 13 (25 pts), boolean chains 18, loops 2 (5 pts), error handling 2 (4 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.
GeminiAnalyzer._call_litellm_impl (cognitive 107) src/analyzer.py:3604— GeminiAnalyzer._call_litellm_impl has cognitive complexity 107 (threshold 15). Drivers by points: if/else 28 (71 pts), boolean chains 16, error handling 5 (14 pts), ternaries 2 (5 pts), loops 1 (nesting depth added 55). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
share_image._market_data (cognitive 107) src/share_image.py:1407— share_image._market_data has cognitive complexity 107 (threshold 15). Drivers by points: if/else 30 (60 pts), ternaries 9 (25 pts), boolean chains 13, loops 5 (9 pts) (nesting depth added 50). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
LLMChannelEditor.ChannelRow (cognitive 106) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:399— LLMChannelEditor.ChannelRow has cognitive complexity 106 (threshold 15). Drivers by points: ternaries 43 (86 pts), boolean chains 16, if/else 2 (4 pts) (nesting depth added 45). Of this number, 100 points are the body's own statements and 6 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NotificationService.generate_daily_report (cognitive 104) src/notification.py:902— NotificationService.generate_daily_report has cognitive complexity 104 (threshold 15). Drivers by points: if/else 28 (79 pts), boolean chains 17, loops 2 (4 pts), ternaries 2 (4 pts) (nesting depth added 55). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HistoryService._generate_single_stock_markdown (cognitive 104) src/services/history_service.py:1112— HistoryService._generate_single_stock_markdown has cognitive complexity 104 (threshold 15). Drivers by points: if/else 37 (69 pts), ternaries 12 (16 pts), loops 4 (12 pts), boolean chains 4, error handling 1 (3 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.
Config._parse_llm_channels_with_issues (cognitive 100) src/config.py:2492— Config._parse_llm_channels_with_issues has cognitive complexity 100 (threshold 15). Drivers by points: if/else 31 (71 pts), boolean chains 20, loops 3 (6 pts), error handling 1 (3 pts) (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentOrchestrator._finalize_dashboard_payload (cognitive 97) src/agent/orchestrator.py:1414— AgentOrchestrator._finalize_dashboard_payload has cognitive complexity 97 (threshold 15). Drivers by points: if/else 46 (57 pts), boolean chains 20, ternaries 11 (17 pts), loops 1 (2 pts), error handling 1 (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.
StockAnalysisPipeline._enhance_context (cognitive 95) src/core/pipeline.py:1002— StockAnalysisPipeline._enhance_context has cognitive complexity 95 (threshold 15). Drivers by points: if/else 22 (57 pts), ternaries 6 (14 pts), boolean chains 12, error handling 2 (9 pts), loops 1 (3 pts) (nesting depth added 52). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
RunFlowGraph.RunFlowGraph (cognitive 94) apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:314— RunFlowGraph.RunFlowGraph has cognitive complexity 94 (threshold 15). Drivers by points: ternaries 34 (43 pts), boolean chains 37, if/else 13 (14 pts) (nesting depth added 10). Most of this is not in the body itself: 5 of the 94 points are its own statements and the rest belongs to 25 function literals inside it that branch (lines 568, 746, 392, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
BacktestPage.BacktestPage (cognitive 90) apps/dsa-web/src/pages/BacktestPage.tsx:246— BacktestPage.BacktestPage has cognitive complexity 90 (threshold 15). Drivers by points: ternaries 26 (58 pts), boolean chains 24, if/else 5, error handling 3 (nesting depth added 32). Of this number, 40 points are the body's own statements and 50 belong to 6 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.
generate_index_from_csv.validate_index_registry (cognitive 89) scripts/generate_index_from_csv.py:774— generate_index_from_csv.validate_index_registry has cognitive complexity 89 (threshold 15). Drivers by points: if/else 26 (62 pts), boolean chains 13, loops 6 (10 pts), ternaries 2 (4 pts) (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchService._score_news_relevance (cognitive 89) src/search_service.py:3186— SearchService._score_news_relevance has cognitive complexity 89 (threshold 15). Drivers by points: if/else 24 (55 pts), loops 6 (12 pts), ternaries 4 (12 pts), boolean chains 10 (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.
analysis.get_analysis_status (cognitive 87) api/v1/endpoints/analysis.py:1170— analysis.get_analysis_status has cognitive complexity 87 (threshold 15). Drivers by points: if/else 19 (57 pts), boolean chains 13, ternaries 6 (12 pts), error handling 2 (5 pts) (nesting depth added 47). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
SearchService.search_stock_news (cognitive 87) src/search_service.py:4021— SearchService.search_stock_news has cognitive complexity 87 (threshold 15). Drivers by points: if/else 21 (39 pts), ternaries 12 (25 pts), boolean chains 20, error handling 1 (2 pts), loops 1 (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stockPoolStore.useStockPoolStore (cognitive 87) apps/dsa-web/src/stores/stockPoolStore.ts:615— stockPoolStore.useStockPoolStore has cognitive complexity 87 (threshold 15). Drivers by points: if/else 47 (56 pts), boolean chains 19, error handling 7, ternaries 4, loops 1 (nesting depth added 9). None of this is in the body itself: all 87 points belong to 22 function literals inside it that branch (lines 886, 714, 788, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
DataFetcherManager.get_daily_data (cognitive 85) data_provider/base.py:1919— DataFetcherManager.get_daily_data has cognitive complexity 85 (threshold 15). Drivers by points: if/else 16 (34 pts), ternaries 14 (25 pts), boolean chains 14, error handling 2 (6 pts), loops 3 (6 pts) (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarketAnalyzer._build_review_prompt (cognitive 85) src/market_analyzer.py:1652— MarketAnalyzer._build_review_prompt has cognitive complexity 85 (threshold 15). Drivers by points: ternaries 24 (53 pts), if/else 17 (28 pts), boolean chains 2, loops 2 (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.
YfinanceFundamentalAdapter.get_fundamental_bundle (cognitive 84) data_provider/yfinance_fundamental_adapter.py:158— YfinanceFundamentalAdapter.get_fundamental_bundle has cognitive complexity 84 (threshold 15). Drivers by points: if/else 29 (41 pts), boolean chains 19, error handling 9 (15 pts), ternaries 4 (5 pts), loops 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.
chat_object_decision.decide_chat_object (cognitive 82) src/agent/chat_object_decision.py:165— chat_object_decision.decide_chat_object has cognitive complexity 82 (threshold 15). Drivers by points: if/else 32 (61 pts), boolean chains 11, loops 4 (6 pts), ternaries 2 (4 pts) (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.
AgentOrchestrator._execute_pipeline (cognitive 82) src/agent/orchestrator.py:567— AgentOrchestrator._execute_pipeline has cognitive complexity 82 (threshold 15). Drivers by points: if/else 25 (63 pts), boolean chains 9, loops 2 (5 pts), ternaries 3 (5 pts) (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.
CodexToolProcessRunner.execute (cognitive 81) src/agent/codex_tool_process.py:327— CodexToolProcessRunner.execute has cognitive complexity 81 (threshold 15). Drivers by points: if/else 29 (50 pts), boolean chains 14, error handling 5 (10 pts), loops 2 (4 pts), ternaries 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.
StockAnalysisPipeline._agent_result_to_analysis_result (cognitive 80) src/core/pipeline.py:2133— StockAnalysisPipeline._agent_result_to_analysis_result has cognitive complexity 80 (threshold 15). Drivers by points: if/else 27 (55 pts), ternaries 6 (14 pts), boolean chains 11 (nesting depth added 36). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
DataFetcherManager.get_fundamental_context (cognitive 79) data_provider/base.py:4295— DataFetcherManager.get_fundamental_context has cognitive complexity 79 (threshold 15). Drivers by points: if/else 33 (46 pts), ternaries 16 (22 pts), error handling 2 (6 pts), boolean chains 4, loops 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PortfolioService._replay_account (cognitive 77) src/services/portfolio_service.py:781— PortfolioService._replay_account has cognitive complexity 77 (threshold 15). Drivers by points: if/else 20 (52 pts), boolean chains 14, loops 6 (10 pts), ternaries 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.
run_flow._append_active_flow_events (cognitive 75) src/services/run_flow.py:935— run_flow._append_active_flow_events has cognitive complexity 75 (threshold 15). Drivers by points: if/else 12 (29 pts), ternaries 6 (24 pts), boolean chains 21, loops 1 (nesting depth added 35). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
hotspot.get_hotspot_detail (cognitive 75) src/services/screening/hotspot.py:417— hotspot.get_hotspot_detail has cognitive complexity 75 (threshold 15). Drivers by points: if/else 20 (38 pts), boolean chains 21, ternaries 5 (12 pts), error handling 1 (2 pts), loops 1 (2 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemConfigService._validate_value (cognitive 73) src/services/system_config_service.py:2560— SystemConfigService._validate_value has cognitive complexity 73 (threshold 15). Drivers by points: if/else 22 (39 pts), boolean chains 14, error handling 5 (11 pts), loops 2 (5 pts), ternaries 2 (4 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
share_image._market_data_from_payload (cognitive 73) src/share_image.py:1586— share_image._market_data_from_payload has cognitive complexity 73 (threshold 15). Drivers by points: if/else 21 (39 pts), ternaries 5 (15 pts), boolean chains 8, loops 2 (6 pts), error handling 1 (5 pts) (nesting depth added 36). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
stock_index_loader._validate_index_rows_semantics (cognitive 72) src/data/stock_index_loader.py:597— stock_index_loader._validate_index_rows_semantics has cognitive complexity 72 (threshold 15). Drivers by points: if/else 20 (50 pts), boolean chains 10, loops 5 (8 pts), ternaries 2 (4 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.
StockAnalysisPipeline.run (cognitive 71) src/core/pipeline.py:3398— StockAnalysisPipeline.run has cognitive complexity 71 (threshold 15). Drivers by points: if/else 25 (41 pts), boolean chains 13, ternaries 4 (9 pts), loops 4 (6 pts), error handling 1 (2 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
web_intent_resolver._consume_confirmations (cognitive 70) src/agent/web_intent_resolver.py:975— web_intent_resolver._consume_confirmations has cognitive complexity 70 (threshold 15). Drivers by points: if/else 23 (46 pts), boolean chains 14, loops 5 (9 pts), ternaries 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.
stock_list_parser.parse_analysis_target (cognitive 70) src/services/stock_list_parser.py:632— stock_list_parser.parse_analysis_target has cognitive complexity 70 (threshold 15). Drivers by points: if/else 25 (43 pts), boolean chains 19, ternaries 2 (6 pts), loops 1 (2 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.
runner.run_agent_loop (cognitive 69) src/agent/runner.py:326— runner.run_agent_loop has cognitive complexity 69 (threshold 15). Drivers by points: if/else 16 (36 pts), ternaries 5 (15 pts), boolean chains 14, loops 2 (4 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.
screening_service._attach_candidate_explanations (cognitive 69) REDACTED:3984— screening_service._attach_candidate_explanations has cognitive complexity 69 (threshold 15). Drivers by points: if/else 24 (37 pts), boolean chains 23, ternaries 3 (5 pts), loops 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.
SystemConfigService._collect_setup_channel_models (cognitive 69) src/services/system_config_service.py:3452— SystemConfigService._collect_setup_channel_models has cognitive complexity 69 (threshold 15). Drivers by points: if/else 15 (34 pts), boolean chains 29, loops 3 (6 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.
HistoryService._history_code_filter_candidates (cognitive 68) src/services/history_service.py:108— HistoryService._history_code_filter_candidates has cognitive complexity 68 (threshold 15). Drivers by points: if/else 18 (42 pts), boolean chains 16, loops 3 (7 pts), error handling 2 (3 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatPage.ChatPage (cognitive 68) apps/dsa-web/src/pages/ChatPage.tsx:83— ChatPage.ChatPage has cognitive complexity 68 (threshold 15). Drivers by points: ternaries 51 (78 pts), if/else 61 (69 pts), boolean chains 64, error handling 5, loops 1 (nesting depth added 35). 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. This shape REPEATS in the file: one other method here (ChatPage.ChatPage::getCurrentStage) 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.
DataFetcherManager._normalize_belong_boards (cognitive 67) data_provider/base.py:1683— DataFetcherManager._normalize_belong_boards has cognitive complexity 67 (threshold 15). Drivers by points: if/else 23 (60 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 39). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
web_intent_resolver._merge_llm_result (cognitive 66) src/agent/web_intent_resolver.py:1292— web_intent_resolver._merge_llm_result has cognitive complexity 66 (threshold 15). Drivers by points: if/else 27 (48 pts), boolean chains 10, ternaries 3 (4 pts), loops 3, error handling 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.
local_cli_backend._redact_multiline_sensitive_fields (cognitive 66) src/llm/local_cli_backend.py:1055— local_cli_backend._redact_multiline_sensitive_fields has cognitive complexity 66 (threshold 15). Drivers by points: if/else 17 (49 pts), boolean chains 14, loops 2 (3 pts) (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.
GenerationBackendStatusService._parse_llm_channels_from_map (cognitive 66) src/services/generation_backend_status_service.py:835— GenerationBackendStatusService._parse_llm_channels_from_map has cognitive complexity 66 (threshold 15). Drivers by points: if/else 18 (36 pts), boolean chains 29, 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.
DataFetcherManager._build_offshore_fundamental_context (cognitive 65) data_provider/base.py:3949— DataFetcherManager._build_offshore_fundamental_context has cognitive complexity 65 (threshold 15). Drivers by points: if/else 27 (37 pts), ternaries 14 (15 pts), boolean chains 9, error handling 1 (3 pts), loops 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.
analyzer.apply_placeholder_fill (cognitive 65) src/analyzer.py:406— analyzer.apply_placeholder_fill has cognitive complexity 65 (threshold 15). Drivers by points: if/else 20 (63 pts), boolean chains 1, 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.
SystemConfigService._validate_llm_channel_map (cognitive 65) src/services/system_config_service.py:4642— SystemConfigService._validate_llm_channel_map has cognitive complexity 65 (threshold 15). Drivers by points: if/else 17 (35 pts), boolean chains 24, loops 4 (6 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.
formatters.chunk_markdown_preserving_blocks (cognitive 64) src/formatters.py:361— formatters.chunk_markdown_preserving_blocks has cognitive complexity 64 (threshold 15). Drivers by points: if/else 22 (46 pts), ternaries 4 (10 pts), loops 3 (5 pts), boolean chains 3 (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.
analysis_tools._handle_analyze_pattern (cognitive 62) src/agent/tools/analysis_tools.py:324— analysis_tools._handle_analyze_pattern has cognitive complexity 62 (threshold 15). Drivers by points: if/else 18 (31 pts), ternaries 8 (17 pts), boolean chains 12, loops 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.
import_parser._parse_dataframe (cognitive 60) src/services/import_parser.py:70— import_parser._parse_dataframe has cognitive complexity 60 (threshold 15). Drivers by points: if/else 14 (34 pts), ternaries 5 (18 pts), boolean chains 7, 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.
SocialSentimentService._format_social_intel (cognitive 60) src/services/social_sentiment_service.py:244— SocialSentimentService._format_social_intel has cognitive complexity 60 (threshold 15). Drivers by points: if/else 20 (40 pts), ternaries 4 (13 pts), loops 2 (6 pts), boolean chains 1 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
auth.auth_update_settings (cognitive 59) api/v1/endpoints/auth.py:208— auth.auth_update_settings has cognitive complexity 59 (threshold 15). Drivers by points: if/else 22 (54 pts), boolean chains 5 (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.
SystemConfigService._collect_llm_channel_models_from_map (cognitive 59) src/services/system_config_service.py:4832— SystemConfigService._collect_llm_channel_models_from_map has cognitive complexity 59 (threshold 15). Drivers by points: if/else 13 (29 pts), boolean chains 24, loops 3 (6 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.
share_image._stock_data (cognitive 59) src/share_image.py:953— share_image._stock_data has cognitive complexity 59 (threshold 15). Drivers by points: if/else 20 (28 pts), ternaries 9 (18 pts), boolean chains 8, loops 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.
RunFlowNodeDetails.RunFlowNodeDetails (cognitive 58) apps/dsa-web/src/components/run-flow/RunFlowNodeDetails.tsx:111— RunFlowNodeDetails.RunFlowNodeDetails has cognitive complexity 58 (threshold 15). Drivers by points: ternaries 17 (26 pts), boolean chains 16, if/else 14 (16 pts) (nesting depth added 11). Of this number, 33 points are the body's own statements and 25 belong to 10 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PortfolioPage.buildExposureRows (cognitive 57) apps/dsa-web/src/pages/PortfolioPage.tsx:372— PortfolioPage.buildExposureRows has cognitive complexity 57 (threshold 15). Drivers by points: if/else 12 (25 pts), boolean chains 16, ternaries 5 (10 pts), loops 4 (6 pts) (nesting depth added 20). Of this number, 55 points are the body's own statements and 2 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
screening_service._build_dsa_candidate_context (cognitive 56) REDACTED:3612— screening_service._build_dsa_candidate_context has cognitive complexity 56 (threshold 15). Drivers by points: if/else 18 (27 pts), boolean chains 12, error handling 5 (11 pts), ternaries 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.
DecisionSignalsPage.DecisionSignalsPage::renderReassessPanel (cognitive 56) apps/dsa-web/src/pages/DecisionSignalsPage.tsx:966— DecisionSignalsPage.DecisionSignalsPage::renderReassessPanel has cognitive complexity 56 (threshold 15). Drivers by points: ternaries 31 (50 pts), boolean chains 6 (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. This shape REPEATS in the file: one other method here (DecisionSignalsPage.DecisionSignalsPage) 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.
usage.normalize_litellm_usage (cognitive 55) src/llm/usage.py:275— usage.normalize_litellm_usage has cognitive complexity 55 (threshold 15). Drivers by points: if/else 16 (29 pts), boolean chains 21, ternaries 5 (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.
IntelligentImport.IntelligentImport (cognitive 55) apps/dsa-web/src/components/settings/IntelligentImport.tsx:100— IntelligentImport.IntelligentImport has cognitive complexity 55 (threshold 15). Drivers by points: boolean chains 23, if/else 18 (20 pts), ternaries 6 (9 pts), error handling 3 (nesting depth added 5). Of this number, 16 points are the body's own statements and 39 belong to 14 function literals inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
web_intent_resolver._token_facts (cognitive 54) src/agent/web_intent_resolver.py:368— web_intent_resolver._token_facts has cognitive complexity 54 (threshold 15). Drivers by points: if/else 13 (33 pts), boolean chains 15, loops 2 (4 pts), ternaries 1 (2 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.
LocalCliGenerationBackend.generate (cognitive 54) src/llm/local_cli_backend.py:2095— LocalCliGenerationBackend.generate has cognitive complexity 54 (threshold 15). Drivers by points: if/else 18 (28 pts), error handling 14 (20 pts), boolean chains 3, ternaries 1 (2 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.
chat_object_decision.object_mentions (cognitive 53) src/agent/chat_object_decision.py:52— chat_object_decision.object_mentions has cognitive complexity 53 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 7 (12 pts), ternaries 3 (11 pts), boolean chains 7, error handling 2 (6 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.
web_intent_resolver._classify_rule (cognitive 53) src/agent/web_intent_resolver.py:527— web_intent_resolver._classify_rule has cognitive complexity 53 (threshold 15). Drivers by points: boolean chains 21, if/else 12 (17 pts), ternaries 7 (13 pts), loops 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.
portfolio._load_position_codes (cognitive 53) src/brokers/futu/portfolio.py:233— portfolio._load_position_codes has cognitive complexity 53 (threshold 15). Drivers by points: if/else 12 (31 pts), ternaries 3 (11 pts), error handling 3 (7 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NotificationService.generate_single_stock_report (cognitive 52) src/notification.py:1959— NotificationService.generate_single_stock_report has cognitive complexity 52 (threshold 15). Drivers by points: if/else 20 (34 pts), loops 3 (9 pts), ternaries 8, 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.
GeminiAnalyzer.analyze (cognitive 51) src/analyzer.py:3989— GeminiAnalyzer.analyze has cognitive complexity 51 (threshold 15). Drivers by points: if/else 22 (31 pts), boolean chains 8, ternaries 5 (8 pts), error handling 2 (3 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.
SerpAPISearchProvider._do_search (cognitive 51) src/search_service.py:626— SerpAPISearchProvider._do_search has cognitive complexity 51 (threshold 15). Drivers by points: if/else 14 (33 pts), loops 4 (8 pts), error handling 3 (5 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 26). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
runtime_scheduler._terminate_analysis_process_tree (cognitive 51) src/services/runtime_scheduler.py:125— runtime_scheduler._terminate_analysis_process_tree has cognitive complexity 51 (threshold 15). Drivers by points: if/else 11 (19 pts), error handling 7 (18 pts), loops 4 (9 pts), boolean chains 5 (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.
industry.load_industry_map (cognitive 51) src/services/screening/industry.py:119— industry.load_industry_map has cognitive complexity 51 (threshold 15). Drivers by points: if/else 14 (34 pts), loops 4 (8 pts), ternaries 1 (5 pts), boolean chains 4 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarketReviewReportView.MarketReviewReportView (cognitive 51) apps/dsa-web/src/components/report/MarketReviewReportView.tsx:363— MarketReviewReportView.MarketReviewReportView has cognitive complexity 51 (threshold 15). Drivers by points: ternaries 20 (26 pts), boolean chains 14, if/else 7 (10 pts), error handling 1 (nesting depth added 9). Of this number, 21 points are the body's own statements and 30 belong to 10 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DatabaseManager._ensure_chat_session_schema (cognitive 50) REDACTED:1459— DatabaseManager._ensure_chat_session_schema has cognitive complexity 50 (threshold 15). Drivers by points: if/else 10 (29 pts), loops 5 (10 pts), error handling 3 (8 pts), boolean chains 3 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
market_review.run_market_review (cognitive 49) src/core/market_review.py:174— market_review.run_market_review has cognitive complexity 49 (threshold 15). Drivers by points: if/else 17 (32 pts), boolean chains 5, error handling 3 (5 pts), ternaries 3 (5 pts), loops 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.
LLMChannelEditor.buildChangedItemKeys (cognitive 49) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:310— LLMChannelEditor.buildChangedItemKeys has cognitive complexity 49 (threshold 15). Drivers by points: if/else 14 (33 pts), loops 5 (13 pts), boolean chains 3 (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.
AskCommand._analyze_multi (cognitive 48) bot/commands/ask.py:259— AskCommand._analyze_multi has cognitive complexity 48 (threshold 15). Drivers by points: if/else 12 (24 pts), error handling 3 (7 pts), loops 5 (7 pts), boolean chains 6, ternaries 1 (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.
AkshareFundamentalAdapter.get_fundamental_bundle (cognitive 47) data_provider/fundamental_adapter.py:372— AkshareFundamentalAdapter.get_fundamental_bundle has cognitive complexity 47 (threshold 15). Drivers by points: if/else 18 (36 pts), ternaries 4 (9 pts), boolean chains 2 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FutuFundamentalAdapter._dividends_and_splits (cognitive 47) data_provider/futu_fundamental_adapter.py:138— FutuFundamentalAdapter._dividends_and_splits has cognitive complexity 47 (threshold 15). Drivers by points: if/else 10 (25 pts), ternaries 4 (12 pts), boolean chains 8, loops 1 (2 pts) (nesting depth added 24). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
local_cli_backend._redact_yaml_explicit_sensitive_fields (cognitive 47) src/llm/local_cli_backend.py:1183— local_cli_backend._redact_yaml_explicit_sensitive_fields has cognitive complexity 47 (threshold 15). Drivers by points: if/else 9 (25 pts), boolean chains 9, loops 4 (7 pts), ternaries 3 (6 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.
PortfolioService._build_symbol_filter_values (cognitive 47) src/services/portfolio_service.py:1303— PortfolioService._build_symbol_filter_values has cognitive complexity 47 (threshold 15). Drivers by points: if/else 14 (26 pts), ternaries 4 (13 pts), boolean chains 5, 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.
ShareImageButton.ShareImageButton (cognitive 47) apps/dsa-web/src/components/report/ShareImageButton.tsx:38— ShareImageButton.ShareImageButton has cognitive complexity 47 (threshold 15). Drivers by points: if/else 12 (18 pts), ternaries 12 (18 pts), boolean chains 6, error handling 3 (5 pts) (nesting depth added 14). Of this number, 20 points are the body's own statements and 27 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DecisionSignalsPage.DecisionSignalsPage (cognitive 46) apps/dsa-web/src/pages/DecisionSignalsPage.tsx:388— DecisionSignalsPage.DecisionSignalsPage has cognitive complexity 46 (threshold 15). Drivers by points: ternaries 73 (108 pts), if/else 57 (68 pts), boolean chains 30, error handling 8, loops 1 (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. This shape REPEATS in the file: one other method here (DecisionSignalsPage.DecisionSignalsPage::renderReassessPanel) 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.
web_intent_resolver._reclaim_orphan_entities (cognitive 45) src/agent/web_intent_resolver.py:1529— web_intent_resolver._reclaim_orphan_entities has cognitive complexity 45 (threshold 15). Drivers by points: if/else 17 (23 pts), loops 5 (12 pts), boolean chains 9, ternaries 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
market_phase_summary.format_public_phase_pack_excerpt (cognitive 45) src/market_phase_summary.py:181— market_phase_summary.format_public_phase_pack_excerpt has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (32 pts), ternaries 4 (8 pts), boolean chains 3, loops 1 (2 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.
stock_code_utils.resolve_daily_stock_identity (cognitive 45) src/services/stock_code_utils.py:339— stock_code_utils.resolve_daily_stock_identity has cognitive complexity 45 (threshold 15). Drivers by points: if/else 21 (32 pts), boolean chains 11, loops 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.
Input.Input (cognitive 45) apps/dsa-web/src/components/common/Input.tsx:25— Input.Input has cognitive complexity 45 (threshold 15). Drivers by points: ternaries 23 (36 pts), boolean chains 5, if/else 3 (4 pts) (nesting depth added 14). Of this number, 37 points are the body's own statements and 8 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TickFlowFetcher.get_sector_rankings (cognitive 44) data_provider/tickflow_fetcher.py:1137— TickFlowFetcher.get_sector_rankings has cognitive complexity 44 (threshold 15). Drivers by points: if/else 15 (25 pts), boolean chains 14, loops 3, error handling 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.
metrics.compute_stage_trajectory_metrics (cognitive 44) evals/agent_trajectory/metrics.py:376— metrics.compute_stage_trajectory_metrics has cognitive complexity 44 (threshold 15). Drivers by points: if/else 20 (32 pts), boolean chains 8, ternaries 2 (3 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.
PortfolioImportService.commit_trade_records (cognitive 44) src/services/portfolio_import_service.py:182— PortfolioImportService.commit_trade_records has cognitive complexity 44 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 12, error handling 4 (8 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.
daily.fetch_daily_history (cognitive 44) src/services/screening/daily.py:170— daily.fetch_daily_history has cognitive complexity 44 (threshold 15). Drivers by points: if/else 15 (32 pts), boolean chains 4, error handling 1 (3 pts), loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemConfigService._validate_llm_runtime_selection (cognitive 44) src/services/system_config_service.py:5099— SystemConfigService._validate_llm_runtime_selection has cognitive complexity 44 (threshold 15). Drivers by points: if/else 17 (24 pts), boolean chains 20 (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.
HomeStockWorkspace.HomeStockWorkspace (cognitive 44) apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:388— HomeStockWorkspace.HomeStockWorkspace has cognitive complexity 44 (threshold 15). Drivers by points: ternaries 11 (23 pts), if/else 12, boolean chains 9 (nesting depth added 12). Of this number, 26 points are the body's own statements and 18 belong to 7 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
portfolio._filter_stock_codes (cognitive 43) src/brokers/futu/portfolio.py:358— portfolio._filter_stock_codes has cognitive complexity 43 (threshold 15). Drivers by points: if/else 15 (31 pts), loops 5 (8 pts), boolean chains 2, error handling 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.
SignalAttribution.validate_and_normalize_contributions (cognitive 43) src/schemas/report_schema.py:140— SignalAttribution.validate_and_normalize_contributions has cognitive complexity 43 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 4 (9 pts), error handling 2 (5 pts) (nesting depth added 25). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
PortfolioService._build_positions (cognitive 43) src/services/portfolio_service.py:1011— PortfolioService._build_positions has cognitive complexity 43 (threshold 15). Drivers by points: if/else 15 (31 pts), ternaries 4 (7 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
base.normalize_stock_code (cognitive 42) data_provider/base.py:71— base.normalize_stock_code has cognitive complexity 42 (threshold 15). Drivers by points: if/else 17 (28 pts), boolean chains 14 (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.
web_intent_tokenizer._split_by_stock_entities (cognitive 42) src/agent/web_intent_tokenizer.py:227— web_intent_tokenizer._split_by_stock_entities has cognitive complexity 42 (threshold 15). Drivers by points: if/else 12 (34 pts), loops 3 (7 pts), boolean chains 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BacktestEngine._first_intent_position (cognitive 42) src/core/backtest_engine.py:496— BacktestEngine._first_intent_position has cognitive complexity 42 (threshold 15). Drivers by points: if/else 11 (33 pts), loops 3 (7 pts), boolean chains 2 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
etf_rotation.run_backtest (cognitive 42) src/core/etf_rotation.py:167— etf_rotation.run_backtest has cognitive complexity 42 (threshold 15). Drivers by points: if/else 12 (27 pts), boolean chains 7, ternaries 3 (7 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AlertWorker.run_once (cognitive 42) REDACTED:107— AlertWorker.run_once has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (35 pts), boolean chains 3, error handling 2 (3 pts), loops 1 (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
import_parser.parse_import_from_bytes (cognitive 42) src/services/import_parser.py:128— import_parser.parse_import_from_bytes has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (23 pts), boolean chains 9, error handling 4 (6 pts), loops 2, ternaries 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.
notification_diagnostics.run_notification_diagnostics (cognitive 42) src/services/notification_diagnostics.py:314— notification_diagnostics.run_notification_diagnostics has cognitive complexity 42 (threshold 15). Drivers by points: if/else 18 (24 pts), boolean chains 11, error handling 2 (4 pts), ternaries 2, loops 1 (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.
industry.fetch_akshare_board_map (cognitive 42) src/services/screening/industry.py:177— industry.fetch_akshare_board_map has cognitive complexity 42 (threshold 15). Drivers by points: if/else 9 (26 pts), loops 3 (6 pts), error handling 2 (5 pts), boolean chains 4, ternaries 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.
ScreeningService.hotspots (cognitive 42) REDACTED:968— ScreeningService.hotspots has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (19 pts), ternaries 4 (10 pts), boolean chains 9, error handling 3 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
share_image._stock_data_from_payload (cognitive 42) src/share_image.py:1123— share_image._stock_data_from_payload has cognitive complexity 42 (threshold 15). Drivers by points: if/else 18 (21 pts), boolean chains 16, ternaries 4, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
agentChatStore.useAgentChatStore.startStream (cognitive 42) apps/dsa-web/src/stores/agentChatStore.ts:349— agentChatStore.useAgentChatStore.startStream has cognitive complexity 42 (threshold 15). Drivers by points: if/else 25 (40 pts), boolean chains 19, error handling 3 (6 pts), ternaries 3 (4 pts), loops 2 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (agentChatStore.useAgentChatStore.startStream::processLine) 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.
YfinanceFetcher.get_realtime_quote (cognitive 41) REDACTED:794— YfinanceFetcher.get_realtime_quote has cognitive complexity 41 (threshold 15). Drivers by points: boolean chains 15, if/else 9 (13 pts), ternaries 8 (9 pts), error handling 4 (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.
DecisionAgent.build_user_message (cognitive 41) src/agent/agents/decision_agent.py:159— DecisionAgent.build_user_message has cognitive complexity 41 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 3 (6 pts), boolean chains 5, ternaries 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.
NotificationService.send_with_results (cognitive 41) src/notification.py:2645— NotificationService.send_with_results has cognitive complexity 41 (threshold 15). Drivers by points: if/else 17 (22 pts), ternaries 4 (9 pts), error handling 2 (5 pts), boolean chains 4, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TelegramSender._send_telegram_message (cognitive 41) src/notification_sender/telegram_sender.py:121— TelegramSender._send_telegram_message has cognitive complexity 41 (threshold 15). Drivers by points: if/else 14 (35 pts), boolean chains 2, error handling 1 (2 pts), loops 1, ternaries 1 (nesting depth added 22). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
SearchService.search_comprehensive_intel (cognitive 41) src/search_service.py:4384— SearchService.search_comprehensive_intel has cognitive complexity 41 (threshold 15). Drivers by points: ternaries 11 (22 pts), if/else 11 (17 pts), boolean chains 1, loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stockCode.normalizeStockCode (cognitive 41) apps/dsa-web/src/utils/stockCode.ts:16— stockCode.normalizeStockCode has cognitive complexity 41 (threshold 15). Drivers by points: if/else 17 (27 pts), boolean chains 14 (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.
ReportDiagnostics.ReportDiagnostics (cognitive 41) apps/dsa-web/src/components/report/ReportDiagnostics.tsx:165— ReportDiagnostics.ReportDiagnostics has cognitive complexity 41 (threshold 15). Drivers by points: boolean chains 16, ternaries 14, if/else 10, error handling 1. Of this number, 23 points are the body's own statements and 18 belong to 8 function items inside it that branch. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AlertRuleForm.AlertRuleForm::buildParameters (cognitive 41) apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:284— AlertRuleForm.AlertRuleForm::buildParameters has cognitive complexity 41 (threshold 15). Drivers by points: if/else 24 (37 pts), boolean chains 4 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (AlertRuleForm.AlertRuleForm) 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.
CodexToolProcessRunner._terminate (cognitive 40) src/agent/codex_tool_process.py:542— CodexToolProcessRunner._terminate has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (15 pts), error handling 6 (12 pts), boolean chains 9, loops 2 (3 pts), ternaries 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
runner._execute_tools (cognitive 40) src/agent/runner.py:709— runner._execute_tools has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 10, loops 6 (9 pts), ternaries 3 (6 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DesktopUpdateIndicator.DesktopUpdateIndicator (cognitive 40) apps/dsa-web/src/components/layout/DesktopUpdateIndicator.tsx:12— DesktopUpdateIndicator.DesktopUpdateIndicator has cognitive complexity 40 (threshold 15). Drivers by points: boolean chains 18, ternaries 10 (18 pts), if/else 4 (nesting depth added 8). Of this number, 36 points are the body's own statements and 4 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EfinanceFetcher.get_main_indices (cognitive 39) data_provider/efinance_fetcher.py:924— EfinanceFetcher.get_main_indices has cognitive complexity 39 (threshold 15). Drivers by points: ternaries 11 (20 pts), if/else 7 (12 pts), boolean chains 3, loops 2 (3 pts), error handling 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.
LongbridgeFetcher._get_ctx (cognitive 39) REDACTED:497— LongbridgeFetcher._get_ctx has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (18 pts), error handling 5 (11 pts), boolean chains 5, loops 2 (3 pts), ternaries 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.
chat_context._build_visible_history_state (cognitive 39) src/agent/chat_context.py:238— chat_context._build_visible_history_state has cognitive complexity 39 (threshold 15). Drivers by points: if/else 17 (29 pts), boolean chains 8, ternaries 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.
web_intent_tokenizer._split_by_codes (cognitive 39) src/agent/web_intent_tokenizer.py:560— web_intent_tokenizer._split_by_codes has cognitive complexity 39 (threshold 15). Drivers by points: if/else 13 (26 pts), boolean chains 7, loops 4 (5 pts), ternaries 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Config._channels_to_model_list (cognitive 39) src/config.py:2745— Config._channels_to_model_list has cognitive complexity 39 (threshold 15). Drivers by points: if/else 7 (23 pts), boolean chains 10, loops 3 (6 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.
BacktestEngine.compute_summary (cognitive 39) src/core/backtest_engine.py:367— BacktestEngine.compute_summary has cognitive complexity 39 (threshold 15). Drivers by points: boolean chains 17, if/else 16, ternaries 6. 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.
image_stock_extractor._call_litellm_vision (cognitive 39) src/services/image_stock_extractor.py:270— image_stock_extractor._call_litellm_vision has cognitive complexity 39 (threshold 15). Drivers by points: if/else 17 (26 pts), boolean chains 11, ternaries 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.
daily.enrich_daily_features (cognitive 39) src/services/screening/daily.py:63— daily.enrich_daily_features has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 5 (9 pts), boolean chains 5, ternaries 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.
sniper_points.parse_sniper_value (cognitive 39) src/utils/sniper_points.py:14— sniper_points.parse_sniper_value has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (14 pts), ternaries 6 (11 pts), error handling 3 (6 pts), boolean chains 4, loops 3 (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.
LongbridgeFetcher.get_realtime_quote (cognitive 38) REDACTED:743— LongbridgeFetcher.get_realtime_quote has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15 (23 pts), boolean chains 11, ternaries 2 (3 pts), error handling 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.
executor.prepare_agent_chat (cognitive 38) src/agent/executor.py:538— executor.prepare_agent_chat has cognitive complexity 38 (threshold 15). Drivers by points: if/else 17 (26 pts), ternaries 4 (10 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.
ToolSurface.execute_tool (cognitive 38) src/agent/tool_surface.py:71— ToolSurface.execute_tool has cognitive complexity 38 (threshold 15). Drivers by points: if/else 13 (15 pts), ternaries 7 (11 pts), boolean chains 8, error handling 4 (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.
web_intent_tokenizer._dfs_match (cognitive 38) src/agent/web_intent_tokenizer.py:413— web_intent_tokenizer._dfs_match has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 8, ternaries 1 (4 pts), loops 2 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearchService.format_intel_report (cognitive 38) src/search_service.py:4638— SearchService.format_intel_report has cognitive complexity 38 (threshold 15). Drivers by points: if/else 7 (24 pts), ternaries 2 (8 pts), loops 2 (4 pts), boolean chains 2 (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.
AnalysisContextSummary.AnalysisContextSummary (cognitive 38) apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:307— AnalysisContextSummary.AnalysisContextSummary has cognitive complexity 38 (threshold 15). Drivers by points: ternaries 19 (27 pts), boolean chains 10, if/else 1 (nesting depth added 8). Of this number, 31 points are the body's own statements and 7 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DataFetcherManager.batch_get_stock_names (cognitive 37) data_provider/base.py:3249— DataFetcherManager.batch_get_stock_names has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (26 pts), loops 4 (6 pts), boolean chains 3, error handling 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.
LLMToolAdapter.call_completion (cognitive 37) src/agent/llm_adapter.py:586— LLMToolAdapter.call_completion has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (29 pts), boolean chains 4, error handling 1 (2 pts), loops 1, ternaries 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.
analyzer.stabilize_decision_with_structure (cognitive 37) src/analyzer.py:1043— analyzer.stabilize_decision_with_structure has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 15, ternaries 3, error handling 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.
stock_index_loader._build_stock_code_candidates (cognitive 37) src/data/stock_index_loader.py:152— stock_index_loader._build_stock_code_candidates has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (25 pts), boolean chains 9, ternaries 1 (2 pts), loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
report_language._first_non_negated_position (cognitive 37) src/report_language.py:883— report_language._first_non_negated_position has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (32 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SystemConfigService._collect_non_hermes_channel_models_from_map (cognitive 37) src/services/system_config_service.py:4964— SystemConfigService._collect_non_hermes_channel_models_from_map has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 14, 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.
useRunFlowSnapshot.appendDerivedEdge (cognitive 37) apps/dsa-web/src/hooks/useRunFlowSnapshot.ts:200— useRunFlowSnapshot.appendDerivedEdge has cognitive complexity 37 (threshold 15). Drivers by points: ternaries 7 (16 pts), if/else 10 (14 pts), boolean chains 7 (nesting depth added 13). Of this number, 30 points are the body's own statements and 7 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarketAnalyzer._generate_template_review (cognitive 36) src/market_analyzer.py:1892— MarketAnalyzer._generate_template_review has cognitive complexity 36 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 13, ternaries 8, loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
AgentChatSessionService._resolve_session_turn (cognitive 36) src/services/agent_chat_session_service.py:196— AgentChatSessionService._resolve_session_turn has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 8, ternaries 6, loops 2 (3 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.
AlertService.build_runtime_payloads (cognitive 36) src/services/alert_service.py:1005— AlertService.build_runtime_payloads has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (24 pts), boolean chains 5, ternaries 1 (3 pts), error handling 1 (2 pts), loops 1 (2 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BacktestService.run_backtest (cognitive 36) src/services/backtest_service.py:48— BacktestService.run_backtest has cognitive complexity 36 (threshold 15). Drivers by points: if/else 15 (21 pts), boolean chains 10, error handling 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
image_stock_extractor._parse_items_from_text (cognitive 36) src/services/image_stock_extractor.py:150— image_stock_extractor._parse_items_from_text has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (24 pts), boolean chains 3, error handling 2 (3 pts), loops 2 (3 pts), ternaries 1 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
analyzer.check_content_integrity (cognitive 35) src/analyzer.py:327— analyzer.check_content_integrity has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (23 pts), ternaries 6 (9 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.
StockAnalysisPipeline._augment_historical_with_realtime (cognitive 35) src/core/pipeline.py:2733— StockAnalysisPipeline._augment_historical_with_realtime has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (20 pts), boolean chains 8, ternaries 5 (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.
SearchService.search_stock_price_fallback (cognitive 35) src/search_service.py:4726— SearchService.search_stock_price_fallback has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (21 pts), loops 3 (7 pts), error handling 1 (3 pts), ternaries 2 (3 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.
DailyMarketContextService.get_context (cognitive 35) src/services/daily_market_context.py:103— DailyMarketContextService.get_context has cognitive complexity 35 (threshold 15). Drivers by points: if/else 18 (32 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.
RuntimeSchedulerService._run_analysis_with_watchdog (cognitive 35) src/services/runtime_scheduler.py:483— RuntimeSchedulerService._run_analysis_with_watchdog has cognitive complexity 35 (threshold 15). Drivers by points: if/else 20 (28 pts), boolean chains 3, error handling 2 (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.
filter.check_hard_filters (cognitive 35) src/services/screening/filter.py:125— filter.check_hard_filters has cognitive complexity 35 (threshold 15). Drivers by points: if/else 8 (16 pts), ternaries 5 (12 pts), boolean chains 6, 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.
screening_service._normalize_candidate (cognitive 35) REDACTED:3861— screening_service._normalize_candidate has cognitive complexity 35 (threshold 15). Drivers by points: boolean chains 30, if/else 3, ternaries 2. 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.
SystemConfigService.test_llm_channel (cognitive 35) src/services/system_config_service.py:1216— SystemConfigService.test_llm_channel has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (19 pts), boolean chains 9, ternaries 3 (4 pts), error handling 2 (3 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.
IntelligentImport.mergeItems (cognitive 35) apps/dsa-web/src/components/settings/IntelligentImport.tsx:43— IntelligentImport.mergeItems has cognitive complexity 35 (threshold 15). Drivers by points: ternaries 3 (16 pts), if/else 7 (14 pts), boolean chains 3, loops 2 (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.
PortfolioPage.buildPortfolioRiskFlags (cognitive 35) apps/dsa-web/src/pages/PortfolioPage.tsx:444— PortfolioPage.buildPortfolioRiskFlags has cognitive complexity 35 (threshold 15). Drivers by points: ternaries 26 (34 pts), boolean chains 1 (nesting depth added 8). Of this number, 34 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
HistoryCommand.execute (cognitive 34) bot/commands/history.py:67— HistoryCommand.execute has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (13 pts), ternaries 3 (8 pts), error handling 4 (6 pts), boolean chains 4, 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.
local_cli_backend._consume_authorization_param_list (cognitive 34) src/llm/local_cli_backend.py:1634— local_cli_backend._consume_authorization_param_list has cognitive complexity 34 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 5 (10 pts), boolean chains 8, ternaries 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PortfolioService._calculate_available_quantity (cognitive 34) src/services/portfolio_service.py:702— PortfolioService._calculate_available_quantity has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (27 pts), boolean chains 4, loops 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.
context._load_candidate_context_rows (cognitive 34) src/services/screening/context.py:409— context._load_candidate_context_rows has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (28 pts), loops 2 (5 pts), boolean chains 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.
SystemConfigService.discover_llm_channel_models (cognitive 34) src/services/system_config_service.py:946— SystemConfigService.discover_llm_channel_models has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (16 pts), boolean chains 12, error handling 4 (5 pts), ternaries 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.
TickFlowFetcher.get_main_indices (cognitive 33) data_provider/tickflow_fetcher.py:986— TickFlowFetcher.get_main_indices has cognitive complexity 33 (threshold 15). Drivers by points: boolean chains 15, if/else 9 (13 pts), ternaries 1 (3 pts), loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CodexAppServerTransport._route_message (cognitive 33) src/agent/codex_app_server_transport.py:760— CodexAppServerTransport._route_message has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (26 pts), boolean chains 7 (nesting depth added 15). 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.
stock_scope.resolve_stock_scope (cognitive 33) src/agent/stock_scope.py:313— stock_scope.resolve_stock_scope has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (14 pts), ternaries 4 (10 pts), boolean chains 7, error handling 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.
StockAnalysisPipeline._load_persisted_intelligence_context (cognitive 33) src/core/pipeline.py:3019— StockAnalysisPipeline._load_persisted_intelligence_context has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (18 pts), boolean chains 8, loops 3 (4 pts), ternaries 1 (2 pts), error handling 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.
local_cli_backend._extract_opencode_json_events (cognitive 33) src/llm/local_cli_backend.py:1857— local_cli_backend._extract_opencode_json_events has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 9, ternaries 1 (3 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.
SearchService._parse_relative_news_date (cognitive 33) src/search_service.py:3547— SearchService._parse_relative_news_date has cognitive complexity 33 (threshold 15). Drivers by points: if/else 18 (30 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.
snapshot._read_last_good_snapshot (cognitive 33) src/services/screening/snapshot.py:281— snapshot._read_last_good_snapshot has cognitive complexity 33 (threshold 15). Drivers by points: if/else 16 (21 pts), boolean chains 5, ternaries 2 (5 pts), error handling 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.
share_image._merge_sector_rankings (cognitive 33) src/share_image.py:513— share_image._merge_sector_rankings has cognitive complexity 33 (threshold 15). Drivers by points: if/else 10 (21 pts), ternaries 3 (6 pts), boolean chains 5, 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.
AuthSettingsCard.AuthSettingsCard (cognitive 33) apps/dsa-web/src/components/settings/AuthSettingsCard.tsx:22— AuthSettingsCard.AuthSettingsCard has cognitive complexity 33 (threshold 15). Drivers by points: boolean chains 14, ternaries 9 (11 pts), if/else 4 (6 pts), error handling 1, match/switch 1 (nesting depth added 4). Of this number, 17 points are the body's own statements and 16 belong to 2 function items inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
AgentBackendStatusPanel.AgentBackendStatusPanel (cognitive 33) apps/dsa-web/src/components/settings/AgentBackendStatusPanel.tsx:49— AgentBackendStatusPanel.AgentBackendStatusPanel has cognitive complexity 33 (threshold 15). Drivers by points: ternaries 14 (24 pts), if/else 4 (5 pts), boolean chains 3, error handling 1 (nesting depth added 11). Of this number, 26 points are the body's own statements and 7 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AlertsPage.AlertsPage (cognitive 33) apps/dsa-web/src/pages/AlertsPage.tsx:101— AlertsPage.AlertsPage has cognitive complexity 33 (threshold 15). Drivers by points: ternaries 11 (12 pts), if/else 8 (10 pts), error handling 7, boolean chains 4 (nesting depth added 3). Most of this is not in the body itself: 13 of the 33 points are its own statements and the rest belongs to 9 function items inside it that branch (a function literal at line 132, handleToggleEnabled, a function literal at line 169, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
analysis.trigger_analysis (cognitive 32) api/v1/endpoints/analysis.py:345— analysis.trigger_analysis has cognitive complexity 32 (threshold 15). Drivers by points: if/else 16 (24 pts), boolean chains 5, ternaries 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stocks.parse_import (cognitive 32) api/v1/endpoints/stocks.py:215— stocks.parse_import has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (11 pts), error handling 5 (10 pts), boolean chains 6, ternaries 2 (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.
DecisionSignalService.list_signals (cognitive 32) src/services/decision_signal_service.py:197— DecisionSignalService.list_signals has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (25 pts), boolean chains 5, loops 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PortfolioRiskService._build_decision_signal_risk (cognitive 32) src/services/portfolio_risk_service.py:103— PortfolioRiskService._build_decision_signal_risk has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 8, loops 3 (4 pts), ternaries 2 (4 pts), error handling 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.
ranker.rank_candidates_with_metadata (cognitive 32) src/services/screening/ranker.py:122— ranker.rank_candidates_with_metadata has cognitive complexity 32 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 4 (9 pts), boolean chains 4, ternaries 1 (4 pts), error handling 1 (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.
screening_service._enrich_hotspot_rows_from_provider (cognitive 32) REDACTED:593— screening_service._enrich_hotspot_rows_from_provider has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (19 pts), boolean chains 6, loops 3 (4 pts), ternaries 1 (2 pts), error handling 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.
IndexRegistry.__init__ (cognitive 32) src/services/stock_list_parser.py:306— IndexRegistry.__init__ has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 4 (7 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.
error.parseApiError (cognitive 32) apps/dsa-web/src/api/error.ts:310— error.parseApiError has cognitive complexity 32 (threshold 15). Drivers by points: if/else 17, boolean chains 13, ternaries 1 (2 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AlertRuleForm.AlertRuleForm (cognitive 32) apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:127— AlertRuleForm.AlertRuleForm has cognitive complexity 32 (threshold 15). Drivers by points: if/else 55 (69 pts), ternaries 27 (38 pts), boolean chains 8 (nesting depth added 25). 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. This shape REPEATS in the file: one other method here (AlertRuleForm.AlertRuleForm::buildParameters) 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.
CodexAppServerTransport._write_message (cognitive 31) src/agent/codex_app_server_transport.py:918— CodexAppServerTransport._write_message has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (17 pts), error handling 5 (9 pts), boolean chains 3, loops 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CodexAppServerTransport._terminate_process (cognitive 31) src/agent/codex_app_server_transport.py:1003— CodexAppServerTransport._terminate_process has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (12 pts), error handling 6 (11 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LLMDeliberationMediator._coerce_responses (cognitive 31) src/agent/skills/deliberation.py:452— LLMDeliberationMediator._coerce_responses has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (21 pts), boolean chains 9, 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.
NotificationService._send_to_static_channel (cognitive 31) src/notification.py:2578— NotificationService._send_to_static_channel has cognitive complexity 31 (threshold 15). Drivers by points: if/else 21 (28 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.
AlertService._coerce_datetime (cognitive 31) src/services/alert_service.py:778— AlertService._coerce_datetime has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (15 pts), error handling 5 (10 pts), ternaries 3 (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.
run_flow.build_history_run_flow_snapshot (cognitive 31) src/services/run_flow.py:183— run_flow.build_history_run_flow_snapshot has cognitive complexity 31 (threshold 15). Drivers by points: boolean chains 15, ternaries 9 (11 pts), if/else 5 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
screening_service._build_dsa_analysis_summary (cognitive 31) REDACTED:3773— screening_service._build_dsa_analysis_summary has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 5, ternaries 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.
SystemConfigService._build_display_config_map (cognitive 31) src/services/system_config_service.py:342— SystemConfigService._build_display_config_map has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 4 (8 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.
SettingsPage.SchedulerSettingsCard (cognitive 31) apps/dsa-web/src/pages/SettingsPage.tsx:419— SettingsPage.SchedulerSettingsCard has cognitive complexity 31 (threshold 15). Drivers by points: ternaries 14 (15 pts), boolean chains 10, if/else 4, error handling 2 (nesting depth added 1). Of this number, 21 points are the body's own statements and 10 belong to 8 function items inside it that branch. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
analysis._build_analysis_report (cognitive 30) api/v1/endpoints/analysis.py:1465— analysis._build_analysis_report has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (20 pts), boolean chains 9, 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.
smoke_bot_index_entry._run_parent (cognitive 30) scripts/smoke_bot_index_entry.py:382— smoke_bot_index_entry._run_parent has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (19 pts), ternaries 2 (6 pts), error handling 2 (4 pts), loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
provider_trace.extract_provider_trace_turns (cognitive 30) src/agent/provider_trace.py:142— provider_trace.extract_provider_trace_turns has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 14, 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.
SystemConfigService._resolve_hermes_saved_secret (cognitive 30) src/services/system_config_service.py:769— SystemConfigService._resolve_hermes_saved_secret has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 7 (14 pts), boolean chains 11, if/else 4, error handling 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.
SystemConfigService._build_setup_agent_llm_check (cognitive 30) src/services/system_config_service.py:3660— SystemConfigService._build_setup_agent_llm_check has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (23 pts), boolean chains 7 (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.
DatabaseManager._backfill_canonical_ids (cognitive 30) REDACTED:1954— DatabaseManager._backfill_canonical_ids has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 6, error handling 2 (4 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ThemeToggle.ThemeToggle (cognitive 30) apps/dsa-web/src/components/theme/ThemeToggle.tsx:43— ThemeToggle.ThemeToggle has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 15 (24 pts), boolean chains 4, if/else 2 (nesting depth added 9). Of this number, 23 points are the body's own statements and 7 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SidebarNav.SidebarNav (cognitive 30) apps/dsa-web/src/components/layout/SidebarNav.tsx:42— SidebarNav.SidebarNav has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 23 (28 pts), boolean chains 2 (nesting depth added 5). Of this number, 23 points are the body's own statements and 7 belong to 2 function literals inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
StockHistoryTrendDrawer.StockHistoryTrendDrawer (cognitive 30) apps/dsa-web/src/components/history/StockHistoryTrendDrawer.tsx:174— StockHistoryTrendDrawer.StockHistoryTrendDrawer has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 8 (26 pts), boolean chains 4 (nesting depth added 18). Most of this is not in the body itself: 13 of the 30 points are its own statements and the rest belongs to one function literal inside it that branches (line 322). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
TaskPanel.TaskItem (cognitive 30) apps/dsa-web/src/components/tasks/TaskPanel.tsx:21— TaskPanel.TaskItem has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 16 (25 pts), boolean chains 5 (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.
HomeStockWorkspace.WatchlistRowItem (cognitive 30) apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:247— HomeStockWorkspace.WatchlistRowItem has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 16 (27 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.
SettingsHelpButton.SettingsHelpButton (cognitive 30) apps/dsa-web/src/components/settings/SettingsHelpButton.tsx:93— SettingsHelpButton.SettingsHelpButton has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 10 (16 pts), if/else 9 (10 pts), boolean chains 4 (nesting depth added 7). Of this number, 19 points are the body's own statements and 11 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LLMChannelEditor.LLMChannelEditor (cognitive 30) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1667— LLMChannelEditor.LLMChannelEditor has cognitive complexity 30 (threshold 15). Drivers by points: if/else 42 (61 pts), ternaries 38 (56 pts), boolean chains 45, loops 4 (5 pts), error handling 4 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (LLMChannelEditor.LLMChannelEditor::handleSave) 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.
AlertRuleList.formatParameters (cognitive 30) apps/dsa-web/src/components/alerts/AlertRuleList.tsx:30— AlertRuleList.formatParameters has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 8 (15 pts), if/else 13 (14 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.
DataFetcherManager.get_stock_name (cognitive 29) data_provider/base.py:3061— DataFetcherManager.get_stock_name has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 7, ternaries 2 (3 pts), error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
longbridge_fetcher._longbridge_config_kwargs (cognitive 29) REDACTED:145— longbridge_fetcher._longbridge_config_kwargs has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (19 pts), error handling 4 (6 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
events.validate_event_alert_rule (cognitive 29) src/agent/events.py:463— events.validate_event_alert_rule has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (17 pts), error handling 6 (11 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.
market_review._render_sector_payload_block (cognitive 29) src/core/market_review.py:730— market_review._render_sector_payload_block has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 5, loops 2 (4 pts), ternaries 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.
SearchService._normalize_news_publish_date (cognitive 29) src/search_service.py:3601— SearchService._normalize_news_publish_date has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (15 pts), error handling 5 (8 pts), boolean chains 3, ternaries 1 (2 pts), loops 1 (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.
hotspot.discover_hotspots (cognitive 29) src/services/screening/hotspot.py:297— hotspot.discover_hotspots has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (19 pts), ternaries 2 (4 pts), boolean chains 3, loops 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.
main.createWindow (cognitive 29) REDACTED:1883— main.createWindow has cognitive complexity 29 (threshold 15). Drivers by points: if/else 16, ternaries 6, boolean chains 5, error handling 2. Most of this is not in the body itself: 12 of the 29 points are its own statements and the rest belongs to 3 function items inside it that branch (onHealthProgress, a function literal at line 2049, applyThemeBackground). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
updateState.getDesktopUpdateNotice (cognitive 29) apps/dsa-web/src/desktop/updateState.ts:45— updateState.getDesktopUpdateNotice has cognitive complexity 29 (threshold 15). Drivers by points: boolean chains 11, ternaries 5 (10 pts), if/else 8 (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.
SettingsPage.FirstRunSetupCard (cognitive 29) apps/dsa-web/src/pages/SettingsPage.tsx:207— SettingsPage.FirstRunSetupCard has cognitive complexity 29 (threshold 15). Drivers by points: ternaries 15 (21 pts), boolean chains 7, if/else 1 (nesting depth added 6). Of this number, 27 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
chatStockCode.extractStockCodesFromMessage (cognitive 29) apps/dsa-web/src/utils/chatStockCode.ts:57— chatStockCode.extractStockCodesFromMessage has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 5, loops 2, ternaries 1 (2 pts) (nesting depth added 11). Of this number, 23 points are the body's own statements and 6 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AkshareFetcher._calc_market_stats (cognitive 28) REDACTED:2096— AkshareFetcher._calc_market_stats has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 4, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EfinanceFetcher._calc_market_stats (cognitive 28) data_provider/efinance_fetcher.py:1062— EfinanceFetcher._calc_market_stats has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 4, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
fundamental_adapter._build_dividend_payload (cognitive 28) data_provider/fundamental_adapter.py:212— fundamental_adapter._build_dividend_payload has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (16 pts), ternaries 4 (7 pts), boolean chains 3, 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.
TushareFetcher.get_market_stats (cognitive 28) data_provider/tushare_fetcher.py:880— TushareFetcher.get_market_stats has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (20 pts), error handling 3 (5 pts), boolean chains 3 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TushareFetcher._calc_market_stats (cognitive 28) data_provider/tushare_fetcher.py:961— TushareFetcher._calc_market_stats has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 4, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generate_index_from_csv.load_index_registry_seed (cognitive 28) scripts/generate_index_from_csv.py:634— generate_index_from_csv.load_index_registry_seed has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 10, loops 2 (3 pts), error handling 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LLMToolAdapter._convert_messages (cognitive 28) src/agent/llm_adapter.py:795— LLMToolAdapter._convert_messages has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (16 pts), ternaries 2 (6 pts), loops 2 (4 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.
analyzer.fill_price_position_if_needed (cognitive 28) src/analyzer.py:992— analyzer.fill_price_position_if_needed has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (13 pts), ternaries 4 (8 pts), boolean chains 5, error handling 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.
hermes.parse_hermes_channel (cognitive 28) src/llm/hermes.py:275— hermes.parse_hermes_channel has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 6, loops 2 (5 pts), error handling 2 (nesting depth added 6). 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.
agent_backend_status_service._terminate_probe_process_group (cognitive 28) src/services/agent_backend_status_service.py:40— agent_backend_status_service._terminate_probe_process_group has cognitive complexity 28 (threshold 15). Drivers by points: error handling 6 (11 pts), if/else 6 (10 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.
BacktestService.get_summary (cognitive 28) src/services/backtest_service.py:613— BacktestService.get_summary has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (18 pts), ternaries 4 (8 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.
DecisionSignalOutcomeService._list_actionable_candidate_signals (cognitive 28) src/services/decision_signal_outcome_service.py:188— DecisionSignalOutcomeService._list_actionable_candidate_signals has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
etf_rotation_service.load_closes (cognitive 28) src/services/etf_rotation_service.py:96— etf_rotation_service.load_closes has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 6, error handling 1 (2 pts), loops 1, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
candidate_context._collect_candidate_context_row (cognitive 28) src/services/screening/candidate_context.py:134— candidate_context._collect_candidate_context_row has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (15 pts), error handling 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.
context.summarize_candidate_profile (cognitive 28) src/services/screening/context.py:199— context.summarize_candidate_profile has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (21 pts), loops 2 (4 pts), boolean chains 2, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ranker._format_dsa_context_for_prompt (cognitive 28) src/services/screening/ranker.py:493— ranker._format_dsa_context_for_prompt has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (16 pts), ternaries 9 (12 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.
screening_service._enrich_candidates_with_dsa (cognitive 28) REDACTED:3513— screening_service._enrich_candidates_with_dsa has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 8, error handling 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stock_list_parser._classify_bare_code (cognitive 28) src/services/stock_list_parser.py:526— stock_list_parser._classify_bare_code has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (26 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.
SettingsField.renderFieldControl (cognitive 28) apps/dsa-web/src/components/settings/SettingsField.tsx:71— SettingsField.renderFieldControl has cognitive complexity 28 (threshold 15). Drivers by points: ternaries 6 (13 pts), boolean chains 9, if/else 5 (6 pts) (nesting depth added 8). Of this number, 18 points are the body's own statements and 10 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
analysis._build_task_analysis_result (cognitive 27) api/v1/endpoints/analysis.py:1067— analysis._build_task_analysis_result has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 10, error handling 1 (3 pts), ternaries 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.
AskCommand._format_stock_result (cognitive 27) bot/commands/ask.py:510— AskCommand._format_stock_result has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (16 pts), ternaries 3 (5 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AkshareFetcher._get_hk_realtime_quote (cognitive 27) REDACTED:1621— AkshareFetcher._get_hk_realtime_quote has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (22 pts), error handling 2 (4 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DataFetcherManager._supplement_capital_flow_from_fetchers (cognitive 27) data_provider/base.py:4602— DataFetcherManager._supplement_capital_flow_from_fetchers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (19 pts), boolean chains 6, loops 1, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FutuFundamentalAdapter._financials (cognitive 27) data_provider/futu_fundamental_adapter.py:76— FutuFundamentalAdapter._financials has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 11, if/else 6 (11 pts), ternaries 3, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
YfinanceFetcher._get_us_index_realtime_quote (cognitive 27) REDACTED:688— YfinanceFetcher._get_us_index_realtime_quote has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 12, if/else 5 (6 pts), ternaries 5 (6 pts), error handling 3 (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.
llm_adapter.resolve_fallback_litellm_wire_models (cognitive 27) src/agent/llm_adapter.py:299— llm_adapter.resolve_fallback_litellm_wire_models has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 8, 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.
runner.try_parse_json (cognitive 27) src/agent/runner.py:175— runner.try_parse_json has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 4 (5 pts), error handling 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.
local_cli_backend._decode_diagnostic_double_quoted_field_name (cognitive 27) src/llm/local_cli_backend.py:673— local_cli_backend._decode_diagnostic_double_quoted_field_name has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 2 (4 pts), boolean chains 3, error handling 1 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarketAnalyzer._resolve_recorded_provider (cognitive 27) src/market_analyzer.py:196— MarketAnalyzer._resolve_recorded_provider has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 12 (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.
daily._latest_daily_bar_date (cognitive 27) src/services/screening/daily.py:484— daily._latest_daily_bar_date has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (21 pts), boolean chains 3, loops 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pipeline._daily_source_health_notes (cognitive 27) src/services/screening/pipeline.py:703— pipeline._daily_source_health_notes has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 6, ternaries 2 (4 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.
SkillOpinionWeightService.compute_weights (cognitive 27) src/services/skill_opinion_weight_service.py:48— SkillOpinionWeightService.compute_weights has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 4, loops 2, error handling 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.
StockTrendAnalyzer._generate_signal (cognitive 27) src/stock_analyzer.py:585— StockTrendAnalyzer._generate_signal has cognitive complexity 27 (threshold 15). Drivers by points: if/else 17 (18 pts), boolean chains 8, ternaries 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.
RunFlowPanel.RunFlowPanel (cognitive 27) apps/dsa-web/src/components/run-flow/RunFlowPanel.tsx:19— RunFlowPanel.RunFlowPanel has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 15, if/else 10, ternaries 2. Of this number, 15 points are the body's own statements and 12 belong to 8 function items inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
AlertRuleList.AlertRuleList (cognitive 27) apps/dsa-web/src/components/alerts/AlertRuleList.tsx:110— AlertRuleList.AlertRuleList has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 12 (23 pts), boolean chains 3, if/else 1 (nesting depth added 11). Most of this is not in the body itself: 4 of the 27 points are its own statements and the rest belongs to 3 function items inside it that branch (a function literal at line 187, isRuleActionBusy, a function literal at line 274). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
DataCenterPage.DataCenterPage (cognitive 27) apps/dsa-web/src/pages/DataCenterPage.tsx:52— DataCenterPage.DataCenterPage has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 9 (15 pts), boolean chains 7, if/else 3 (4 pts), error handling 1 (nesting depth added 7). Most of this is not in the body itself: 12 of the 27 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 63, 142, 177, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
MarketStructureCard.MarketStructureCard (cognitive 27) apps/dsa-web/src/components/report/MarketStructureCard.tsx:173— MarketStructureCard.MarketStructureCard has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 21, if/else 3, ternaries 2 (3 pts) (nesting depth added 1). Of this number, 26 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, 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.
FeishuStreamHandler._parse_event_message (cognitive 26) bot/platforms/feishu_stream.py:432— FeishuStreamHandler._parse_event_message has cognitive complexity 26 (threshold 15). Drivers by points: boolean chains 10, if/else 8, ternaries 5, error handling 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.
DataFetcherManager.get_board_context (cognitive 26) data_provider/base.py:4797— DataFetcherManager.get_board_context has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 5 (10 pts), boolean chains 9, if/else 5 (7 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.
TickFlowFetcher.get_market_stats (cognitive 26) data_provider/tickflow_fetcher.py:1055— TickFlowFetcher.get_market_stats has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (21 pts), boolean chains 3, error handling 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.
web_intent_resolver._split_sub_messages (cognitive 26) src/agent/web_intent_resolver.py:326— web_intent_resolver._split_sub_messages has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (12 pts), ternaries 4 (8 pts), boolean chains 5, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GeminiAnalyzer._init_litellm (cognitive 26) src/analyzer.py:2782— GeminiAnalyzer._init_litellm has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (19 pts), error handling 3 (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.
industry.load_board_heat_trends (cognitive 26) src/services/screening/industry.py:636— industry.load_board_heat_trends has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 3, error handling 1 (2 pts), loops 2, ternaries 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.
AnalysisTaskQueue.submit_tasks_batch (cognitive 26) src/services/task_queue.py:437— AnalysisTaskQueue.submit_tasks_batch has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 3 (6 pts), boolean chains 4, loops 4, error handling 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
share_image._compact_position (cognitive 26) src/share_image.py:629— share_image._compact_position has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), ternaries 3 (8 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.
share_image._market_body (cognitive 26) src/share_image.py:1863— share_image._market_body has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 12, boolean chains 6, if/else 4 (6 pts), loops 1 (2 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.
agent.decodeChatState (cognitive 26) apps/dsa-web/src/api/agent.ts:60— agent.decodeChatState has cognitive complexity 26 (threshold 15). Drivers by points: boolean chains 12, if/else 10 (11 pts), ternaries 2 (3 pts) (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.
agentChatStore.useAgentChatStore.startStream::processLine (cognitive 26) apps/dsa-web/src/stores/agentChatStore.ts:414— agentChatStore.useAgentChatStore.startStream::processLine has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 8 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (agentChatStore.useAgentChatStore.startStream) 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.
LLMChannelEditor.LLMChannelEditor::handleSave (cognitive 26) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:2024— LLMChannelEditor.LLMChannelEditor::handleSave has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 7, ternaries 2, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (LLMChannelEditor.LLMChannelEditor) 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.
portfolio._resolve_position_analysis_context (cognitive 25) api/v1/endpoints/portfolio.py:495— portfolio._resolve_position_analysis_context has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 6, error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StrategiesCommand.execute (cognitive 25) bot/commands/strategies.py:42— StrategiesCommand.execute has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 4, loops 3 (4 pts), ternaries 1 (3 pts), error handling 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.
EfinanceFetcher.get_realtime_quote (cognitive 25) data_provider/efinance_fetcher.py:624— EfinanceFetcher.get_realtime_quote has cognitive complexity 25 (threshold 15). Drivers by points: ternaries 16, if/else 6, error handling 2, 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.
TickFlowFetcher.prefetch_daily_klines (cognitive 25) data_provider/tickflow_fetcher.py:574— TickFlowFetcher.prefetch_daily_klines has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (15 pts), error handling 3 (6 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.
metrics.compute_trajectory_metrics (cognitive 25) evals/agent_trajectory/metrics.py:236— metrics.compute_trajectory_metrics has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (18 pts), boolean chains 5, loops 1, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
chat_context.build_agent_chat_context_bundle (cognitive 25) src/agent/chat_context.py:141— chat_context.build_agent_chat_context_bundle has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 7, loops 2, ternaries 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.
AgentOrchestrator._build_context (cognitive 25) src/agent/orchestrator.py:1251— AgentOrchestrator._build_context has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 7, 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.
web_intent_tokenizer._identify_one_code (cognitive 25) src/agent/web_intent_tokenizer.py:723— web_intent_tokenizer._identify_one_code has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (16 pts), ternaries 4 (5 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.
market_review._render_market_review_payload_body (cognitive 25) src/core/market_review.py:539— market_review._render_market_review_payload_body has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (5 pts), boolean chains 4 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockAnalysisPipeline._backfill_agent_dashboard_fields (cognitive 25) src/core/pipeline.py:2537— StockAnalysisPipeline._backfill_agent_dashboard_fields has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (17 pts), ternaries 2 (4 pts), boolean chains 3, 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.
stock_index_loader._load_active_index_rows (cognitive 25) src/data/stock_index_loader.py:406— stock_index_loader._load_active_index_rows has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), error handling 2 (4 pts), boolean chains 2, 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.
name_to_code_resolver._fix_name (cognitive 25) src/services/name_to_code_resolver.py:535— name_to_code_resolver._fix_name has cognitive complexity 25 (threshold 15). Drivers by points: if/else 16 (23 pts), error handling 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.
run_diagnostics._llm_component (cognitive 25) src/services/run_diagnostics.py:1279— run_diagnostics._llm_component has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 4, ternaries 1 (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.
hotspot._coerce_hotspot_summary (cognitive 25) src/services/screening/hotspot.py:1013— hotspot._coerce_hotspot_summary has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11, boolean chains 7, ternaries 7. 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.
StockProfileService._intelligence_block (cognitive 25) src/services/stock_profile_service.py:173— StockProfileService._intelligence_block has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (6 pts), error handling 1 (3 pts), ternaries 3, 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.
SystemConfigService._build_explainability_warnings (cognitive 25) src/services/system_config_service.py:2152— SystemConfigService._build_explainability_warnings has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 9, error handling 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.
SystemConfigService._infer_setup_legacy_primary_model (cognitive 25) src/services/system_config_service.py:3543— SystemConfigService._infer_setup_legacy_primary_model has cognitive complexity 25 (threshold 15). Drivers by points: ternaries 6 (12 pts), boolean chains 7, if/else 6 (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.
SystemConfigService._collect_hermes_channel_models_from_map (cognitive 25) src/services/system_config_service.py:4922— SystemConfigService._collect_hermes_channel_models_from_map has cognitive complexity 25 (threshold 15). Drivers by points: boolean chains 12, if/else 5 (10 pts), loops 2 (3 pts) (nesting depth added 6). 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.
stockPoolStore.fetchHistory (cognitive 25) apps/dsa-web/src/stores/stockPoolStore.ts:456— stockPoolStore.fetchHistory has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (16 pts), ternaries 3 (5 pts), boolean chains 3, error handling 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
decisionAction.getLegacyDecisionAction (cognitive 25) apps/dsa-web/src/utils/decisionAction.ts:94— decisionAction.getLegacyDecisionAction has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15, boolean chains 10. 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.
ReportOverview.ReportOverview (cognitive 25) apps/dsa-web/src/components/report/ReportOverview.tsx:165— ReportOverview.ReportOverview has cognitive complexity 25 (threshold 15). Drivers by points: boolean chains 13, if/else 6, ternaries 6. Of this number, 14 points are the body's own statements and 11 belong to 5 function items inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
EfinanceFetcher._get_etf_realtime_quote (cognitive 24) data_provider/efinance_fetcher.py:830— EfinanceFetcher._get_etf_realtime_quote has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 12, if/else 7 (8 pts), boolean chains 3, error handling 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.
AgentOrchestrator._build_data_perspective (cognitive 24) src/agent/orchestrator.py:1760— AgentOrchestrator._build_data_perspective has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 11, ternaries 5 (8 pts), if/else 4 (5 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WebIntentResolver.resolve (cognitive 24) src/agent/web_intent_resolver.py:1953— WebIntentResolver.resolve has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 6 (9 pts), boolean chains 8, if/else 4 (6 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
portfolio._discover_real_accounts (cognitive 24) src/brokers/futu/portfolio.py:165— portfolio._discover_real_accounts has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (17 pts), error handling 3 (4 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Config._legacy_keys_to_model_list (cognitive 24) src/config.py:2799— Config._legacy_keys_to_model_list has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 6, loops 4 (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.
market_review_lock.try_acquire_market_review_lock (cognitive 24) src/core/market_review_lock.py:144— market_review_lock.try_acquire_market_review_lock has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (12 pts), error handling 3 (9 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockAnalysisPipeline._get_concept_rankings_for_market (cognitive 24) src/core/pipeline.py:1302— StockAnalysisPipeline._get_concept_rankings_for_market has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (20 pts), error handling 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.
local_cli_backend._redact_double_quoted_yaml_sensitive_field (cognitive 24) src/llm/local_cli_backend.py:941— local_cli_backend._redact_double_quoted_yaml_sensitive_field has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 5, loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NotificationService.detect_configured_channels (cognitive 24) src/notification.py:495— NotificationService.detect_configured_channels has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14, boolean chains 10. 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.
notification_noise._evaluate_notification_noise (cognitive 24) src/notification_noise.py:246— notification_noise._evaluate_notification_noise has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 13, if/else 9 (10 pts), ternaries 1 (nesting depth added 1). 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.
decision_action.normalize_decision_action (cognitive 24) src/schemas/decision_action.py:306— decision_action.normalize_decision_action has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (18 pts), loops 3, ternaries 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.
SearXNGSearchProvider._do_search (cognitive 24) src/search_service.py:2034— SearXNGSearchProvider._do_search has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (13 pts), error handling 5 (7 pts), ternaries 2, 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.
SearchService.search_topic_news (cognitive 24) src/search_service.py:3866— SearchService.search_topic_news has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 8, ternaries 3, error handling 1 (2 pts), 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.
IntelligenceService._fetch_feed_entries (cognitive 24) REDACTED:442— IntelligenceService._fetch_feed_entries has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2 (3 pts), boolean chains 2, error handling 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.
market_light_service.load_previous_snapshot (cognitive 24) src/services/market_light_service.py:48— market_light_service.load_previous_snapshot has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 6, error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
industry._merge_mapping (cognitive 24) src/services/screening/industry.py:601— industry._merge_mapping has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (14 pts), ternaries 1 (4 pts), boolean chains 3, 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.
ranker._call_llm (cognitive 24) src/services/screening/ranker.py:564— ranker._call_llm has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 3, error handling 1 (3 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.
ranker._parse_ranking_response_detail (cognitive 24) src/services/screening/ranker.py:746— ranker._parse_ranking_response_detail has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (21 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.
SystemConfigService._mask_notification_target (cognitive 24) src/services/system_config_service.py:3176— SystemConfigService._mask_notification_target has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 6, ternaries 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.
SystemConfigService._validate_cross_field (cognitive 24) src/services/system_config_service.py:4504— SystemConfigService._validate_cross_field has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 18, if/else 5, error handling 1. 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.
share_image.build_share_image_html (cognitive 24) src/share_image.py:2045— share_image.build_share_image_html has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 7 (12 pts), if/else 5 (7 pts), boolean chains 5 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockTrendAnalyzer._analyze_trend (cognitive 24) src/stock_analyzer.py:341— StockTrendAnalyzer._analyze_trend has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 6 (12 pts), if/else 6 (8 pts), boolean chains 4 (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.
DatabaseManager._ensure_llm_usage_telemetry_columns (cognitive 24) REDACTED:2188— DatabaseManager._ensure_llm_usage_telemetry_columns has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (16 pts), error handling 2 (4 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.
stockPoolStore.consumeCompletedTaskSelection (cognitive 24) apps/dsa-web/src/stores/stockPoolStore.ts:280— stockPoolStore.consumeCompletedTaskSelection has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 3, loops 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 8). Of this number, 21 points are the body's own statements and 3 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarketReviewRegionSelector.MarketReviewRegionSelector (cognitive 24) apps/dsa-web/src/components/market-review/MarketReviewRegionSelector.tsx:17— MarketReviewRegionSelector.MarketReviewRegionSelector has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (11 pts), ternaries 6 (9 pts), boolean chains 4 (nesting depth added 5). Of this number, 12 points are the body's own statements and 12 belong to 6 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StatusCommand._collect_status (cognitive 23) bot/commands/status.py:59— StatusCommand._collect_status has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 21, if/else 1, ternaries 1. 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.
CommandDispatcher._try_nl_routing (cognitive 23) bot/dispatcher.py:457— CommandDispatcher._try_nl_routing has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 5 (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. This shape REPEATS in the file: one other method here (CommandDispatcher._try_nl_routing_sync) 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.
CommandDispatcher._try_nl_routing_sync (cognitive 23) bot/dispatcher.py:541— CommandDispatcher._try_nl_routing_sync has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 5 (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. This shape REPEATS in the file: one other method here (CommandDispatcher._try_nl_routing) 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.
pytdx_fetcher._parse_hosts_from_env (cognitive 23) data_provider/pytdx_fetcher.py:48— pytdx_fetcher._parse_hosts_from_env has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (12 pts), error handling 2 (7 pts), boolean chains 2, loops 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.
metrics._compute_tool_log_metrics (cognitive 23) evals/agent_trajectory/metrics.py:177— metrics._compute_tool_log_metrics has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 3, error handling 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generate_index_from_csv.load_tushare_data (cognitive 23) scripts/generate_index_from_csv.py:91— generate_index_from_csv.load_tushare_data has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 2 (3 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CodexAppServerTransport.run_turn (cognitive 23) src/agent/codex_app_server_transport.py:478— CodexAppServerTransport.run_turn has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 6, ternaries 3 (5 pts), error handling 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.
CodexAppServerTransport.inspect_external_tool_isolation (cognitive 23) src/agent/codex_app_server_transport.py:596— CodexAppServerTransport.inspect_external_tool_isolation has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 9, 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.
events._read_quote_float (cognitive 23) src/agent/events.py:74— events._read_quote_float has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (16 pts), error handling 2 (5 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.
AgentExecutor._build_user_message (cognitive 23) src/agent/executor.py:892— AgentExecutor._build_user_message has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (22 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.
LLMToolAdapter._call_litellm_model (cognitive 23) src/agent/llm_adapter.py:678— LLMToolAdapter._call_litellm_model has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 10, ternaries 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.
registry._infer_parameters (cognitive 23) src/agent/tools/registry.py:398— registry._infer_parameters has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (5 pts), boolean chains 2, ternaries 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.
web_intent_resolver._narrow_group_entities (cognitive 23) src/agent/web_intent_resolver.py:817— web_intent_resolver._narrow_group_entities has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 6, 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.
web_intent_tokenizer._build_entity_index (cognitive 23) src/agent/web_intent_tokenizer.py:164— web_intent_tokenizer._build_entity_index has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
analysis_context_pack_prompt._data_limitation_lines (cognitive 23) src/analysis_context_pack_prompt.py:288— analysis_context_pack_prompt._data_limitation_lines has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (18 pts), ternaries 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.
analyzer._sanitize_trend_analysis_for_prompt (cognitive 23) src/analyzer.py:811— analyzer._sanitize_trend_analysis_for_prompt has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 6 (14 pts), if/else 5 (8 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LocalCliGenerationBackend._terminate_process_group (cognitive 23) src/llm/local_cli_backend.py:2779— LocalCliGenerationBackend._terminate_process_group has cognitive complexity 23 (threshold 15). Drivers by points: error handling 9 (19 pts), if/else 3 (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.
MarketAnalyzer._merge_persisted_market_intelligence (cognitive 23) src/market_analyzer.py:2069— MarketAnalyzer._merge_persisted_market_intelligence has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 9, if/else 5 (9 pts), loops 2, ternaries 1 (2 pts), error handling 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.
NotificationService.generate_wechat_summary (cognitive 23) src/notification.py:1819— NotificationService.generate_wechat_summary has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 4 (10 pts), if/else 5 (9 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.
NotificationService._get_fundamental_blocks (cognitive 23) src/notification.py:2229— NotificationService._get_fundamental_blocks has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 17, if/else 4, boolean chains 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.
DingtalkSender.send_to_dingtalk (cognitive 23) src/notification_sender/dingtalk_sender.py:21— DingtalkSender.send_to_dingtalk has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 4, ternaries 2 (3 pts), error handling 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.
BochaSearchProvider._do_search (cognitive 23) src/search_service.py:1027— BochaSearchProvider._do_search has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 6 (7 pts), boolean chains 3, 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.
SearchService._stock_code_identity_terms (cognitive 23) src/search_service.py:2827— SearchService._stock_code_identity_terms has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 6, ternaries 2 (4 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MarketStructureService.build_context (cognitive 23) src/services/market_structure_service.py:51— MarketStructureService.build_context has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 11, if/else 11, ternaries 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.
candidate_context.collect_candidate_context (cognitive 23) src/services/screening/candidate_context.py:51— candidate_context.collect_candidate_context has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 4 (6 pts), boolean chains 4, error handling 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ranker._balanced_json_values (cognitive 23) src/services/screening/ranker.py:920— ranker._balanced_json_values has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (20 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.
ScreeningService.screen (cognitive 23) REDACTED:1212— ScreeningService.screen has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 16, error handling 4, if/else 2, ternaries 1. 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.
SkillOpinionSampleService.persist (cognitive 23) src/services/skill_opinion_sample_service.py:30— SkillOpinionSampleService.persist has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 6, error handling 2 (3 pts), loops 1, ternaries 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.
StockProfileService._monitor_block (cognitive 23) src/services/stock_profile_service.py:273— StockProfileService._monitor_block has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 3 (6 pts), boolean chains 3, error handling 1 (2 pts), ternaries 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.
SystemConfigService._classify_llm_exception (cognitive 23) src/services/system_config_service.py:4310— SystemConfigService._classify_llm_exception has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13, boolean chains 10. 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.
AnalysisTaskQueue._execute_task (cognitive 23) src/services/task_queue.py:758— AnalysisTaskQueue._execute_task has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 5, error handling 1, ternaries 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.
share_image._merge_index_cards (cognitive 23) src/share_image.py:458— share_image._merge_index_cards has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 5, ternaries 2 (4 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.
main.restorePackagedRuntimeStateFromBackup (cognitive 23) REDACTED:525— main.restorePackagedRuntimeStateFromBackup has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9, ternaries 4 (7 pts), boolean chains 4, error handling 2 (3 pts) (nesting depth added 4). Of this number, 18 points are the body's own statements and 5 belong to one function literal inside it that branches. To reduce it, split the body: 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.
topologyViewModel.buildRunFlowTopologyModel (cognitive 23) apps/dsa-web/src/components/run-flow/topologyViewModel.ts:218— topologyViewModel.buildRunFlowTopologyModel has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 14, if/else 7, ternaries 2. None of this is in the body itself: all 23 points belong to 5 function literals inside it that branch (lines 306, 329, 235, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
DataFetcherManager.prefetch_realtime_quotes (cognitive 22) data_provider/base.py:2198— DataFetcherManager.prefetch_realtime_quotes has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 3, error handling 2 (3 pts), loops 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
DataFetcherManager.get_capital_flow_context (cognitive 22) data_provider/base.py:4655— DataFetcherManager.get_capital_flow_context has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 10, if/else 8, ternaries 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.
MiaoxiangFetcher._query_tables (cognitive 22) data_provider/miaoxiang_fetcher.py:125— MiaoxiangFetcher._query_tables has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (13 pts), ternaries 2 (4 pts), boolean chains 2, loops 1 (2 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
run_eval.main (cognitive 22) evals/agent_trajectory/run_eval.py:181— run_eval.main has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (10 pts), ternaries 3 (6 pts), error handling 4 (5 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.
BaseAgent._build_memory_context (cognitive 22) src/agent/agents/base_agent.py:289— BaseAgent._build_memory_context has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentChatExecutor.execute_turn (cognitive 22) src/agent/chat_executor.py:142— AgentChatExecutor.execute_turn has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 5, ternaries 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.
factory._coerce_config_timeout (cognitive 22) src/agent/factory.py:220— factory._coerce_config_timeout has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (19 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
llm_adapter.register_fallback_model_pricing (cognitive 22) src/agent/llm_adapter.py:952— llm_adapter.register_fallback_model_pricing has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 2 (5 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.
analysis_tools._handle_get_volume_analysis (cognitive 22) src/agent/tools/analysis_tools.py:207— analysis_tools._handle_get_volume_analysis has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 9 (12 pts), if/else 6, boolean chains 3, error handling 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.
GeminiAnalyzer._extract_text_blocks (cognitive 22) src/analyzer.py:3329— GeminiAnalyzer._extract_text_blocks has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 4, loops 1, ternaries 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.
BacktestEngine._is_negated (cognitive 22) src/core/backtest_engine.py:545— BacktestEngine._is_negated has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stock_index_loader.get_chat_stock_lookup (cognitive 22) src/data/stock_index_loader.py:505— stock_index_loader.get_chat_stock_lookup has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (5 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
usage._infer_provider (cognitive 22) src/llm/usage.py:934— usage._infer_provider has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12, boolean chains 5, ternaries 2 (4 pts), error handling 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.
MarketAnalyzer.generate_market_review (cognitive 22) src/market_analyzer.py:779— MarketAnalyzer.generate_market_review has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 8 (10 pts), boolean chains 7, if/else 4, error handling 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.
MarketAnalyzer._build_stats_block (cognitive 22) src/market_analyzer.py:1196— MarketAnalyzer._build_stats_block has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 5, ternaries 4 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
report_language.get_sentiment_label (cognitive 22) src/report_language.py:1308— report_language.get_sentiment_label has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14 (22 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.
AnspireSearchProvider._do_search (cognitive 22) src/search_service.py:1223— AnspireSearchProvider._do_search has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (11 pts), error handling 6 (7 pts), boolean chains 3, 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.
daily_market_context.format_daily_market_context_prompt_section (cognitive 22) src/services/daily_market_context.py:635— daily_market_context.format_daily_market_context_prompt_section has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 5, ternaries 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.
DecisionSignalService._backfill_analysis_signal_from_history (cognitive 22) src/services/decision_signal_service.py:448— DecisionSignalService._backfill_analysis_signal_from_history has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 14, if/else 4, ternaries 3, error handling 1. 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.
IntelligenceService._validate_url (cognitive 22) REDACTED:392— IntelligenceService._validate_url has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 5, error handling 3 (4 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.
PortfolioImportService._normalize_trade_row (cognitive 22) src/services/portfolio_import_service.py:294— PortfolioImportService._normalize_trade_row has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 10, if/else 6 (8 pts), loops 2, ternaries 2 (nesting depth added 2). 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.
daily._read_daily_history_cache (cognitive 22) src/services/screening/daily.py:553— daily._read_daily_history_cache has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 5, error handling 3, loops 1 (2 pts), ternaries 1 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
industry.enrich_industry_concepts (cognitive 22) src/services/screening/industry.py:55— industry.enrich_industry_concepts has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 3, loops 3 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
screening_service._channel_litellm_model_list (cognitive 22) REDACTED:3120— screening_service._channel_litellm_model_list has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 3 (6 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.
analysis.getSentimentLabel (cognitive 22) apps/dsa-web/src/types/analysis.ts:631— analysis.getSentimentLabel has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14 (22 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.
agentChatStore.mergeChatState (cognitive 22) apps/dsa-web/src/stores/agentChatStore.ts:178— agentChatStore.mergeChatState has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 8, ternaries 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GenerationBackendStatusPanel.GenerationBackendStatusPanel (cognitive 22) apps/dsa-web/src/components/settings/GenerationBackendStatusPanel.tsx:84— GenerationBackendStatusPanel.GenerationBackendStatusPanel has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 7 (10 pts), if/else 6 (8 pts), boolean chains 2, error handling 2 (nesting depth added 5). Most of this is not in the body itself: 10 of the 22 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 107, 141, 159). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
DecisionSignalDisplay.DecisionSignalDetails (cognitive 22) apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx:331— DecisionSignalDisplay.DecisionSignalDetails has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 13 (19 pts), boolean chains 3 (nesting depth added 6). Of this number, 16 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DiscordPlatform._append_option_parts (cognitive 21) bot/platforms/discord.py:336— DiscordPlatform._append_option_parts has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (20 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.
DataFetcherManager._get_cn_index_realtime_quote (cognitive 21) data_provider/base.py:1170— DataFetcherManager._get_cn_index_realtime_quote has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 4, error handling 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AkshareFundamentalAdapter.get_dragon_tiger_flag (cognitive 21) data_provider/fundamental_adapter.py:566— AkshareFundamentalAdapter.get_dragon_tiger_flag has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (8 pts), error handling 2 (5 pts), ternaries 4 (5 pts), loops 2 (3 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.
YfinanceFetcher._convert_stock_code (cognitive 21) REDACTED:97— YfinanceFetcher._convert_stock_code has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 5, ternaries 1 (2 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.
BaseAgent._build_messages (cognitive 21) src/agent/agents/base_agent.py:181— BaseAgent._build_messages has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 4, loops 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.
llm_adapter._extract_provider_blocks (cognitive 21) src/agent/llm_adapter.py:213— llm_adapter._extract_provider_blocks has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 4 (6 pts), boolean chains 4 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StrategyEngine.partition_only (cognitive 21) src/agent/skills/engine.py:60— StrategyEngine.partition_only has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 3 (7 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stock_scope.extract_stock_code_spans (cognitive 21) src/agent/stock_scope.py:238— stock_scope.extract_stock_code_spans has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 11, if/else 4 (7 pts), loops 2 (3 pts) (nesting depth added 4). 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.
ToolRegistry.validate_tool_policies (cognitive 21) src/agent/tools/registry.py:250— ToolRegistry.validate_tool_policies has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
provider_cache._model_list_api_surface (cognitive 21) src/llm/provider_cache.py:731— provider_cache._model_list_api_surface has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 7, 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.
MarketAnalyzer.build_market_review_payload (cognitive 21) src/market_analyzer.py:991— MarketAnalyzer.build_market_review_payload has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 10, if/else 8 (10 pts), ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
NotificationService._append_related_boards (cognitive 21) src/notification.py:2453— NotificationService._append_related_boards has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 4, loops 2 (3 pts), ternaries 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PushoverSender._send_pushover_chunked (cognitive 21) src/notification_sender/pushover_sender.py:157— PushoverSender._send_pushover_chunked has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 2, ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
IntelligenceRepository.upsert_items (cognitive 21) src/repositories/intelligence_repo.py:108— IntelligenceRepository.upsert_items has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 11, if/else 4 (7 pts), error handling 1 (2 pts), loops 1 (nesting depth added 4). 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.
SearchService.__init__ (cognitive 21) src/search_service.py:2404— SearchService.__init__ has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 9 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
agent_chat_session_service._active_from_snapshot (cognitive 21) src/services/agent_chat_session_service.py:50— agent_chat_session_service._active_from_snapshot has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 6, ternaries 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.
DataCapabilityService._dataset_from_priority (cognitive 21) src/services/data_capability_service.py:936— DataCapabilityService._dataset_from_priority has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 3 (5 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.
decision_profile_policy._apply_guardrail (cognitive 21) src/services/decision_profile_policy.py:129— decision_profile_policy._apply_guardrail has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 5, ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
name_to_code_resolver.resolve_name_to_code (cognitive 21) src/services/name_to_code_resolver.py:737— name_to_code_resolver.resolve_name_to_code has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 3, error handling 2, 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.
run_diagnostics.sanitize_diagnostic_metadata (cognitive 21) src/services/run_diagnostics.py:112— run_diagnostics.sanitize_diagnostic_metadata has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (19 pts), 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.
run_flow._append_provider_runs (cognitive 21) src/services/run_flow.py:371— run_flow._append_provider_runs has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 4 (9 pts), if/else 4 (7 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.
run_flow._append_llm_runs (cognitive 21) src/services/run_flow.py:536— run_flow._append_llm_runs has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 4 (9 pts), if/else 3 (6 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.
ScreeningService.hotspot_detail (cognitive 21) REDACTED:1112— ScreeningService.hotspot_detail has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (15 pts), error handling 3 (4 pts), boolean chains 1, ternaries 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.
DsaEastMoneyHotspotProvider.hotspot_rows (cognitive 21) REDACTED:2252— DsaEastMoneyHotspotProvider.hotspot_rows has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 9, if/else 5 (9 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
screening_service._build_hotspot_event_routes_from_search (cognitive 21) REDACTED:346— screening_service._build_hotspot_event_routes_from_search has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 6, ternaries 2, error handling 1, 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.
stock_daily_start_resolver.resolve_stock_daily_start (cognitive 21) src/services/stock_daily_start_resolver.py:37— stock_daily_start_resolver.resolve_stock_daily_start has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (13 pts), ternaries 4 (5 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.
StockProfileService._code_aliases (cognitive 21) src/services/stock_profile_service.py:323— StockProfileService._code_aliases has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 9, loops 1, ternaries 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.
share_image._stock_body (cognitive 21) src/share_image.py:1817— share_image._stock_body has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 13, if/else 5 (6 pts), boolean chains 1, 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.
data_processing._normalize_sector_ranking_items (cognitive 21) src/utils/data_processing.py:106— data_processing._normalize_sector_ranking_items 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.
main.installDownloadedUpdate (cognitive 21) REDACTED:1585— main.installDownloadedUpdate has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (7 pts), ternaries 2 (6 pts), boolean chains 4, error handling 2 (3 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.
ReportMarkdownPanel.ReportMarkdownPanel (cognitive 21) apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx:19— ReportMarkdownPanel.ReportMarkdownPanel has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 5 (8 pts), if/else 5 (6 pts), boolean chains 4, error handling 3 (nesting depth added 4). Most of this is not in the body itself: 9 of the 21 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 59, 33, 44). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
useRunFlowSnapshot.useRunFlowSnapshot (cognitive 21) apps/dsa-web/src/hooks/useRunFlowSnapshot.ts:423— useRunFlowSnapshot.useRunFlowSnapshot has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8, ternaries 6 (7 pts), boolean chains 6 (nesting depth added 1). Most of this is not in the body itself: 8 of the 21 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 484, 496, 456, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
AkshareFetcher._get_stock_realtime_quote_tencent (cognitive 20) REDACTED:1369— AkshareFetcher._get_stock_realtime_quote_tencent has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 11, boolean chains 4, if/else 4, error handling 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.
DataFetcherManager._get_cn_index_daily_data (cognitive 20) data_provider/base.py:970— DataFetcherManager._get_cn_index_daily_data has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 4, error handling 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
longbridge_fetcher._sanitize_longbridge_env (cognitive 20) REDACTED:82— longbridge_fetcher._sanitize_longbridge_env has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 5, loops 2 (3 pts), error handling 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.
PytdxFetcher._get_market_code (cognitive 20) data_provider/pytdx_fetcher.py:240— PytdxFetcher._get_market_code has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 5 (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.
TickFlowFetcher._iter_batch_frames (cognitive 20) data_provider/tickflow_fetcher.py:697— TickFlowFetcher._iter_batch_frames has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 4 (8 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.
main._prime_daily_market_context (cognitive 20) main.py:638— main._prime_daily_market_context has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (9 pts), ternaries 3 (6 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.start_bot_stream_clients (cognitive 20) main.py:1403— main.start_bot_stream_clients has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (16 pts), error handling 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generate_index_from_csv.main (cognitive 20) scripts/generate_index_from_csv.py:973— generate_index_from_csv.main has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 3 (5 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, 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.
CodexAgentBackend.run (cognitive 20) src/agent/codex_agent_backend.py:75— CodexAgentBackend.run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11, ternaries 3 (4 pts), boolean chains 3, error handling 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.
CodexAppServerTransport.request (cognitive 20) src/agent/codex_app_server_transport.py:318— CodexAppServerTransport.request has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (13 pts), error handling 2 (3 pts), boolean chains 2, loops 1, ternaries 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.
codex_tool_process._context_from_payload (cognitive 20) src/agent/codex_tool_process.py:149— codex_tool_process._context_from_payload has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 6, error handling 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.
LLMToolAdapter._parse_litellm_response (cognitive 20) src/agent/llm_adapter.py:867— LLMToolAdapter._parse_litellm_response has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (11 pts), error handling 1 (4 pts), boolean chains 2, loops 1 (2 pts), ternaries 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.
stock_scope.extract_stock_codes (cognitive 20) src/agent/stock_scope.py:194— stock_scope.extract_stock_codes has cognitive complexity 20 (threshold 15). Drivers by points: loops 4 (7 pts), if/else 4 (6 pts), error handling 1 (3 pts), ternaries 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.
execution._resolve_tool_stock_access (cognitive 20) src/agent/tools/execution.py:364— execution._resolve_tool_stock_access has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (13 pts), error handling 2 (4 pts), boolean chains 3 (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.
GeminiAnalyzer._resolve_configured_response_provider (cognitive 20) src/analyzer.py:3146— GeminiAnalyzer._resolve_configured_response_provider has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 8, 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.
BacktestEngine._evaluate_targets (cognitive 20) src/core/backtest_engine.py:688— BacktestEngine._evaluate_targets has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 5, ternaries 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.
trading_calendar.infer_market_phase (cognitive 20) src/core/trading_calendar.py:375— trading_calendar.infer_market_phase has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13 (16 pts), boolean chains 3, error handling 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.
local_cli_backend._find_diagnostic_flow_scalar_end (cognitive 20) src/llm/local_cli_backend.py:1574— local_cli_backend._find_diagnostic_flow_scalar_end has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 3, 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.
MarketAnalyzer._resolve_configured_response_provider (cognitive 20) src/market_analyzer.py:162— MarketAnalyzer._resolve_configured_response_provider has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 8, 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.
SearchService._has_low_quality_news_page_signal (cognitive 20) src/search_service.py:3030— SearchService._has_low_quality_news_page_signal has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 20. 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.
SearchService._filter_news_response (cognitive 20) src/search_service.py:3687— SearchService._filter_news_response has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (17 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.
agent_model_service._build_legacy_deployments (cognitive 20) src/services/agent_model_service.py:69— agent_model_service._build_legacy_deployments has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (4 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
decision_signal_extractor.build_decision_signal_payload_from_report (cognitive 20) src/services/decision_signal_extractor.py:43— decision_signal_extractor.build_decision_signal_payload_from_report has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (14 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.
DecisionSignalService._normalize_payload (cognitive 20) src/services/decision_signal_service.py:786— DecisionSignalService._normalize_payload has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (13 pts), boolean chains 7 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
GenerationBackendStatusService._litellm_route_error (cognitive 20) src/services/generation_backend_status_service.py:538— GenerationBackendStatusService._litellm_route_error has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 6, loops 2 (3 pts), ternaries 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.
image_stock_extractor._parse_codes_from_text (cognitive 20) src/services/image_stock_extractor.py:112— image_stock_extractor._parse_codes_from_text has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (4 pts), boolean chains 2, error handling 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.
MarketHotspotService.get_hotspots (cognitive 20) src/services/market_hotspot_service.py:76— MarketHotspotService.get_hotspots has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 9, error handling 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.
MarketStructureService._infer_stock_role (cognitive 20) src/services/market_structure_service.py:437— MarketStructureService._infer_stock_role has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), ternaries 4 (7 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.
context.summarize_candidate_identity (cognitive 20) src/services/screening/context.py:258— context.summarize_candidate_identity has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 4, ternaries 2 (3 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.
daily._compute_daily_quality (cognitive 20) src/services/screening/daily.py:1062— daily._compute_daily_quality has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (18 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.
hotspot.load_hotspot_timeline (cognitive 20) src/services/screening/hotspot.py:681— hotspot.load_hotspot_timeline has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 8, error handling 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
screening_service._resolve_screening_llm_models (cognitive 20) REDACTED:3207— screening_service._resolve_screening_llm_models has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 7, loops 2, ternaries 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.
stock_index_remote_service.validate_stock_index_payload (cognitive 20) src/services/stock_index_remote_service.py:91— stock_index_remote_service.validate_stock_index_payload has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.configureElectronAutoUpdater (cognitive 20) REDACTED:1684— main.configureElectronAutoUpdater has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 11, ternaries 4 (5 pts), if/else 3 (4 pts) (nesting depth added 2). Most of this is not in the body itself: 6 of the 20 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 1726, 1744, 1758, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
StockBar.StockBar (cognitive 20) apps/dsa-web/src/components/history/StockBar.tsx:24— StockBar.StockBar has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 8, ternaries 4 (6 pts), if/else 5, loops 1 (nesting depth added 2). Of this number, 10 points are the body's own statements and 10 belong to 5 function literals inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
analysis._resolve_analysis_input (cognitive 19) api/v1/endpoints/analysis.py:259— analysis._resolve_analysis_input has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (17 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.
analysis._handle_async_analysis_batch (cognitive 19) api/v1/endpoints/analysis.py:453— analysis._handle_async_analysis_batch has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 8, if/else 7, ternaries 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.
DataFetcherManager._init_default_fetchers (cognitive 19) data_provider/base.py:1793— DataFetcherManager._init_default_fetchers has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15, boolean chains 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.
DataFetcherManager._fetch_offshore_fundamental_bundle (cognitive 19) data_provider/base.py:3767— DataFetcherManager._fetch_offshore_fundamental_bundle has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 4, error handling 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.
fetch_tushare_stock_list.fetch_rt_k_names (cognitive 19) scripts/fetch_tushare_stock_list.py:162— fetch_tushare_stock_list.fetch_rt_k_names has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 3, loops 2 (3 pts), error handling 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.
disagreement._classify_conflict_type (cognitive 19) src/agent/disagreement.py:167— disagreement._classify_conflict_type has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 5, ternaries 2 (4 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.
EventMonitor.check_all (cognitive 19) src/agent/events.py:218— EventMonitor.check_all has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (9 pts), error handling 2 (6 pts), loops 2 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
litellm_route_resolution.resolve_agent_litellm_route (cognitive 19) src/agent/litellm_route_resolution.py:51— litellm_route_resolution.resolve_agent_litellm_route has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 6, ternaries 1 (2 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentMemory.get_stock_history (cognitive 19) src/agent/memory.py:130— AgentMemory.get_stock_history has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 4, error handling 2 (4 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AgentOrchestrator._partition_skill_opinions (cognitive 19) src/agent/orchestrator.py:1025— AgentOrchestrator._partition_skill_opinions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (9 pts), ternaries 3 (7 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.
SkillRouter._detect_regime (cognitive 19) src/agent/skills/router.py:75— SkillRouter._detect_regime has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 5, error handling 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.
analysis_tools._handle_calculate_ma (cognitive 19) src/agent/tools/analysis_tools.py:115— analysis_tools._handle_calculate_ma has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (9 pts), ternaries 4 (6 pts), error handling 1 (2 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.
execution._normalize_tool_stock_code (cognitive 19) src/agent/tools/execution.py:202— execution._normalize_tool_stock_code has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 4, error handling 2 (3 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
analysis_context_pack_overview._sanitize_persisted_overview (cognitive 19) src/analysis_context_pack_overview.py:137— analysis_context_pack_overview._sanitize_persisted_overview has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 9, if/else 6 (8 pts), loops 1, ternaries 1 (nesting depth added 2). 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.
analysis_context_pack_prompt._block_lines (cognitive 19) src/analysis_context_pack_prompt.py:236— analysis_context_pack_prompt._block_lines has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 3 (8 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.
GeminiAnalyzer._get_hermes_config_error (cognitive 19) src/analyzer.py:2945— GeminiAnalyzer._get_hermes_config_error has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 9, if/else 4 (6 pts), error handling 1 (2 pts), loops 1, ternaries 1 (nesting depth added 3). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
GeminiAnalyzer.generate_text_with_metadata (cognitive 19) src/analyzer.py:3926— GeminiAnalyzer.generate_text_with_metadata has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 7, if/else 4 (7 pts), error handling 3, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
analyzer.get_stock_name_multi_source (cognitive 19) src/analyzer.py:1657— analyzer.get_stock_name_multi_source has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (13 pts), error handling 2 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockAnalysisPipeline._refresh_saved_diagnostic_snapshot (cognitive 19) src/core/pipeline.py:2964— StockAnalysisPipeline._refresh_saved_diagnostic_snapshot has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 5, error handling 2 (4 pts), loops 1, ternaries 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.
formatters._flush_table_as_key_value_rows (cognitive 19) src/formatters.py:508— formatters._flush_table_as_key_value_rows has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 3 (4 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
usage._provider_usage_json_has_count_signal (cognitive 19) src/llm/usage.py:243— usage._provider_usage_json_has_count_signal has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 3 (4 pts), error handling 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.
SerpAPISearchProvider._extract_rich_snippet_extensions (cognitive 19) src/search_service.py:825— SerpAPISearchProvider._extract_rich_snippet_extensions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (6 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.
SearchService._get_cached_or_wait_for_reservation (cognitive 19) src/search_service.py:2756— SearchService._get_cached_or_wait_for_reservation has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, ternaries 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AlertService._normalize_parameters (cognitive 19) src/services/alert_service.py:953— AlertService._normalize_parameters has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (11 pts), error handling 3 (6 pts), boolean chains 2 (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.
DailyMarketContextService._load_same_day_history (cognitive 19) src/services/daily_market_context.py:239— DailyMarketContextService._load_same_day_history has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 2 (4 pts), boolean chains 3, error handling 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.
daily_market_context._extract_full_market_report (cognitive 19) src/services/daily_market_context.py:743— daily_market_context._extract_full_market_report has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (14 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.
DecisionSignalOutcomeService.run_outcomes (cognitive 19) src/services/decision_signal_outcome_service.py:105— DecisionSignalOutcomeService.run_outcomes has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 4, loops 2 (3 pts), ternaries 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.
decision_signal_reassess_service._extract_guardrail_reason (cognitive 19) src/services/decision_signal_reassess_service.py:347— decision_signal_reassess_service._extract_guardrail_reason has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (3 pts), ternaries 3, 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.
DecisionSignalService._history_guardrail_reason (cognitive 19) src/services/decision_signal_service.py:574— DecisionSignalService._history_guardrail_reason has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (3 pts), ternaries 3, 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.
market_light_alerts.normalize_market_alert_parameters (cognitive 19) src/services/market_light_alerts.py:50— market_light_alerts.normalize_market_alert_parameters has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 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.
MarketStructureService._infer_primary_theme (cognitive 19) src/services/market_structure_service.py:376— MarketStructureService._infer_primary_theme has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 2, loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
dsa.extract_deep_analysis_summary (cognitive 19) src/services/screening/dsa.py:186— dsa.extract_deep_analysis_summary has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
industry._normalize_cached_mapping (cognitive 19) src/services/screening/industry.py:528— industry._normalize_cached_mapping has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (5 pts), ternaries 1 (4 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.
ranker._fit_candidate_prompt_lines (cognitive 19) src/services/screening/ranker.py:436— ranker._fit_candidate_prompt_lines has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 3 (6 pts), ternaries 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.
screening_service._normalize_screening_hotspot_detail (cognitive 19) REDACTED:1341— screening_service._normalize_screening_hotspot_detail has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 12, ternaries 7. 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.
SystemConfigService._has_legacy_key_for_provider (cognitive 19) src/services/system_config_service.py:5060— SystemConfigService._has_legacy_key_for_provider has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 15, if/else 4. 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.
storage.persist_llm_usage (cognitive 19) REDACTED:4652— storage.persist_llm_usage has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 7, ternaries 4 (5 pts), if/else 3, loops 2 (3 pts), error handling 1 (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.
main.compareVersions (cognitive 19) REDACTED:130— main.compareVersions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 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.
UiLanguageToggle.UiLanguageToggle (cognitive 19) apps/dsa-web/src/components/i18n/UiLanguageToggle.tsx:18— UiLanguageToggle.UiLanguageToggle has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 11 (18 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.
decisionAction.getDecisionActionTone (cognitive 19) apps/dsa-web/src/utils/decisionAction.ts:234— decisionAction.getDecisionActionTone has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (15 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.
TaskPanel.TaskPanel (cognitive 19) apps/dsa-web/src/components/tasks/TaskPanel.tsx:172— TaskPanel.TaskPanel has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 9 (13 pts), boolean chains 4, if/else 2 (nesting depth added 4). Of this number, 17 points are the body's own statements and 2 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
waitForHealth (cognitive 19) REDACTED:1013— waitForHealth has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15 (16 pts), boolean chains 2, error handling 1 (nesting depth added 1). None of this is in the body itself: all 19 points belong to 8 function items inside it that branch ((anonymous)::finish, (anonymous)::attempt, (anonymous)::emitProgress, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
AskCommand._extract_summary (cognitive 18) bot/commands/ask.py:440— AskCommand._extract_summary has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 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.
DataFetcherManager._get_cn_index_name (cognitive 18) data_provider/base.py:1402— DataFetcherManager._get_cn_index_name has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 3, error handling 1 (2 pts), loops 1, ternaries 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.
DataFetcherManager._get_tickflow_fetcher (cognitive 18) data_provider/base.py:1479— DataFetcherManager._get_tickflow_fetcher has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (7 pts), error handling 3 (6 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DataFetcherManager.close (cognitive 18) data_provider/base.py:1535— DataFetcherManager.close has cognitive complexity 18 (threshold 15). Drivers by points: error handling 3 (8 pts), if/else 5 (7 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.
AkshareFundamentalAdapter.get_capital_flow (cognitive 18) data_provider/fundamental_adapter.py:510— AkshareFundamentalAdapter.get_capital_flow has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 4, ternaries 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.
TushareFetcher._convert_stock_code (cognitive 18) data_provider/tushare_fetcher.py:373— TushareFetcher._convert_stock_code has cognitive complexity 18 (threshold 15). Drivers by points: if/else 13 (15 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.
YfinanceFetcher._normalize_data (cognitive 18) REDACTED:236— YfinanceFetcher._normalize_data has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (15 pts), ternaries 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.
YfinanceFetcher._get_us_stock_quote_from_stooq (cognitive 18) REDACTED:537— YfinanceFetcher._get_us_stock_quote_from_stooq has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7, boolean chains 4, ternaries 4, error handling 2, loops 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CodexAppServerTransport._read_stdout (cognitive 18) src/agent/codex_app_server_transport.py:697— CodexAppServerTransport._read_stdout has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 4, error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
factory._normalize_skill_ids (cognitive 18) src/agent/factory.py:112— factory._normalize_skill_ids has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (16 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.
LLMToolAdapter._init_litellm (cognitive 18) src/agent/llm_adapter.py:378— LLMToolAdapter._init_litellm has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 6, error handling 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.
AgentOrchestrator._collect_strategy_synthesis (cognitive 18) src/agent/orchestrator.py:1708— AgentOrchestrator._collect_strategy_synthesis has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, ternaries 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
risk_override.validate_risk_application_transition (cognitive 18) src/agent/risk_override.py:81— risk_override.validate_risk_application_transition has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 2, ternaries 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.
runner.parse_dashboard_json (cognitive 18) src/agent/runner.py:117— runner.parse_dashboard_json has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
deliberation._parse_deliberation_json (cognitive 18) src/agent/skills/deliberation.py:971— deliberation._parse_deliberation_json has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), error handling 1 (2 pts), loops 2, boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StrategySynthesizer._group_opinions (cognitive 18) src/agent/skills/synthesis.py:288— StrategySynthesizer._group_opinions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 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.
GeminiAnalyzer._get_analysis_system_prompt (cognitive 18) src/analyzer.py:2669— GeminiAnalyzer._get_analysis_system_prompt has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), ternaries 3 (7 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.
config.resolve_unified_llm_temperature (cognitive 18) src/config.py:810— config.resolve_unified_llm_temperature has cognitive complexity 18 (threshold 15). Drivers by points: error handling 3 (8 pts), if/else 4 (6 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockAnalysisPipeline.__init__ (cognitive 18) src/core/pipeline.py:236— StockAnalysisPipeline.__init__ has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7, boolean chains 4, ternaries 4, error handling 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.
local_cli_backend._extract_claude_code_json (cognitive 18) src/llm/local_cli_backend.py:1783— local_cli_backend._extract_claude_code_json has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 7, error handling 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.
NotificationService._send_via_source_context (cognitive 18) src/notification.py:739— NotificationService._send_via_source_context has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 3 (6 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.
CustomWebhookSender.send_to_custom (cognitive 18) src/notification_sender/custom_webhook_sender.py:41— CustomWebhookSender.send_to_custom has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 pts), error handling 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.
EmailSender.get_receivers_for_stocks (cognitive 18) src/notification_sender/email_sender.py:72— EmailSender.get_receivers_for_stocks has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 3 (7 pts), boolean chains 1, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TelegramSender._send_telegram_chunked (cognitive 18) src/notification_sender/telegram_sender.py:256— TelegramSender._send_telegram_chunked has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (14 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.
BacktestService._get_recent_evaluations_by_phase (cognitive 18) src/services/backtest_service.py:762— BacktestService._get_recent_evaluations_by_phase 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.
image_stock_extractor._get_api_keys_for_model (cognitive 18) src/services/image_stock_extractor.py:244— image_stock_extractor._get_api_keys_for_model has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 7, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
report_renderer.render (cognitive 18) src/services/report_renderer.py:93— report_renderer.render has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 3, loops 2 (3 pts), error handling 2 (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.
run_diagnostics.build_run_diagnostic_summary (cognitive 18) src/services/run_diagnostics.py:1412— run_diagnostics.build_run_diagnostic_summary has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 8 (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.
run_flow._append_context_blocks (cognitive 18) src/services/run_flow.py:474— run_flow._append_context_blocks has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 3 (6 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
run_flow._append_notification_runs (cognitive 18) src/services/run_flow.py:665— run_flow._append_notification_runs has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 5 (10 pts), if/else 3 (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.
config._parse_llm_channels_env (cognitive 18) src/services/screening/config.py:418— config._parse_llm_channels_env has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 4, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
daily._fetch_daily_tencent (cognitive 18) src/services/screening/daily.py:669— daily._fetch_daily_tencent has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (6 pts), ternaries 4 (6 pts), boolean chains 4, loops 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
hotspot.classify_hotspot_stage (cognitive 18) src/services/screening/hotspot.py:157— hotspot.classify_hotspot_stage has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 12, if/else 6. 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.
post_analysis._scorecard_delta (cognitive 18) src/services/screening/post_analysis.py:289— post_analysis._scorecard_delta has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 6, ternaries 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.
risk.assess_pick_risk (cognitive 18) src/services/screening/risk.py:141— risk.assess_pick_risk has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12, boolean chains 6. 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.
stock_index_remote_service.refresh_remote_stock_index_cache (cognitive 18) src/services/stock_index_remote_service.py:211— stock_index_remote_service.refresh_remote_stock_index_cache has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 3 (6 pts), error handling 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.
SystemConfigService._extract_llm_tool_call_names (cognitive 18) src/services/system_config_service.py:1990— SystemConfigService._extract_llm_tool_call_names has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 4 (6 pts), boolean chains 3, 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.
SystemConfigService._classify_llm_http_error (cognitive 18) src/services/system_config_service.py:4152— SystemConfigService._classify_llm_http_error has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10, boolean chains 8. 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.
data_processing._normalize_belong_boards (cognitive 18) src/utils/data_processing.py:54— data_processing._normalize_belong_boards 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.
data_processing._deep_merge_dicts (cognitive 18) src/utils/data_processing.py:177— data_processing._deep_merge_dicts has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (3 pts), boolean chains 1, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.parseQuotedEnvValue (cognitive 18) REDACTED:726— main.parseQuotedEnvValue has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (17 pts), loops 1 (nesting depth added 12). Most of this is not in the body itself: 6 of the 18 points are its own statements and the rest belongs to one function literal inside it that branches (line 732). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
HistoryList.HistoryList (cognitive 18) apps/dsa-web/src/components/history/HistoryList.tsx:32— HistoryList.HistoryList has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 9, if/else 4 (5 pts), ternaries 3 (4 pts) (nesting depth added 2). Of this number, 10 points are the body's own statements and 8 belong to 3 function literals inside it that branch. To reduce it, 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.
RunFlowEventList.RunFlowEventList (cognitive 18) apps/dsa-web/src/components/run-flow/RunFlowEventList.tsx:54— RunFlowEventList.RunFlowEventList has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 7 (10 pts), boolean chains 6, if/else 1 (2 pts) (nesting depth added 4). Most of this is not in the body itself: 1 of the 18 points is its own statement and the rest belongs to 5 function literals inside it that branch (lines 105, 62, 84, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
LoginPage.LoginPage (cognitive 18) REDACTED:15— LoginPage.LoginPage has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 9 (11 pts), boolean chains 4, if/else 3 (nesting depth added 2). Of this number, 13 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
TokenUsagePage.TokenUsagePage (cognitive 18) apps/dsa-web/src/pages/TokenUsagePage.tsx:102— TokenUsagePage.TokenUsagePage has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 8 (12 pts), if/else 3 (4 pts), boolean chains 1, error handling 1 (nesting depth added 5). Of this number, 9 points are the body's own statements and 9 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DataFetcherManager.get_chip_distribution (cognitive 17) data_provider/base.py:2947— DataFetcherManager.get_chip_distribution has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 1 (2 pts), loops 2, ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DataFetcherManager.get_main_indices (cognitive 17) data_provider/base.py:3318— DataFetcherManager.get_main_indices has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), error handling 2 (5 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.
DataFetcherManager.get_concept_rankings (cognitive 17) data_provider/base.py:4926— DataFetcherManager.get_concept_rankings has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 7, if/else 4 (5 pts), error handling 2 (3 pts), loops 1, ternaries 1 (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.
MiaoxiangFetcher._table_rows (cognitive 17) data_provider/miaoxiang_fetcher.py:190— MiaoxiangFetcher._table_rows has cognitive complexity 17 (threshold 15). Drivers by points: loops 5 (9 pts), boolean chains 3, ternaries 1 (3 pts), if/else 1 (2 pts) (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
metrics.validate_golden_sample (cognitive 17) evals/agent_trajectory/metrics.py:588— metrics.validate_golden_sample has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 5, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
main._compute_trading_day_filter (cognitive 17) main.py:478— main._compute_trading_day_filter has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 6, 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.
main.start_api_server (cognitive 17) main.py:1302— main.start_api_server has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), error handling 2, boolean chains 1, loops 1, ternaries 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.
smoke_bot_index_entry._terminate_process_tree (cognitive 17) scripts/smoke_bot_index_entry.py:103— smoke_bot_index_entry._terminate_process_tree has cognitive complexity 17 (threshold 15). Drivers by points: error handling 7 (12 pts), if/else 4 (5 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.
SkillAggregator.calculate (cognitive 17) src/agent/skills/aggregator.py:86— SkillAggregator.calculate has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (11 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.
web_intent_tokenizer._extract_markets_from_tokens (cognitive 17) src/agent/web_intent_tokenizer.py:93— web_intent_tokenizer._extract_markets_from_tokens has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (13 pts), boolean chains 3, 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.
GeminiAnalyzer._resolve_response_model_provider (cognitive 17) src/analyzer.py:3180— GeminiAnalyzer._resolve_response_model_provider has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 5 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
analyzer._capital_flow_bias_with_status (cognitive 17) src/analyzer.py:1322— analyzer._capital_flow_bias_with_status has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 5, ternaries 2, 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.
BacktestEngine._classify_outcome (cognitive 17) src/core/backtest_engine.py:603— BacktestEngine._classify_outcome has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (17 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.
hermes.canonicalize_hermes_base_url (cognitive 17) src/llm/hermes.py:159— hermes.canonicalize_hermes_base_url has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8, boolean chains 7, error handling 1, ternaries 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.
local_cli_backend._consume_diagnostic_scalar (cognitive 17) src/llm/local_cli_backend.py:1486— local_cli_backend._consume_diagnostic_scalar has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 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.
local_cli_backend._consume_shell_command_substitution (cognitive 17) src/llm/local_cli_backend.py:1542— local_cli_backend._consume_shell_command_substitution has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 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.
usage._sanitize_raw_usage (cognitive 17) src/llm/usage.py:894— usage._sanitize_raw_usage has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 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.
CustomWebhookSender._send_custom_webhook_image (cognitive 17) src/notification_sender/custom_webhook_sender.py:108— CustomWebhookSender._send_custom_webhook_image has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), error handling 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.
DiscordSender._post_discord_message (cognitive 17) src/notification_sender/discord_sender.py:204— DiscordSender._post_discord_message has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 3, error handling 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.
AlertService._normalize_rule_payload (cognitive 17) src/services/alert_service.py:871— AlertService._normalize_rule_payload has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 9, if/else 6, error handling 1 (2 pts) (nesting depth added 1). 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.
BacktestService._build_dynamic_summary (cognitive 17) src/services/backtest_service.py:1124— BacktestService._build_dynamic_summary has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 1, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
GenerationBackendStatusService.smoke_test (cognitive 17) src/services/generation_backend_status_service.py:264— GenerationBackendStatusService.smoke_test has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 7, if/else 2 (4 pts), ternaries 2 (4 pts), error handling 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.
HistoryService.get_history_list (cognitive 17) src/services/history_service.py:248— HistoryService.get_history_list has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 3 (5 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.
IntelligenceService._normalize_source_fields (cognitive 17) REDACTED:360— IntelligenceService._normalize_source_fields has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 10, if/else 6, ternaries 1. 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.
portfolio_alerts._portfolio_holding_symbols (cognitive 17) src/services/portfolio_alerts.py:350— portfolio_alerts._portfolio_holding_symbols has cognitive complexity 17 (threshold 15). Drivers by points: if/else 2 (6 pts), boolean chains 4, error handling 1 (3 pts), loops 2 (3 pts), ternaries 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.
PortfolioRiskService._ensure_drawdown_snapshot_window (cognitive 17) src/services/portfolio_risk_service.py:203— PortfolioRiskService._ensure_drawdown_snapshot_window has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 3 (6 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PortfolioService.record_trade (cognitive 17) src/services/portfolio_service.py:186— PortfolioService.record_trade has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 11, if/else 5, error handling 1. 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.
research_artifact_service._build_evidence (cognitive 17) src/services/research_artifact_service.py:96— research_artifact_service._build_evidence has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 8, if/else 4, ternaries 2 (4 pts), loops 1 (nesting depth added 2). 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.
run_flow._normalize_history_diagnostics_for_record (cognitive 17) src/services/run_flow.py:740— run_flow._normalize_history_diagnostics_for_record has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 3, ternaries 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.
context.summarize_event_profile (cognitive 17) src/services/screening/context.py:292— context.summarize_event_profile has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 1 (3 pts), loops 2 (3 pts), boolean chains 1, ternaries 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.
filter.validate_check_snapshot (cognitive 17) src/services/screening/filter.py:106— filter.validate_check_snapshot has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 4, error handling 1 (3 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.
hotspot.resolve_hotspot_topic (cognitive 17) src/services/screening/hotspot.py:189— hotspot.resolve_hotspot_topic has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 2 (4 pts), loops 1 (2 pts), ternaries 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.
pipeline._format_filter_waterfall (cognitive 17) src/services/screening/pipeline.py:746— pipeline._format_filter_waterfall has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ranker._coerce_completion_content (cognitive 17) src/services/screening/ranker.py:687— ranker._coerce_completion_content has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 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.
screening_service._summarize_screening_source_history (cognitive 17) REDACTED:1682— screening_service._summarize_screening_source_history has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), boolean chains 4, 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.
screening_service._normalize_dsa_daily_history (cognitive 17) REDACTED:3370— screening_service._normalize_dsa_daily_history has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 3, ternaries 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.
share_image._market_segments (cognitive 17) src/share_image.py:925— share_image._market_segments has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 2, ternaries 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.
share_image._parse_index_bullets (cognitive 17) src/share_image.py:1333— share_image._parse_index_bullets has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 2 (6 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DatabaseManager._backfill_decision_signal_profile_from_metadata (cognitive 17) REDACTED:1622— DatabaseManager._backfill_decision_signal_profile_from_metadata has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 2, error handling 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.
data_processing.normalize_signal_attribution_values (cognitive 17) src/utils/data_processing.py:353— data_processing.normalize_signal_attribution_values has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 4 (6 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tooltip.Tooltip (cognitive 17) apps/dsa-web/src/components/common/Tooltip.tsx:20— Tooltip.Tooltip has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7, ternaries 5 (6 pts), boolean chains 4 (nesting depth added 1). Most of this is not in the body itself: 7 of the 17 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 35, 71, 85, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
ChatPage.ChatPage::getCurrentStage (cognitive 17) apps/dsa-web/src/pages/ChatPage.tsx:677— ChatPage.ChatPage::getCurrentStage has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9, boolean chains 8. 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. This shape REPEATS in the file: one other method here (ChatPage.ChatPage) 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.
StockScreeningPage.formatScreenMessage (cognitive 17) apps/dsa-web/src/pages/StockScreeningPage.tsx:391— StockScreeningPage.formatScreenMessage has cognitive complexity 17 (threshold 15). Drivers by points: if/else 15 (16 pts), boolean chains 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ResearchCommand.execute (cognitive 16) bot/commands/research.py:53— ResearchCommand.execute has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 1, error handling 1, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
AkshareFetcher.get_main_indices (cognitive 16) REDACTED:1932— AkshareFetcher.get_main_indices has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 1 (2 pts), boolean chains 1, error handling 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.
AkshareFetcher._normalize_limit_time_value (cognitive 16) REDACTED:2431— AkshareFetcher._normalize_limit_time_value has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 3 (6 pts), if/else 4 (5 pts), error handling 3 (4 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BaostockFetcher.get_stock_name (cognitive 16) data_provider/baostock_fetcher.py:290— BaostockFetcher.get_stock_name has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 1 (3 pts), boolean chains 2, loops 1 (2 pts), error handling 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.
DataFetcherManager._dividend_contract_has_values (cognitive 16) data_provider/base.py:3621— DataFetcherManager._dividend_contract_has_values has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 2 (3 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.
TickFlowFetcher._extract_universe_entries (cognitive 16) data_provider/tickflow_fetcher.py:953— TickFlowFetcher._extract_universe_entries has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 4, ternaries 1 (3 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
check_env.view_database (cognitive 16) scripts/check_env.py:125— check_env.view_database has cognitive complexity 16 (threshold 15). Drivers by points: loops 3 (6 pts), if/else 5, ternaries 1 (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.
ResearchAgent.research (cognitive 16) src/agent/research.py:70— ResearchAgent.research has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 1, ternaries 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.
SkillManager.get_skill_instructions (cognitive 16) src/agent/skills/base.py:433— SkillManager.get_skill_instructions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 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.
analysis_context_pack_prompt._subject_lines (cognitive 16) src/analysis_context_pack_prompt.py:201— analysis_context_pack_prompt._subject_lines has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, ternaries 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.
analyzer._has_structural_risk_alert (cognitive 16) src/analyzer.py:1221— analyzer._has_structural_risk_alert has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), ternaries 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
config.get_api_keys_for_model (cognitive 16) src/config.py:3873— config.get_api_keys_for_model has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 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.
BacktestEngine.evaluate_decision_signal (cognitive 16) src/core/backtest_engine.py:276— BacktestEngine.evaluate_decision_signal has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), ternaries 3 (4 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.
ConfigManager._read_config_map (cognitive 16) src/core/config_manager.py:128— ConfigManager._read_config_map has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 2 (3 pts), ternaries 1 (2 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.
market_review._render_single_market_review_payload (cognitive 16) src/core/market_review.py:571— market_review._render_single_market_review_payload has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 5, ternaries 1 (2 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockAnalysisPipeline._attach_belong_boards_to_fundamental_context (cognitive 16) src/core/pipeline.py:1217— StockAnalysisPipeline._attach_belong_boards_to_fundamental_context has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7, boolean chains 5, ternaries 3, error handling 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.
StockAnalysisPipeline._is_agent_field_missing (cognitive 16) src/core/pipeline.py:2398— StockAnalysisPipeline._is_agent_field_missing has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 4 (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.
StockAnalysisPipeline._send_single_stock_notification (cognitive 16) src/core/pipeline.py:3627— StockAnalysisPipeline._send_single_stock_notification has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (10 pts), error handling 2 (3 pts), ternaries 2, 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.
trading_calendar.build_market_phase_context (cognitive 16) src/core/trading_calendar.py:551— trading_calendar.build_market_phase_context has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 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.
trading_calendar.compute_effective_region (cognitive 16) src/core/trading_calendar.py:640— trading_calendar.compute_effective_region has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 2, ternaries 1 (2 pts) (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.
local_cli_backend._iter_opencode_events (cognitive 16) src/llm/local_cli_backend.py:1939— local_cli_backend._iter_opencode_events has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (6 pts), loops 3 (6 pts), boolean chains 2, error handling 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.
MarketAnalyzer._split_report_sections (cognitive 16) src/market_analyzer.py:1082— MarketAnalyzer._split_report_sections has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 5 (6 pts), if/else 4 (5 pts), boolean chains 4, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
phase_decision_guardrail.apply_phase_decision_guardrails (cognitive 16) src/phase_decision_guardrail.py:116— phase_decision_guardrail.apply_phase_decision_guardrails has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 4, ternaries 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.
BacktestRepository.align_existing_result_dates (cognitive 16) src/repositories/backtest_repo.py:82— BacktestRepository.align_existing_result_dates has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BraveSearchProvider._do_search (cognitive 16) src/search_service.py:1647— BraveSearchProvider._do_search has cognitive complexity 16 (threshold 15). Drivers by points: error handling 5 (7 pts), if/else 6 (7 pts), boolean chains 1, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SearXNGSearchProvider._extract_public_instances (cognitive 16) src/search_service.py:1928— SearXNGSearchProvider._extract_public_instances has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 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.
SearchService._filter_ranked_news_for_context (cognitive 16) src/search_service.py:3428— SearchService._filter_ranked_news_for_context has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 6, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
analysis_context_builder._build_daily_bars_block (cognitive 16) src/services/analysis_context_builder.py:180— analysis_context_builder._build_daily_bars_block has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 3 (6 pts), if/else 5, boolean chains 4, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
etf_rotation_service.build_report (cognitive 16) src/services/etf_rotation_service.py:349— etf_rotation_service.build_report has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (7 pts), ternaries 5, boolean chains 3, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
GenerationBackendStatusService._infer_legacy_litellm_model (cognitive 16) src/services/generation_backend_status_service.py:805— GenerationBackendStatusService._infer_legacy_litellm_model has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 6, ternaries 3 (6 pts), if/else 4 (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.
PortfolioImportService.register_parser (cognitive 16) src/services/portfolio_import_service.py:103— PortfolioImportService.register_parser has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 5, 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.
run_diagnostics._notification_component (cognitive 16) src/services/run_diagnostics.py:1332— run_diagnostics._notification_component has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9, boolean chains 4, ternaries 2 (3 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.
context._allocate_section_budgets (cognitive 16) src/services/screening/context.py:522— context._allocate_section_budgets has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
dsa_provider._build_dsa_summary (cognitive 16) src/services/screening/dsa_provider.py:177— dsa_provider._build_dsa_summary has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), ternaries 4, 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.
hotspot._resolve_topic_from_candidates (cognitive 16) src/services/screening/hotspot.py:1132— hotspot._resolve_topic_from_candidates has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (6 pts), boolean chains 5, ternaries 4, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
snapshot.fetch_snapshot_with_fallback (cognitive 16) src/services/screening/snapshot.py:65— snapshot.fetch_snapshot_with_fallback has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), error handling 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.
strategy.match_strategies (cognitive 16) src/services/screening/strategy.py:451— strategy.match_strategies has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 6, 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.
screening_service._match_screening_litellm_headers (cognitive 16) REDACTED:3172— screening_service._match_screening_litellm_headers has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 5, ternaries 1 (2 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stock_code_utils._build_market_code_variants (cognitive 16) src/services/stock_code_utils.py:273— stock_code_utils._build_market_code_variants has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 5, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
stock_list_parser._index_entry_from_row (cognitive 16) src/services/stock_list_parser.py:465— stock_list_parser._index_entry_from_row has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 7, if/else 6, ternaries 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.
SystemConfigService._resolve_setup_primary_model (cognitive 16) src/services/system_config_service.py:3570— SystemConfigService._resolve_setup_primary_model has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 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.
share_image._stock_heading_entry (cognitive 16) src/share_image.py:879— share_image._stock_heading_entry has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (13 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StockTrendAnalyzer._analyze_support_resistance (cognitive 16) src/stock_analyzer.py:449— StockTrendAnalyzer._analyze_support_resistance has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 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.
DatabaseManager._run_write_transaction (cognitive 16) REDACTED:2318— DatabaseManager._run_write_transaction has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), error handling 2 (4 pts), boolean chains 1, loops 1, ternaries 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.
stockPoolStore.fetchMarketReviewHistory (cognitive 16) apps/dsa-web/src/stores/stockPoolStore.ts:548— stockPoolStore.fetchMarketReviewHistory has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), ternaries 3 (4 pts), boolean chains 1, error handling 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.
ParticleBackground.ParticleBackground (cognitive 16) apps/dsa-web/src/components/common/ParticleBackground.tsx:46— ParticleBackground.ParticleBackground has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 4). None of this is in the body itself: all 16 points belong to 5 function literals inside it that branch (lines 75, 49, 66, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
searchStocks.calculateMatchScore (cognitive 16) apps/dsa-web/src/utils/searchStocks.ts:87— searchStocks.calculateMatchScore has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13, 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.
StockAutocomplete.StockAutocompleteInner (cognitive 16) apps/dsa-web/src/components/StockAutocomplete/StockAutocomplete.tsx:105— StockAutocomplete.StockAutocompleteInner has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 5, match/switch 1 (nesting depth added 1). Most of this is not in the body itself: 5 of the 16 points are its own statements and the rest belongs to 6 function items inside it that branch (handleKeyDown, updateDropdownPosition, a function literal at line 156, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
LLMChannelEditor.parseChannelsFromItems (cognitive 16) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1469— LLMChannelEditor.parseChannelsFromItems has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 15, ternaries 1. Most of this is not in the body itself: 6 of the 16 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 1483, 1491). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
LLMChannelEditor.channelsToUpdateItems (cognitive 16) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1509— LLMChannelEditor.channelsToUpdateItems has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 3 (8 pts), if/else 4 (6 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.
DecisionSignalProfileCalibration.DecisionSignalProfileCalibration (cognitive 16) apps/dsa-web/src/components/decision-signals/DecisionSignalProfileCalibration.tsx:40— DecisionSignalProfileCalibration.DecisionSignalProfileCalibration has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 10 (12 pts), boolean chains 3, if/else 1 (nesting depth added 2). Most of this is not in the body itself: 5 of the 16 points are its own statements and the rest belongs to 6 function items inside it that branch (childLabel, a function literal at line 184, a function literal at line 117, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D4 · Code Duplication· Near-duplicate member family (3 members, 80 shared lines) · ×1
Near-duplicate member family (3 members, 80 shared lines) REDACTED:2100— REDACTED:2100-2183 | data_provider/efinance_fetcher.py:1066-1149 | data_provider/tushare_fetcher.py:965-1048 — These 3 members are variants of one another: a block of 80 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
Near-duplicate member pair (171 shared lines) src/notification.py:1260— src/notification.py:1260-1622 | src/services/history_service.py:1117-1469 — These two members are variants of one another: 171 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (98 shared lines) src/search_service.py:1028— src/search_service.py:1028-1194 | src/search_service.py:1224-1383 — These two members are variants of one another: 98 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (55 shared lines) bot/dispatcher.py:458— bot/dispatcher.py:458-539 | bot/dispatcher.py:542-602 — These two members are variants of one another: 55 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (49 shared lines) REDACTED:1219— REDACTED:1219-1367 | REDACTED:1370-1520 — These two members are variants of one another: 49 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (39 shared lines) scripts/generate_index_from_csv.py:778— scripts/generate_index_from_csv.py:778-913 | src/data/stock_index_loader.py:598-700 — These two members are variants of one another: 39 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (33 shared lines) src/services/screening/filter.py:198— src/services/screening/filter.py:198-274 | src/services/screening/filter.py:283-374 — These two members are variants of one another: 33 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Edited copy of a member (38 corresponding lines) · ×1
Edited copy of a member (38 corresponding lines) REDACTED:276— REDACTED:276-318 | data_provider/efinance_fetcher.py:218-259 — These two members are one piece of code written twice and then edited apart: 38 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 (6 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (6 members, 50+ identical tokens) REDACTED:352— REDACTED:352-399 | REDACTED:402-426 | REDACTED:429-458 | REDACTED:461-481 | REDACTED:484-504 | REDACTED:507-527 — 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· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (4 members, 50+ identical tokens) src/services/system_config_service.py:3453— src/services/system_config_service.py:3453-3540 | src/services/system_config_service.py:4643-4829 | src/services/system_config_service.py:4833-4919 | src/services/system_config_service.py:4923-4961 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Duplicated block (4–59 lines × 3) src/notification.py:1358— src/notification.py:1358-1416 | src/notification.py:1555-1558 | src/services/history_service.py:1174-1230 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `src/notification.py:1358` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (52–54 lines × 2) data_provider/base.py:2048— data_provider/base.py:2048-2099 | data_provider/base.py:2127-2180 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:2048` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `data_provider/base.py:2183` calls `info` and `data_provider/base.py:2100` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (50 lines × 2) src/repositories/portfolio_repo.py:875— src/repositories/portfolio_repo.py:875-924 | src/repositories/portfolio_repo.py:1060-1109 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (34–49 lines × 2) bot/handler.py:58— bot/handler.py:58-106 | bot/handler.py:145-178 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (47–49 lines × 2) data_provider/base.py:989— data_provider/base.py:989-1035 | data_provider/base.py:1202-1250 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:989` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (49 lines × 2) src/notification.py:1493— src/notification.py:1493-1541 | src/services/history_service.py:1316-1364 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/notification.py:1490` calls `_append_phase_decision_block` and `src/services/history_service.py:1313` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (44–46 lines × 2) src/search_service.py:1073— src/search_service.py:1073-1118 | src/search_service.py:1258-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (42–43 lines × 2) src/services/system_config_service.py:5143— src/services/system_config_service.py:5143-5185 | src/services/system_config_service.py:5280-5321 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/system_config_service.py:5143` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (41–42 lines × 2) src/repositories/portfolio_repo.py:997— src/repositories/portfolio_repo.py:997-1037 | src/repositories/portfolio_repo.py:1111-1152 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (41 lines × 2) src/search_service.py:1154— src/search_service.py:1154-1194 | src/search_service.py:1343-1383 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/search_service.py:1154` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (37–38 lines × 2) src/services/system_config_service.py:2509— src/services/system_config_service.py:2509-2545 | src/services/system_config_service.py:5164-5201 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/system_config_service.py:5164` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20–37 lines × 2) bot/dispatcher.py:458— bot/dispatcher.py:458-494 | bot/dispatcher.py:542-561 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (33–36 lines × 2) src/notification_sender/gotify_sender.py:88— src/notification_sender/gotify_sender.py:88-123 | src/notification_sender/ntfy_sender.py:95-127 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (35 lines × 2) REDACTED:284— REDACTED:284-318 | data_provider/efinance_fetcher.py:225-259 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:284` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (29–32 lines × 2) src/notification.py:2065— src/notification.py:2065-2096 | src/services/history_service.py:1354-1382 — 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–31 lines × 2) REDACTED:725— REDACTED:725-749 | REDACTED:858-888 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:856` calls `warning`, `_get_us_stock_quote_from_stooq` and `REDACTED:724` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (28–31 lines × 2) src/services/daily_market_context.py:144— src/services/daily_market_context.py:144-174 | src/services/daily_market_context.py:195-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (31 lines × 2) src/services/decision_signal_reassess_service.py:374— src/services/decision_signal_reassess_service.py:374-404 | src/services/decision_signal_service.py:603-633 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (27–28 lines × 2) api/v1/endpoints/system_config.py:389— api/v1/endpoints/system_config.py:389-415 | api/v1/endpoints/system_config.py:507-534 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `api/v1/endpoints/system_config.py:507` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (28 lines × 2) src/analyzer.py:3151— src/analyzer.py:3151-3178 | src/market_analyzer.py:167-194 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (26–27 lines × 2) bot/platforms/feishu_stream.py:204— bot/platforms/feishu_stream.py:204-230 | bot/platforms/feishu_stream.py:242-267 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `bot/platforms/feishu_stream.py:204` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (27 lines × 2) src/notification.py:1421— src/notification.py:1421-1447 | src/services/history_service.py:1236-1262 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/services/history_service.py:1263` calls `localize_bias_status`, `get_bias_status_emoji` and `src/notification.py:1448` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11–24 lines × 3) scripts/generate_index_from_csv.py:708— scripts/generate_index_from_csv.py:708-718 | src/data/stock_index_loader.py:30-47 | src/services/stock_list_parser.py:64-87 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `value` to `str` in one and `object` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (23–24 lines × 2) data_provider/base.py:1125— data_provider/base.py:1125-1147 | data_provider/base.py:1329-1352 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:1329` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `data_provider/base.py:1148` calls `_record_daily_source_failure` and `data_provider/base.py:1353` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (22–24 lines × 2) src/services/screening/daily.py:624— src/services/screening/daily.py:624-647 | src/services/screening/snapshot.py:255-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.
Duplicated block (23 lines × 3) src/auth.py:257— src/auth.py:257-279 | src/auth.py:307-329 | src/auth.py:437-459 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/auth.py:255` calls `_get_data_dir`, `mkdir` and `src/auth.py:305` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (23 lines × 2) src/search_service.py:382— src/search_service.py:382-404 | src/search_service.py:535-557 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20–23 lines × 2) src/services/portfolio_risk_service.py:300— src/services/portfolio_risk_service.py:300-319 | src/services/portfolio_risk_service.py:365-387 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/services/portfolio_risk_service.py:363` calls `setdefault`, `set`, `add` and `src/services/portfolio_risk_service.py:298` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (21–22 lines × 2) scripts/generate_index_from_csv.py:65— scripts/generate_index_from_csv.py:65-86 | scripts/generate_index_from_csv.py:213-233 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (22 lines × 2) src/agent/skills/deliberation.py:376— src/agent/skills/deliberation.py:376-397 | src/agent/skills/deliberation.py:834-855 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20–22 lines × 2) src/services/notification_diagnostics.py:423— src/services/notification_diagnostics.py:423-442 | src/services/notification_diagnostics.py:451-472 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/notification_diagnostics.py:423` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–21 lines × 4) REDACTED:429— REDACTED:429-449 | REDACTED:461-475 | REDACTED:484-498 | REDACTED:507-521 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:429` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 3) src/market_structure_prompt.py:72— src/market_structure_prompt.py:72-91 | src/market_structure_prompt.py:104-123 | src/market_structure_prompt.py:136-155 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18–20 lines × 2) data_provider/base.py:3968— data_provider/base.py:3968-3985 | data_provider/base.py:4322-4341 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `data_provider/base.py:4322` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (17–20 lines × 2) src/search_service.py:3904— src/search_service.py:3904-3920 | src/search_service.py:4148-4167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/search_service.py:4148` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) src/services/screening/pipeline.py:668— src/services/screening/pipeline.py:668-687 | src/services/screening/strategy.py:792-811 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (19 lines × 5) data_provider/base.py:994— data_provider/base.py:994-1012 | data_provider/base.py:1020-1038 | data_provider/base.py:1044-1062 | data_provider/base.py:1209-1227 | data_provider/base.py:1235-1253 — 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 (17–18 lines × 3) src/core/pipeline.py:1719— src/core/pipeline.py:1719-1735 | src/core/pipeline.py:1747-1763 | src/core/pipeline.py:1777-1794 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/core/pipeline.py:1777` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–17 lines × 3) src/search_service.py:1156— src/search_service.py:1156-1172 | src/search_service.py:1345-1361 | src/search_service.py:1572-1585 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/search_service.py:1156` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15–16 lines × 2) REDACTED:1253— REDACTED:1253-1268 | REDACTED:1404-1418 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1253` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 4) api/v1/endpoints/decision_signals.py:187— api/v1/endpoints/decision_signals.py:187-201 | src/repositories/decision_signal_repo.py:187-201 | src/services/decision_signal_service.py:276-290 | src/services/decision_signal_service.py:314-328 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `api/v1/endpoints/decision_signals.py:187` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–15 lines × 2) src/agent/runner.py:473— src/agent/runner.py:473-485 | src/agent/runner.py:545-559 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agent/runner.py:545` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–14 lines × 6) REDACTED:386— REDACTED:386-399 | REDACTED:413-426 | REDACTED:445-458 | REDACTED:471-481 | REDACTED:494-504 | REDACTED:517-527 — 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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 3) data_provider/base.py:4664— data_provider/base.py:4664-4677 | data_provider/base.py:4754-4767 | data_provider/base.py:4805-4818 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–14 lines × 2) REDACTED:1154— REDACTED:1154-1167 | REDACTED:1561-1573 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:1170` calls `info` and `REDACTED:1577` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11–14 lines × 2) src/analyzer.py:5492— src/analyzer.py:5492-5505 | src/services/history_service.py:1072-1082 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–14 lines × 2) src/services/market_light_alerts.py:97— src/services/market_light_alerts.py:97-110 | src/services/portfolio_alerts.py:202-213 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/market_light_alerts.py:97` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–12 lines × 3) REDACTED:649— REDACTED:649-659 | REDACTED:797-808 | REDACTED:956-967 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:649` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) REDACTED:665— REDACTED:665-676 | REDACTED:771-782 | REDACTED:919-930 — 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–12 lines × 2) data_provider/efinance_fetcher.py:691— data_provider/efinance_fetcher.py:691-702 | data_provider/efinance_fetcher.py:881-889 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 3) src/llm/local_cli_backend.py:927— src/llm/local_cli_backend.py:927-937 | src/llm/local_cli_backend.py:1524-1534 | src/llm/local_cli_backend.py:1581-1591 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10–11 lines × 3) src/services/system_config_service.py:3465— src/services/system_config_service.py:3465-3475 | src/services/system_config_service.py:4851-4861 | src/services/system_config_service.py:4980-4989 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9–11 lines × 2) REDACTED:709— REDACTED:709-717 | REDACTED:834-844 — both copies are in the same file, so extract the block into 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–11 lines × 2) src/services/decision_signal_extractor.py:67— src/services/decision_signal_extractor.py:67-73 | src/services/decision_signal_extractor.py:183-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. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/decision_signal_extractor.py:183` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–10 lines × 2) src/services/system_config_service.py:3509— src/services/system_config_service.py:3509-3518 | src/services/system_config_service.py:4893-4900 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/system_config_service.py:3509` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 2) src/agent/skills/base.py:195— src/agent/skills/base.py:195-202 | src/agent/skills/base.py:263-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. Read the line range as the matched WINDOW rather than a finished unit: at `src/agent/skills/base.py:195` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (2–8 lines × 4) src/services/system_config_service.py:3508— src/services/system_config_service.py:3508-3515 | src/services/system_config_service.py:4766-4767 | src/services/system_config_service.py:4892-4899 | src/services/system_config_service.py:4953-4960 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/system_config_service.py:3508` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/services/system_config_service.py:3506` calls `get`, `strip` and `src/services/system_config_service.py:4764` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 4) REDACTED:1187— REDACTED:1187-1193 | REDACTED:1593-1599 | REDACTED:1661-1667 | REDACTED:1804-1810 — 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 (5–6 lines × 2) REDACTED:1606— REDACTED:1606-1610 | REDACTED:1673-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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1606` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 3) src/services/screening/scorer.py:235— src/services/screening/scorer.py:235-239 | src/services/screening/scorer.py:246-250 | src/services/screening/scorer.py:302-306 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/services/screening/scorer.py:235` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/services/screening/scorer.py:232` calls `clip` and `src/services/screening/scorer.py:301` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Outbound HTTP without resilience src/notification_sender/discord_sender.py:227— `requests.post(` 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.
P8 · Schema migrations· Schema created by SQLAlchemy create_all() (no migration path) · ×1
Schema created by SQLAlchemy create_all() (no migration path) REDACTED:1403— SQLAlchemy create_all() builds the schema from the model at startup and keeps no migration history, so there is no reviewed, repeatable upgrade path for an existing production database — a renamed column is dropped and re-added rather than migrated. Adopt Alembic (`alembic revision --autogenerate` + `alembic upgrade head`), so every schema change is a versioned file applied the same way in every environment.
Duplication concentrated across 7 sibling directories (31 clone groups) apps/dsa-web/src/components/alerts/AlertTriggerHistory.tsx:52— 31 duplicated blocks under apps/dsa-web/src/ have copies in at least two of the sibling directories api, components, contexts, hooks, pages, stores (+1 more sibling(s) not listed) — 15 of them are reported below, and 16 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 31 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 31 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 31 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 9 sibling directories (7 clone groups) apps/dsa-web/src/components/common/PageHeader.tsx:12— 7 duplicated blocks under apps/dsa-web/src/components/ have copies in at least two of the sibling directories StockAutocomplete, alerts, common, history, i18n, layout (+3 more sibling(s) not listed) — 3 of them are reported below, and 4 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 7 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 7 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 7 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
R10 · Code Duplication· Duplicated block with local edits (64 matched lines × 2 locations) · ×1
Duplicated block with local edits (64 matched lines × 2 locations) apps/dsa-web/src/components/history/HistoryList.tsx:105— apps/dsa-web/src/components/history/HistoryList.tsx:105 · apps/dsa-web/src/components/history/StockBar.tsx:88 — the two spans are one implementation copied and then locally edited — 339 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication· Duplicated block with local edits (55 matched lines × 2 locations) · ×1
Duplicated block with local edits (55 matched lines × 2 locations) apps/dsa-web/src/components/history/HistoryListItem.tsx:55— apps/dsa-web/src/components/history/HistoryListItem.tsx:55 · apps/dsa-web/src/components/history/StockBarItem.tsx:46 — the two spans are one implementation copied and then locally edited — 241 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (42 lines × 2 locations) apps/dsa-web/src/stores/stockPoolStore.ts:761— apps/dsa-web/src/stores/stockPoolStore.ts:761 · apps/dsa-web/src/stores/stockPoolStore.ts:824 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication· Duplicated block with local edits (38 matched lines × 2 locations) · ×1
Duplicated block with local edits (38 matched lines × 2 locations) apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:361— apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:361 · apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:413 — the two spans are one implementation copied and then locally edited — 263 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (27 lines × 2 locations) apps/dsa-web/src/stores/stockPoolStore.ts:477— apps/dsa-web/src/stores/stockPoolStore.ts:477 · apps/dsa-web/src/stores/stockPoolStore.ts:556 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (24 lines × 2 locations) apps/dsa-web/src/components/alerts/AlertTriggerHistory.tsx:52— apps/dsa-web/src/components/alerts/AlertTriggerHistory.tsx:52 · apps/dsa-web/src/pages/AlertsPage.tsx:334 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
R10 · Code Duplication· Duplicated block with local edits (24 matched lines × 2 locations) · ×1
Duplicated block with local edits (24 matched lines × 2 locations) apps/dsa-web/src/components/settings/AgentBackendStatusPanel.tsx:69— apps/dsa-web/src/components/settings/AgentBackendStatusPanel.tsx:69 · apps/dsa-web/src/components/settings/GenerationBackendStatusPanel.tsx:105 — the two spans are one implementation copied and then locally edited — 125 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (22 lines × 2 locations) apps/dsa-web/src/stores/stockPoolStore.ts:1071— apps/dsa-web/src/stores/stockPoolStore.ts:1071 · apps/dsa-web/src/stores/stockPoolStore.ts:1095 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 2 locations) apps/dsa-web/src/api/backtest.ts:78— apps/dsa-web/src/api/backtest.ts:78 · apps/dsa-web/src/api/backtest.ts:107 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (17 lines × 2 locations) apps/dsa-web/src/components/decision-signals/DecisionSignalProfileCalibration.tsx:161— apps/dsa-web/src/components/decision-signals/DecisionSignalProfileCalibration.tsx:161 · apps/dsa-web/src/components/decision-signals/DecisionSignalProfileCalibration.tsx:226 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
R10 · Code Duplication· Duplicated block with local edits (16 matched lines × 2 locations) · ×1
Duplicated block with local edits (16 matched lines × 2 locations) apps/dsa-web/src/components/report/ReportDetails.tsx:50— apps/dsa-web/src/components/report/ReportDetails.tsx:50 · apps/dsa-web/src/pages/ChatPage.tsx:641 — the two spans are one implementation copied and then locally edited — 82 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (15 lines × 4 locations) apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:595— apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:595 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:627 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:669 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:711 — all 4 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
R10 · Code Duplication· Duplicated block with local edits (15 matched lines × 2 locations) · ×1
Duplicated block with local edits (15 matched lines × 2 locations) apps/dsa-web/src/components/report/ReportNews.tsx:156— apps/dsa-web/src/components/report/ReportNews.tsx:156 · apps/dsa-web/src/pages/ChatPage.tsx:871 — the two spans are one implementation copied and then locally edited — 54 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication· Duplicated block with local edits (14 matched lines × 2 locations) · ×1
Duplicated block with local edits (14 matched lines × 2 locations) apps/dsa-web/src/pages/BacktestPage.tsx:528— apps/dsa-web/src/pages/BacktestPage.tsx:528 · apps/dsa-web/src/pages/HomePage.tsx:1627 — the two spans are one implementation copied and then locally edited — 74 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (14 lines × 3 locations) apps/dsa-web/src/pages/PortfolioPage.tsx:1090— apps/dsa-web/src/pages/PortfolioPage.tsx:1090 · apps/dsa-web/src/pages/PortfolioPage.tsx:1117 · apps/dsa-web/src/pages/PortfolioPage.tsx:1140 — all 3 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (13 lines × 7 locations) apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:571— apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:571 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:593 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:625 · apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:645 · +3 more site(s) not listed — all 7 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Complex function SettingsPage (cyclomatic 119, cognitive 101) apps/dsa-web/src/pages/SettingsPage.tsx:688— SettingsPage has cyclomatic complexity 119 and cognitive complexity 101; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function PortfolioPage (cyclomatic 113, cognitive 106) apps/dsa-web/src/pages/PortfolioPage.tsx:624— PortfolioPage has cyclomatic complexity 113 and cognitive complexity 106; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function StockScreeningPage (cyclomatic 101, cognitive 95) apps/dsa-web/src/pages/StockScreeningPage.tsx:841— StockScreeningPage has cyclomatic complexity 101 and cognitive complexity 95; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function ChatPage (cyclomatic 63, cognitive 59) apps/dsa-web/src/pages/ChatPage.tsx:83— ChatPage has cyclomatic complexity 63 and cognitive complexity 59; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function ChannelRow (cyclomatic 59, cognitive 57) apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:399— ChannelRow has cyclomatic complexity 59 and cognitive complexity 57; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function renderReassessPanel (cyclomatic 53, cognitive 49) apps/dsa-web/src/pages/DecisionSignalsPage.tsx:966— renderReassessPanel has cyclomatic complexity 53 and cognitive complexity 49; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function DecisionSignalsPage (cyclomatic 46, cognitive 43) apps/dsa-web/src/pages/DecisionSignalsPage.tsx:388— DecisionSignalsPage has cyclomatic complexity 46 and cognitive complexity 43; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function HomePage (cyclomatic 43, cognitive 40) apps/dsa-web/src/pages/HomePage.tsx:252— HomePage has cyclomatic complexity 43 and cognitive complexity 40; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function buildExposureRows (cyclomatic 41, cognitive 57) apps/dsa-web/src/pages/PortfolioPage.tsx:372— buildExposureRows has cyclomatic complexity 41 and cognitive complexity 57; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function (anonymous) (cyclomatic 41, cognitive 25) apps/dsa-web/src/utils/decisionAction.ts:94— (anonymous) has cyclomatic complexity 41 and cognitive complexity 25; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function formatParameters (cyclomatic 39, cognitive 42) apps/dsa-web/src/components/alerts/AlertRuleList.tsx:30— formatParameters has cyclomatic complexity 39 and cognitive complexity 42; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function normalizeStockCode (cyclomatic 36, cognitive 41) apps/dsa-web/src/utils/stockCode.ts:16— normalizeStockCode has cyclomatic complexity 36 and cognitive complexity 41; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function parseApiError (cyclomatic 36, cognitive 34) apps/dsa-web/src/api/error.ts:310— parseApiError has cyclomatic complexity 36 and cognitive complexity 34; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function startStream (cyclomatic 34, cognitive 44) apps/dsa-web/src/stores/agentChatStore.ts:349— startStream has cyclomatic complexity 34 and cognitive complexity 44; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function decodeChatState (cyclomatic 34, cognitive 33) apps/dsa-web/src/api/agent.ts:60— decodeChatState has cyclomatic complexity 34 and cognitive complexity 33; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function Input (cyclomatic 33, cognitive 30) apps/dsa-web/src/components/common/Input.tsx:25— Input has cyclomatic complexity 33 and cognitive complexity 30; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function buildPortfolioRiskFlags (cyclomatic 32, cognitive 30) apps/dsa-web/src/pages/PortfolioPage.tsx:444— buildPortfolioRiskFlags has cyclomatic complexity 32 and cognitive complexity 30; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function DesktopUpdateIndicator (cyclomatic 32, cognitive 28) apps/dsa-web/src/components/layout/DesktopUpdateIndicator.tsx:12— DesktopUpdateIndicator has cyclomatic complexity 32 and cognitive complexity 28; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function MarketReviewReportView (cyclomatic 32, cognitive 23) apps/dsa-web/src/components/report/MarketReviewReportView.tsx:363— MarketReviewReportView has cyclomatic complexity 32 and cognitive complexity 23; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function (anonymous) (cyclomatic 31, cognitive 43) apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:284— (anonymous) has cyclomatic complexity 31 and cognitive complexity 43; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R3 · Large Files· apps/dsa-web/src/locales/settingsHelp.ts · ×1
apps/dsa-web/src/locales/settingsHelp.ts: 2539 lines of code apps/dsa-web/src/locales/settingsHelp.ts:1— apps/dsa-web/src/locales/settingsHelp.ts has 2539 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/settings/LLMChannelEditor.tsx · ×1
apps/dsa-web/src/components/settings/LLMChannelEditor.tsx: 2469 lines of code apps/dsa-web/src/components/settings/LLMChannelEditor.tsx:1— apps/dsa-web/src/components/settings/LLMChannelEditor.tsx has 2469 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/pages/PortfolioPage.tsx · ×1
apps/dsa-web/src/pages/PortfolioPage.tsx: 2095 lines of code apps/dsa-web/src/pages/PortfolioPage.tsx:1— apps/dsa-web/src/pages/PortfolioPage.tsx has 2095 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/pages/StockScreeningPage.tsx · ×1
apps/dsa-web/src/pages/StockScreeningPage.tsx: 2061 lines of code apps/dsa-web/src/pages/StockScreeningPage.tsx:1— apps/dsa-web/src/pages/StockScreeningPage.tsx has 2061 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/i18n/uiText.ts · ×1
apps/dsa-web/src/i18n/uiText.ts: 2026 lines of code apps/dsa-web/src/i18n/uiText.ts:1— apps/dsa-web/src/i18n/uiText.ts has 2026 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
REDACTED: 1900 lines of code REDACTED:1— REDACTED has 1900 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/pages/HomePage.tsx · ×1
apps/dsa-web/src/pages/HomePage.tsx: 1783 lines of code apps/dsa-web/src/pages/HomePage.tsx:1— apps/dsa-web/src/pages/HomePage.tsx has 1783 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/pages/SettingsPage.tsx · ×1
apps/dsa-web/src/pages/SettingsPage.tsx: 1667 lines of code apps/dsa-web/src/pages/SettingsPage.tsx:1— apps/dsa-web/src/pages/SettingsPage.tsx has 1667 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/pages/DecisionSignalsPage.tsx · ×1
apps/dsa-web/src/pages/DecisionSignalsPage.tsx: 1538 lines of code apps/dsa-web/src/pages/DecisionSignalsPage.tsx:1— apps/dsa-web/src/pages/DecisionSignalsPage.tsx has 1538 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/pages/ChatPage.tsx · ×1
apps/dsa-web/src/pages/ChatPage.tsx: 1481 lines of code apps/dsa-web/src/pages/ChatPage.tsx:1— apps/dsa-web/src/pages/ChatPage.tsx has 1481 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/stores/stockPoolStore.ts · ×1
apps/dsa-web/src/stores/stockPoolStore.ts: 999 lines of code apps/dsa-web/src/stores/stockPoolStore.ts:1— apps/dsa-web/src/stores/stockPoolStore.ts has 999 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx · ×1
apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx: 772 lines of code apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:1— apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx has 772 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/alerts/AlertRuleForm.tsx · ×1
apps/dsa-web/src/components/alerts/AlertRuleForm.tsx: 741 lines of code apps/dsa-web/src/components/alerts/AlertRuleForm.tsx:1— apps/dsa-web/src/components/alerts/AlertRuleForm.tsx has 741 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/report/MarketReviewReportView.tsx · ×1
apps/dsa-web/src/components/report/MarketReviewReportView.tsx: 702 lines of code apps/dsa-web/src/components/report/MarketReviewReportView.tsx:1— apps/dsa-web/src/components/report/MarketReviewReportView.tsx has 702 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx · ×1
apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx: 691 lines of code apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:1— apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx has 691 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/pages/BacktestPage.tsx · ×1
apps/dsa-web/src/pages/BacktestPage.tsx: 683 lines of code apps/dsa-web/src/pages/BacktestPage.tsx:1— apps/dsa-web/src/pages/BacktestPage.tsx has 683 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/utils/systemConfigI18n.ts · ×1
apps/dsa-web/src/utils/systemConfigI18n.ts: 596 lines of code apps/dsa-web/src/utils/systemConfigI18n.ts:1— apps/dsa-web/src/utils/systemConfigI18n.ts has 596 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/types/analysis.ts · ×1
apps/dsa-web/src/types/analysis.ts: 582 lines of code apps/dsa-web/src/types/analysis.ts:1— apps/dsa-web/src/types/analysis.ts has 582 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/stores/agentChatStore.ts · ×1
apps/dsa-web/src/stores/agentChatStore.ts: 543 lines of code apps/dsa-web/src/stores/agentChatStore.ts:1— apps/dsa-web/src/stores/agentChatStore.ts has 543 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/api/error.ts · ×1
apps/dsa-web/src/api/error.ts: 493 lines of code apps/dsa-web/src/api/error.ts:1— apps/dsa-web/src/api/error.ts has 493 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/hooks/useRunFlowSnapshot.ts · ×1
apps/dsa-web/src/hooks/useRunFlowSnapshot.ts: 483 lines of code apps/dsa-web/src/hooks/useRunFlowSnapshot.ts:1— apps/dsa-web/src/hooks/useRunFlowSnapshot.ts has 483 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/report/AnalysisContextSummary.tsx · ×1
apps/dsa-web/src/components/report/AnalysisContextSummary.tsx: 477 lines of code apps/dsa-web/src/components/report/AnalysisContextSummary.tsx:1— apps/dsa-web/src/components/report/AnalysisContextSummary.tsx has 477 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx · ×1
apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx: 461 lines of code apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx:1— apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx has 461 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/api/screening.ts · ×1
apps/dsa-web/src/api/screening.ts: 453 lines of code apps/dsa-web/src/api/screening.ts:1— apps/dsa-web/src/api/screening.ts has 453 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/settings/IntelligentImport.tsx · ×1
apps/dsa-web/src/components/settings/IntelligentImport.tsx: 420 lines of code apps/dsa-web/src/components/settings/IntelligentImport.tsx:1— apps/dsa-web/src/components/settings/IntelligentImport.tsx has 420 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· apps/dsa-web/src/components/report/ReportDiagnostics.tsx · ×1
apps/dsa-web/src/components/report/ReportDiagnostics.tsx: 412 lines of code apps/dsa-web/src/components/report/ReportDiagnostics.tsx:1— apps/dsa-web/src/components/report/ReportDiagnostics.tsx has 412 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
Dead file (~25 LoC) apps/dsa-desktop/scripts/afterPackMacos.js— no import path from any entry point (20 application, 8 tooling, 119 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~12 LoC) apps/dsa-web/src/components/report/index.ts— no import path from any entry point (20 application, 8 tooling, 119 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Unused dependency '@remixicon/react' — Declared in apps/dsa-web/package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
X1 · Async correctness· Task from `asyncio.ensure_future` is not kept · ×1
Task from `asyncio.ensure_future` is not kept bot/handler.py:189— The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
Interpolated log message defeats structured logging main.py:791— `info` at line 791 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:797— `warning` at line 797 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.warning("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1084— `info` at line 1084 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1178— `info` at line 1178 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1216— `info` at line 1216 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1225— `error` at line 1225 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1236— `exception` at line 1236 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.exception("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.exception("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1380— `info` at line 1380 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1389— `info` at line 1389 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1418— `error` at line 1418 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1433— `error` at line 1433 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1586— `info` at line 1586 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1625— `info` at line 1625 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1650— `info` at line 1650 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1720— `error` at line 1720 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1731— `info` at line 1731 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1733— `info` at line 1733 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1754— `info` at line 1754 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1814— `info` at line 1814 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1825— `info` at line 1825 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1834— `info` at line 1834 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging main.py:1941— `exception` at line 1941 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.exception("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.exception("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging api/middlewares/error_handler.py:52— `error` at line 52 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging api/middlewares/error_handler.py:116— `error` at line 116 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging api/v1/endpoints/stocks.py:177— `warning` at line 177 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.warning("order moved", order_id=order_id, status=status)` with structlog.
Orphaned file src/brokers/futu/portfolio.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file src/services/social_sentiment_service.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file apps/dsa-web/src/pages/TokenUsagePage.tsx:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file bot/platforms/dingtalk_stream.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file bot/platforms/dingtalk.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file scripts/generate_stock_index.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file src/notification_sender/slack_sender.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file src/notification_sender/pushover_sender.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file REDACTED:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file src/services/stock_service.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file apps/dsa-web/src/components/run-flow/RunFlowEventList.tsx:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file REDACTED:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file src/agent/skills/scheduler.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file src/feishu_doc.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file apps/dsa-web/src/utils/searchStocks.ts:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file data_provider/finnhub_fetcher.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file bot/models.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file apps/dsa-web/src/hooks/useAutocomplete.ts:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file src/repositories/stock_repo.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file apps/dsa-web/src/components/run-flow/utils.ts:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file bot/platforms/base.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file scripts/e2e_test_feishu_app.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file src/notification_sender/pushplus_sender.py:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file apps/dsa-web/src/components/common/ParticleBackground.tsx:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file apps/dsa-web/src/utils/portfolioFormat.ts:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Duplicated predicate apps/dsa-web/src/components/run-flow/RunFlowNodeDetails.tsx:75— `!value || typeof value !== 'object' || Array.isArray(value)` appears character-identically in 2 files — apps/dsa-web/src/components/run-flow/RunFlowNodeDetails.tsx, apps/dsa-web/src/pages/DataCenterPage.tsx. 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 apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:747— `RUN_FLOW_STATUS_STYLE[node.status] || RUN_FLOW_STATUS_STYLE.unknown` appears character-identically in 2 files — apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx, apps/dsa-web/src/components/run-flow/RunFlowNodeDetails.tsx. 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 apps/dsa-web/src/utils/decisionAction.ts:46— `action === 'buy' || action === 'add' || action === 'hold'` appears character-identically in 2 files — apps/dsa-web/src/utils/decisionAction.ts, apps/dsa-web/src/utils/decisionSignalTimeline.ts. 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 apps/dsa-web/src/pages/HomePage.tsx:636— `check.required && check.status === 'needs_action'` appears character-identically in 2 files — apps/dsa-web/src/pages/HomePage.tsx, apps/dsa-web/src/pages/SettingsPage.tsx. 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 apps/dsa-web/src/components/layout/DesktopUpdateIndicator.tsx:40— `containerRef.current && !containerRef.current.contains(event.target as Node)` appears character-identically in 2 files — apps/dsa-web/src/components/layout/DesktopUpdateIndicator.tsx, apps/dsa-web/src/components/theme/ThemeToggle.tsx. 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 apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:97— `edge.kind === 'fallback' || edge.kind === 'retry'` appears character-identically in 3 files — apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx, apps/dsa-web/src/components/run-flow/topologyViewModel.ts, apps/dsa-web/src/hooks/useRunFlowSnapshot.ts. 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 apps/dsa-web/src/components/report/MarketReviewReportView.tsx:519— `isLoading || !content || copiedType !== null` appears character-identically in 2 files — apps/dsa-web/src/components/report/MarketReviewReportView.tsx, apps/dsa-web/src/components/report/ReportMarkdownPanel.tsx. 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 apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:424— `row.isTodayStatusLoading || row.isTodayStatusUnknown` appears character-identically in 2 files — apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx, apps/dsa-web/src/pages/HomePage.tsx. 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 apps/dsa-web/src/components/history/HistoryList.tsx:58— `selectedCount > 0 && !allVisibleSelected` appears character-identically in 2 files — apps/dsa-web/src/components/history/HistoryList.tsx, apps/dsa-web/src/components/history/StockBar.tsx. 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 apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx:83— `status === 'failed' || status === 'timeout'` appears character-identically in 2 files — apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx, apps/dsa-web/src/components/run-flow/topologyViewModel.ts. 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 apps/dsa-web/src/components/layout/RouteBoundary.tsx:53— `this.state.hasError && prevProps.resetKey !== this.props.resetKey` appears character-identically in 2 files — apps/dsa-web/src/components/layout/RouteBoundary.tsx, apps/dsa-web/src/components/settings/SettingsPanelErrorBoundary.tsx. 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 apps/dsa-web/src/components/run-flow/topologyViewModel.ts:65— `typeof node.durationMs === 'number' && Number.isFinite(node.durationMs)` appears character-identically in 2 files — apps/dsa-web/src/components/run-flow/topologyViewModel.ts, apps/dsa-web/src/hooks/useRunFlowSnapshot.ts. 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 apps/dsa-web/src/components/history/StockHistoryTrendDrawer.tsx:46— `typeof value !== 'number' || !Number.isFinite(value)` appears character-identically in 2 files — apps/dsa-web/src/components/history/StockHistoryTrendDrawer.tsx, apps/dsa-web/src/components/run-flow/utils.ts. 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 apps/dsa-web/src/components/history/StockHistoryTrendDrawer.tsx:43— `typeof value === 'number' && Number.isFinite(value)` appears character-identically in 3 files — apps/dsa-web/src/components/history/StockHistoryTrendDrawer.tsx, apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx, apps/dsa-web/src/components/run-flow/RunFlowNodeDetails.tsx. 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 apps/dsa-web/src/api/error.ts:72— `typeof value === 'number' || typeof value === 'boolean'` appears character-identically in 3 files — apps/dsa-web/src/api/error.ts, apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx, apps/dsa-web/src/components/run-flow/utils.ts. 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 apps/dsa-web/src/api/agent.ts:57— `typeof value === 'object' && value !== null && !Array.isArray(value)` appears character-identically in 2 files — apps/dsa-web/src/api/agent.ts, apps/dsa-web/src/pages/DecisionSignalsPage.tsx. 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 apps/dsa-web/src/api/error.ts:56— `typeof value === 'string' && value.trim()` appears character-identically in 5 files — apps/dsa-web/src/api/error.ts, apps/dsa-web/src/components/report/MarketReviewReportView.tsx, apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx, apps/dsa-web/src/components/run-flow/topologyViewModel.ts. 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 apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx:78— `value === null || value === undefined || Number.isNaN(value)` appears character-identically in 2 files — apps/dsa-web/src/components/decision-signals/DecisionSignalDisplay.tsx, apps/dsa-web/src/pages/DecisionSignalsPage.tsx. 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 apps/dsa-web/src/components/decision-signals/DecisionSignalTimeline.tsx:74— `value === null || value === undefined || Number.isNaN(value) || !Number.isFinite(value)` appears character-identically in 2 files — apps/dsa-web/src/components/decision-signals/DecisionSignalTimeline.tsx, apps/dsa-web/src/utils/decisionSignalTimeline.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate REDACTED:174— `value === null || value === undefined || value === ''` appears character-identically in 4 files — REDACTED, apps/dsa-web/src/components/alerts/AlertTriggerHistory.tsx, apps/dsa-web/src/components/run-flow/utils.ts, apps/dsa-web/src/desktop/runtime.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate REDACTED:2154— `(current_price > 0) and (abs(current_price - limit_down_price) <= limit_down_price_Tolerance)` appears character-identically in 3 files — REDACTED, data_provider/efinance_fetcher.py, data_provider/tushare_fetcher.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate REDACTED:2153— `(current_price > 0) and (abs(current_price - limit_up_price) <= limit_up_price_Tolerance)` appears character-identically in 3 files — REDACTED, data_provider/efinance_fetcher.py, data_provider/tushare_fetcher.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate REDACTED:1542— `_etf_realtime_cache['data'] is not None and current_time - _etf_realtime_cache['timestamp'] < _etf_realtime_cache['ttl']` appears character-identically in 2 files — REDACTED, data_provider/efinance_fetcher.py. 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 src/llm/local_cli_backend.py:1742— `_has_sensitive_url_params(parsed.query) or _has_sensitive_url_params(parsed.fragment)` appears character-identically in 2 files — src/llm/local_cli_backend.py, src/utils/sanitize.py. 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 data_provider/base.py:4663— `_is_non_cn_request(stock_code) or _is_etf_code(stock_code)` appears character-identically in 2 files — data_provider/base.py, data_provider/miaoxiang_fetcher.py. 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.
Mock-dominated test: submits manually when fallback input receives Enter apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx:308— This test sets up 11 test doubles (for example `vi.fn`) against 1 real object(s) of its own, and its only verification is 1 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: prevents duplicate form submission when fallback input receives Enter apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx:372— This test sets up 12 test doubles (for example `vi.fn`) against 1 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: submits the raw input when suggestions are open but nothing is highlighted apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx:430— This test sets up 11 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 1 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: submits the highlighted suggestion when one is explicitly selected apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx:463— This test sets up 11 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: submits the highlighted HK suggestion using the canonical .HK code apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx:500— This test sets up 11 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: submits the highlighted BSE suggestion using the canonical .BJ code apps/dsa-web/src/components/StockAutocomplete/__tests__/StockAutocomplete.test.tsx:537— This test sets up 11 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: loads history, refreshes on interval, and reacts to visibility changes apps/dsa-web/src/hooks/__tests__/useDashboardLifecycle.test.tsx:37— This test sets up 9 test doubles (for example `vi.fn`) against 1 real object(s) of its own, and its only verification is 11 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: cleans pending task removal timers on unmount apps/dsa-web/src/hooks/__tests__/useDashboardLifecycle.test.tsx:83— This test sets up 8 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: refreshes completed task history and removes completed tasks after the grace window apps/dsa-web/src/hooks/__tests__/useDashboardLifecycle.test.tsx:115— This test sets up 12 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 7 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: forwards task progress updates to the task sync handler apps/dsa-web/src/hooks/__tests__/useDashboardLifecycle.test.tsx:162— This test sets up 8 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 1 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: reports failed tasks and removes them after the failure grace window apps/dsa-web/src/hooks/__tests__/useDashboardLifecycle.test.tsx:193— This test sets up 8 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: reconciles active tasks when the SSE stream connects apps/dsa-web/src/hooks/__tests__/useDashboardLifecycle.test.tsx:230— This test sets up 8 test doubles (for example `vi.fn`) against 0 real object(s) of its own, and its only verification is 1 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: does not open details when removing a watchlist row apps/dsa-web/src/pages/__tests__/HomePage.test.tsx:750— This test sets up 3 test doubles (for example `vi.mock/jest.mock of an imported module`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: deduplicates index aliases while keeping the same-code stock in analyze-all (PR #2312) apps/dsa-web/src/pages/__tests__/HomePage.test.tsx:2239— This test sets up 4 test doubles (for example `vi.mock/jest.mock of an imported module`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: submits a one-time multi-market override without saving system config apps/dsa-web/src/pages/__tests__/HomePage.test.tsx:2688— This test sets up 4 test doubles (for example `vi.mock/jest.mock of an imported module`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: keeps report language unset when only the UI language is English apps/dsa-web/src/pages/__tests__/HomePage.test.tsx:2729— This test sets up 3 test doubles (for example `vi.mock/jest.mock of an imported module`) against 0 real object(s) of its own, and its only verification is 3 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: navigates to chat with report context when asking a follow-up question apps/dsa-web/src/pages/__tests__/HomePage.test.tsx:3016— This test sets up 3 test doubles (for example `vi.mock/jest.mock of an imported module`) against 0 real object(s) of its own, and its only verification is 1 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: triggers reanalyze for the current report even if the search input has other text apps/dsa-web/src/pages/__tests__/HomePage.test.tsx:3258— This test sets up 3 test doubles (for example `vi.mock/jest.mock of an imported module`) against 0 real object(s) of its own, and its only verification is 2 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Mock-dominated test: passes the selected strategy when submitting stock analysis apps/dsa-web/src/pages/__tests__/HomePage.test.tsx:3297— This test sets up 4 test doubles (for example `vi.mock/jest.mock of an imported module`) against 0 real object(s) of its own, and its only verification is 1 check(s) that the doubles were called. It pins how the code is wired, not what it does: it passes with a wrong result and fails when a call is harmlessly reordered or merged. Assert the outcome instead (the value returned, the state left behind), build collaborators and value objects for real or with a small hand-written fake, and keep doubles for the boundaries the test cannot own — the network, the clock, the file system.
Silent fallback default on parse failure REDACTED:2474— `_safe_int` returns `0` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure evals/agent_trajectory/metrics.py:172— `_coerce_step` returns `0` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/agent/orchestrator.py:196— `_get_timeout_seconds` returns `0` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/analyzer.py:5138— `_format_percent` returns `'N/A'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/analyzer.py:5147— `_format_price` returns `'N/A'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/core/market_review.py:770— `_format_sector_change_pct` returns `'--'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/market_analyzer.py:1477— `_format_signed_pct` returns `'N/A'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/notification.py:2191— `_format_amount_cn` returns `'N/A'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/notification.py:2208— `_format_percent` returns `'N/A'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/notification.py:2215— `_format_per_share` returns `'N/A'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/notification.py:2402— `_format_net_shares` returns `'N/A'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure REDACTED:906— `_cooldown_seconds` returns `0` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/services/decision_signal_extractor.py:456— `_extract_holding_state` returns `'unknown'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/services/run_flow.py:1428— `_as_mapping` returns `{}` when `(TypeError, ValueError, json.JSONDecodeError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/services/screening/ranker.py:649— `_extract_completion_text` returns `''` when `(AttributeError, IndexError, KeyError, TypeError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure REDACTED:421— `_normalize_external_http_url` returns `''` when `ValueError` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/services/system_config_service.py:4010— `_get_runtime_llm_temperature` returns `0.7` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure src/share_image.py:1753— `_tone_for_score` returns `'primary'` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default on parse failure REDACTED:2806— `_screening_json_list` returns `[]` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch data_provider/tickflow_fetcher.py:811— `_get_realtime_cache_ttl` swallows every exception into `return 600` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/agent/skills/defaults.py:133— `_load_builtin_skill_catalog` swallows every exception into `return ()` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/analysis_context_pack_prompt.py:158— `analysis_context_pack_to_dict` swallows every exception into `return {}` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/analyzer.py:1273— `_as_dict_for_decision_guard` swallows every exception into `return {}` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/llm/local_cli_backend.py:765— `_registered_sensitive_field_titles` swallows every exception into `return frozenset()` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/llm/local_cli_backend.py:2861— `_registered_sensitive_env_exact_names` swallows every exception into `return frozenset()` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/search_service.py:567— `_extract_domain` swallows every exception into `return '未知来源'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/search_service.py:815— `_extract_domain` swallows every exception into `return '未知来源'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/search_service.py:1204— `_extract_domain` swallows every exception into `return '未知来源'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/search_service.py:1393— `_extract_domain` swallows every exception into `return '未知来源'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/search_service.py:1625— `_extract_domain` swallows every exception into `return '未知来源'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/search_service.py:1811— `_extract_domain` swallows every exception into `return '未知来源'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/search_service.py:2168— `_extract_domain` swallows every exception into `return '未知来源'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch src/services/daily_market_context.py:730— `_loads_mapping` swallows every exception into `return {}` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch REDACTED:2759— `_fetch_ths_summary_event` swallows every exception into `return ''` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch REDACTED:2784— `_fetch_ths_info` swallows every exception into `return {}` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch REDACTED:796— `readEnvFileValues` swallows every exception into `return {}` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch apps/dsa-web/src/utils/loginRedirect.ts:19— `resolveLoginRedirect` swallows every exception into `return '/'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
README/code drift docs/DEPLOY.md:273— docs/DEPLOY.md runs `docker-compose -f ./docker/docker-compose.yml logs -f --tail=100`, but `--tail=100` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift docs/DEPLOY_EN.md:261— docs/DEPLOY_EN.md runs `docker-compose -f ./docker/docker-compose.yml logs -f --tail=100`, but `--tail=100` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift docs/full-guide.md:548— docs/full-guide.md runs `docker-compose -f ./docker/docker-compose.yml logs -f server`, but `server` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift docs/full-guide.md:1532— docs/full-guide.md names `src/report.py`, but no file or folder `src/report.py` exists. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift docs/full-guide_EN.md:492— docs/full-guide_EN.md runs `docker-compose -f ./docker/docker-compose.yml logs -f server`, but `server` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift docs/openclaw-skill-integration.md:107— docs/openclaw-skill-integration.md documents the environment variable `DSA_BASE_URL`, but no code, script or configuration file names it. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
Unused export 'default' apps/dsa-web/src/components/StockAutocomplete/StockAutocomplete.tsx:325— Nothing imports this binding — it is safe to review for removal.
Unused export 'default' apps/dsa-web/src/components/StockAutocomplete/SuggestionsList.tsx:121— Nothing imports this binding — it is safe to review for removal.
Unused export 'default' apps/dsa-web/src/components/tasks/TaskPanel.tsx:299— Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/tasks/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/tasks/index.ts in the same commit, or the barrel will import a name that no longer exists.
Unused export 'default' apps/dsa-web/src/components/watchlist/HomeStockWorkspace.tsx:725— Nothing imports this binding — it is safe to review for removal.
Unused export 'default' apps/dsa-web/src/hooks/useAutocomplete.ts:199— Nothing imports this binding — it is safe to review for removal.
Unused export 'default' apps/dsa-web/src/hooks/useStockIndex.ts:78— Nothing imports this binding — it is safe to review for removal.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 22 significant file(s) lose their only recent owner: REDACTED, src/share_image.py, src/services/screening/daily.py, src/services/data_capability_service.py, src/services/screening/ranker.py, src/services/screening/pipeline.py, bot/commands/ask.py, src/services/screening/filter.py (+14 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 16 significant file(s) lose their only recent owner: src/llm/usage.py, src/services/analysis_context_builder.py, src/repositories/decision_signal_repo.py, src/agent/chat_context.py, src/agent/tools/analysis_tools.py, src/services/alert_indicators.py, src/services/portfolio_import_service.py, src/agent/tool_surface.py (+8 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 8 significant file(s) lose their only recent owner: src/services/run_flow.py, apps/dsa-web/src/components/run-flow/RunFlowGraph.tsx, scripts/fetch_tushare_stock_list.py, apps/dsa-web/src/hooks/useRunFlowSnapshot.ts, apps/dsa-web/src/components/run-flow/RunFlowNodeDetails.tsx, apps/dsa-web/src/components/run-flow/topologyViewModel.ts, apps/dsa-web/src/components/run-flow/RunFlowPanel.tsx, api/v1/schemas/run_flow.py. Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #4 — If anonymized user #4 becomes unavailable, 6 significant file(s) lose their only recent owner: src/agent/risk_override.py, src/services/skill_opinion_outcome_service.py, src/repositories/skill_opinion_outcome_repo.py, src/agent/runtime_facts.py, src/services/skill_opinion_performance_service.py, src/services/stock_daily_start_resolver.py. Pair on, review, or document these before any departure.
X23 · Unguarded diagnostic materialisation· Diagnostic log message is built whether or not it is wanted · ×4
Diagnostic log message is built whether or not it is wanted bot/handler.py:94— `debug` at line 94 is called with an argument built by `json.dumps(data, ensure_ascii = False)` (line 94), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
Diagnostic log message is built whether or not it is wanted bot/handler.py:169— `debug` at line 169 is called with an argument built by `json.dumps(data, ensure_ascii = False)` (line 169), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
Diagnostic log message is built whether or not it is wanted REDACTED:1871— `debug` at line 1871 is called with an argument built by `list(df.columns)` (line 1871), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
Diagnostic log message is built whether or not it is wanted src/search_service.py:1550— `debug` at line 1550 is called with an argument built by `list(data.keys())` (line 1550), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
Documentation: no project overview docs/README_CHT.md— The README begins with a product description and links to the full guide but does not state what the project is for or how it differs from competitors in one sentence. Add an overview paragraph stating the system's purpose (AI-driven stock analysis of A-shares,港股,美股,日股,韓股,台股) and its competitive advantages over alternatives.
Documentation: no project overview docs/README_EN.md— The README begins with a strong product description ('AI-powered stock analysis system for A-shares / Hong Kong / US / Japanese / Korean / Taiwan stocks') and links to repositories, but it does not state what the directory is for or how to use its contents. Add an overview section explaining what each subdirectory (e.g. Tushare fetcher, agent stream events) does and where to find usage examples.
Documentation: no usage examples docs/beginner-client-setup.md— This guide is a one-click installation with configuration steps but no usage example showing how to run it after setup. Add a short 'Run the first analysis' section demonstrating the workflow from setup to output.
Fat interface: StockPoolState (33 required operations) apps/dsa-web/src/stores/stockPoolStore.ts:55— `StockPoolState` declares 33 required operations: `setQuery`, `clearError`, `clearInlineMessages`, `openMarkdownDrawer`, `closeMarkdownDrawer`, `openHistoryTrend`, `closeHistoryTrend`, `setStockHistoryRange`, `loadMoreStockHistory`, `loadInitialHistory`, `refreshHistory`, `refreshHistoryForCompletedTask`, `loadMoreHistory`, `loadMarketReviewHistory`, `refreshMarketReviewHistory`, `loadMoreMarketReviewHistory`, `selectHistoryItem`, `toggleHistorySelection`, `toggleSelectAllVisible`, `deleteSelectedHistory`, `toggleMarketReviewHistorySelection`, `toggleSelectAllVisibleMarketReviewHistory`, `deleteSelectedMarketReviewHistory`, `submitAnalysis`, `setNotify`, `syncTaskCreated`, `syncTaskUpdated`, `syncTaskFailed`, `refreshActiveTasks`, `removeTask`, `resetDashboardState`, `loadStockBar`, `refreshStockBar`. Counted over its REQUIRED operations — a method signature or a function-typed property with no `?`, once per signature; optional members and data properties are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 6 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (58 single-owned of 422 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 422 of the 540 production source files in this repository met that bar). They are anonymized user #5 (1 file(s)), anonymized user #6 (1 file(s)), anonymized user #7 (1 file(s)), anonymized user #8 (1 file(s)), anonymized user #9 (1 file(s)), anonymized user #10 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: src/agent/web_intent_tokenizer.py, src/agent/skills/synthesis.py, data_provider/tw_institutional_fetcher.py, src/services/analysis_timeout_partial.py, REDACTED, bot/commands/help.py.
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 — 2 of 3 project(s) overshoot their size bounds, lowering Project Cohesion to 0.0/10. The most over is `(repository root)` (169182 LoC, 975 module-visible types across 30 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D28 · Secrets (history)· Rotate the exposed credentials · ×1
D34 · Knowledge Freshness· Further orphaned files (smaller) · ×1
Further orphaned files (smaller) — 36 smaller file(s) also have no living knowledge — folded into the freshness score and metrics rather than raised one row each — most significant first: src/brokers/futu/portfolio.py, src/services/social_sentiment_service.py, apps/dsa-web/src/pages/TokenUsagePage.tsx, bot/platforms/dingtalk_stream.py, bot/platforms/dingtalk.py, scripts/generate_stock_index.py, src/notification_sender/slack_sender.py, src/notification_sender/pushover_sender.py (and 28 more) (37 orphaned of 422 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 422 of the 540 production source files in this repository met that bar). Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
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.
Logging is not universal — Only 1/2 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `apps/dsa-desktop`.
No SAST — No static application security testing detected. For this repository's stack, add bandit, `semgrep --config=p/python`, or CodeQL's python pack as a CI step. What was searched, so you can tell an absence from a miss: the 86816 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
R7 · Dead Code· Unused export 'isLocalConnectionFailure' · ×1
Unused export 'isLocalConnectionFailure' apps/dsa-web/src/api/error.ts:306— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'isAxiosApiError' · ×1
Unused export 'isAxiosApiError' apps/dsa-web/src/api/error.ts:555— Nothing imports this binding — it is safe to review for removal.
Unused export 'Collapsible' apps/dsa-web/src/components/common/Collapsible.tsx:15— Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/common/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/common/index.ts in the same commit, or the barrel will import a name that no longer exists.
Unused export 'SectionCard' apps/dsa-web/src/components/common/SectionCard.tsx:12— Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/common/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/common/index.ts in the same commit, or the barrel will import a name that no longer exists.
R7 · Dead Code· Unused export 'StickyActionBar' · ×1
Unused export 'StickyActionBar' apps/dsa-web/src/components/common/StickyActionBar.tsx:9— Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/common/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/common/index.ts in the same commit, or the barrel will import a name that no longer exists.
R7 · Dead Code· Unused export 'ToastViewport' · ×1
Unused export 'ToastViewport' apps/dsa-web/src/components/common/ToastViewport.tsx:9— Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/common/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/common/index.ts in the same commit, or the barrel will import a name that no longer exists.
Unused export 'Toolbar' apps/dsa-web/src/components/common/Toolbar.tsx:10— Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/common/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/common/index.ts in the same commit, or the barrel will import a name that no longer exists.
Unused export 'ShellHeader' apps/dsa-web/src/components/layout/ShellHeader.tsx:27— Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/components/common/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/components/common/index.ts in the same commit, or the barrel will import a name that no longer exists.
R7 · Dead Code· Unused export 'PORTFOLIO_SIDE_LABELS' · ×1
Unused export 'PORTFOLIO_SIDE_LABELS' apps/dsa-web/src/locales/featureText.ts:66— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'PORTFOLIO_CASH_DIRECTION_LABELS' · ×1
Unused export 'PORTFOLIO_CASH_DIRECTION_LABELS' apps/dsa-web/src/locales/featureText.ts:67— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'PORTFOLIO_CORPORATE_ACTION_LABELS' · ×1
Unused export 'PORTFOLIO_CORPORATE_ACTION_LABELS' apps/dsa-web/src/locales/featureText.ts:68— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'useAnalysisStore' · ×1
Unused export 'useAnalysisStore' apps/dsa-web/src/stores/analysisStore.ts:24— Nothing ultimately consumes this binding: its only referrer is the re-export in apps/dsa-web/src/stores/index.ts, whose re-exported name has no consumer either. Removing it is therefore not a one-file change — drop the re-export line in apps/dsa-web/src/stores/index.ts in the same commit, or the barrel will import a name that no longer exists.
R7 · Dead Code· Unused export 'HistoryPagination' · ×1
Unused export 'HistoryPagination' apps/dsa-web/src/types/analysis.ts:592— Nothing imports this binding — it is safe to review for removal.
Unused export 'formatDate' apps/dsa-web/src/utils/format.ts:15— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'formatReportType' · ×1
Unused export 'formatReportType' apps/dsa-web/src/utils/format.ts:52— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'highlightMatch' · ×1
Unused export 'highlightMatch' apps/dsa-web/src/utils/searchStocks.ts:173— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'STOCK_INDEX_FIELDS' · ×1
Unused export 'STOCK_INDEX_FIELDS' apps/dsa-web/src/utils/stockIndexFields.ts:7— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'getCategoryTitleZh' · ×1
Unused export 'getCategoryTitleZh' apps/dsa-web/src/utils/systemConfigI18n.ts:562— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'getCategoryDescriptionZh' · ×1
Unused export 'getCategoryDescriptionZh' apps/dsa-web/src/utils/systemConfigI18n.ts:566— Nothing imports this binding — it is safe to review for removal.
Null assertions (`!`) reduce the strict null checking score — ~0.1 `!` null assertions per 1k TypeScript source lines — 5 assertion(s) across the 50244 source line(s) of the 190 TypeScript file(s) read, which is the only code the operator asserts anything in (a `!` in a `.js` file is not this operator and was not counted, and one in a file whose null checking is off silences nothing). Densest: apps/dsa-web/src/stores/agentChatStore.ts (3), apps/dsa-web/src/components/settings/IntelligentImport.tsx (1), apps/dsa-web/src/main.tsx (1). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce.
Outdated: futu-api — `futu-api` is pinned to 10.8.6808, but 10.11.7108 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 10.8.6808 until the declaration is edited.
Outdated: longbridge — `longbridge` is pinned to 0.2.74, but 5.3.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 0.2.74 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 1 file(s) — `apps/dsa-web/src/components/report/AnalysisContextSummary.tsx` — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
Run 01a17134-40f4-70b5-8ca9-541561993f40 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 163 · Warnings: 1797 · Recommendations: 231 · Info: 2 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 25-10-2026 @ 03:56 UTC.
Downloadable artifacts
Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.