Public report of HKUDS/LightRAG, 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, 10:06 UTC · Survey ID cd_bb00a93c6989485b81eff3827864cf3b
HKUDS/LightRAG
Measured 25 October 2026, 10:02 UTC, at code version aaebfe1
A regression is a drop of 0.5 points or more in the score, or of 2.5 or more out of 10 in a dimension, since the last survey.
Code coverage is not measured: JavaScript/TypeScript suite (CouldNotMeasureTestRunFailed).
CAI scoreAt riskNo change since the last survey
The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.
A large codebase: 174,146 lines of product code in 2 projects, tests not counted · Estimated rebuild effort: about 2.5 person-years · Weakest lens: Production Readiness, 34
Findings by how serious they are
148 critical1367 serious109 minor
14 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, 10:02 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 ▸
87of 87 dimensions measured by tools.
1602of 1624 findings point to an exact file and line, so you can open each one in the code. The other 22 concern the repository as a whole, such as missing documentation.
87dimensions across 7 lenses, read from 174,146 lines of product code in 2 projects.
HKUDS/LightRAG is rated At risk because critical security findings are open. Its score is held back in part because 12 passwords or keys sit in the current code. It scores 46 out of 100, which the At risk rating leaves unchanged.
Production Readiness, at 34, is the weakest lens and counts most in the score. The best first step is replacing the 12 exposed passwords or keys and switching the old ones off, worth about 10 points. Tidying the declared packages comes next, worth about 5 points. Raising Production Readiness to 70 would lift the score to about 56.
Forty-three pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Thirty-five known security holes in the packages the code depends on can be used by attackers, and twenty passwords or keys in the code's history and 12 in the code are open to anyone who can read the repository. Pinning each tool to an exact version, updating the vulnerable packages and replacing each exposed password or key would close these risks. The seven unsafe settings in infrastructure or container files need changing to safe values. The four pipeline steps that install packages without pinning their versions need the packages they install pinned to exact versions. The five labels or groups of fields with no name need connecting to their fields or naming.
The product code is 174,146 lines, about €370,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.
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: 50 findings
These 50 critical or serious findings were in the previous survey, on 11 October 2026, and are gone from this one.
Code Duplication · Edited copy of a member (34 corresponding lines) REDACTED
Code Duplication · Members sharing a duplicated core (12 members, 50+ identical tokens) REDACTED
Code Duplication · Members sharing a duplicated core (8 members, 50+ identical tokens) lightrag/kg/milvus_impl.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) lightrag/kg/milvus_impl.py
Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) lightrag/kg/milvus_impl.py
Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) lightrag/kg/milvus_impl.py
Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED
Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED
Exception handling · Swallowed exception (caught, then discarded) lightrag/llm/ollama.py
Exception handling · Swallowed exception (caught, then discarded) lightrag/llm/ollama.py
Rebuild cost: about €370,000 · Estimate
Cost to rebuild
€120,000 to €620,000, for 2,049 to 6,499 hours of work, about 2.5 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 46. 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: 174,146 lines of product code
How the estimate is made: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Resolve the 12 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (3), REDACTED (3), REDACTED (2).
Raises the score by about 10 points · Medium effort · REDACTED Scanning
2
Remove unused dependencies, declare unlisted imports explicitly, and demote type-/test-only packages to devDependencies.
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 €370,000 to build again, about 2.5 person-years of work. Its weakest lens is Production Readiness, at 34 (Weak). Production Readiness is about whether the product is ready to run in production and to change without breaking. Because the weakest lens counts most in the score, work on Production Readiness also moves the score most.
Based on: the rebuild estimate · the Production Readiness grade · how much each lens counts
What to do: Start with the Production Readiness actions in Top priorities.
If you do one thing first · First action
Resolve the 12 Leaked secret finding(s) in REDACTED Scanning. Of all the actions in this report, it raises the score most for the work it takes: about 10 points for medium effort, because it clears the 12 REDACTED Scanning findings. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 5.7 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 6% to 13% on every change. The history of the code shows how much it changes: about 288,948 lines over the last 90 days, which is about 1,171,845 lines a year. At that pace, the extra work comes to an estimated 166.9 to 1001.3 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of Watchdog's own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.
Architecture: which parts of the code depend on which
The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.
215 modules, with 146 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; 175 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.
lightrag.chunker.registry uses lightrag.utils, so a change to lightrag.utils can break lightrag.chunker.registry, while a change to lightrag.chunker.registry can't break lightrag.utils.
Position
Below the diagonal: lightrag.chunker.registry uses a module listed above it, which is the healthy direction.
lightrag.parser.docx uses lightrag.parser.docx.drawing_image_extractor, so a change to lightrag.parser.docx.drawing_image_extractor can break lightrag.parser.docx, while a change to lightrag.parser.docx can't break lightrag.parser.docx.drawing_image_extractor.
Position
Below the diagonal: lightrag.parser.docx uses a module listed above it, which is the healthy direction.
lightrag.parser.external._base uses lightrag.parser.base, so a change to lightrag.parser.base can break lightrag.parser.external._base, while a change to lightrag.parser.external._base can't break lightrag.parser.base.
Position
Below the diagonal: lightrag.parser.external._base uses a module listed above it, which is the healthy direction.
lightrag.parser.native_base uses lightrag.parser.base, so a change to lightrag.parser.base can break lightrag.parser.native_base, while a change to lightrag.parser.native_base can't break lightrag.parser.base.
Position
Below the diagonal: lightrag.parser.native_base uses a module listed above it, which is the healthy direction.
lightrag_webui.src.features.retrieval.useQuerySession uses lightrag_webui.src.api.lightrag, so a change to lightrag_webui.src.api.lightrag can break lightrag_webui.src.features.retrieval.useQuerySession, while a change to lightrag_webui.src.features.retrieval.useQuerySession can't break lightrag_webui.src.api.lightrag.
Position
Below the diagonal: lightrag_webui.src.features.retrieval.useQuerySession uses a module listed above it, which is the healthy direction.
lightrag_webui.src.stores uses lightrag_webui.src.api.customization, so a change to lightrag_webui.src.api.customization can break lightrag_webui.src.stores, while a change to lightrag_webui.src.stores can't break lightrag_webui.src.api.customization.
Position
Below the diagonal: lightrag_webui.src.stores uses a module listed above it, which is the healthy direction.
lightrag_webui.src.utils uses lightrag_webui.src.api.lightrag, so a change to lightrag_webui.src.api.lightrag can break lightrag_webui.src.utils, while a change to lightrag_webui.src.utils can't break lightrag_webui.src.api.lightrag.
Position
Below the diagonal: lightrag_webui.src.utils uses a module listed above it, which is the healthy direction.
lightrag.api.routers.document_routes uses lightrag.base, so a change to lightrag.base can break lightrag.api.routers.document_routes, while a change to lightrag.api.routers.document_routes can't break lightrag.base.
Position
Below the diagonal: lightrag.api.routers.document_routes uses a module listed above it, which is the healthy direction.
lightrag.chunker uses lightrag.utils, so a change to lightrag.utils can break lightrag.chunker, while a change to lightrag.chunker can't break lightrag.utils.
Position
Below the diagonal: lightrag.chunker uses a module listed above it, which is the healthy direction.
lightrag.chunker uses lightrag.chunker.registry, so a change to lightrag.chunker.registry can break lightrag.chunker, while a change to lightrag.chunker can't break lightrag.chunker.registry.
Position
Below the diagonal: lightrag.chunker uses a module listed above it, which is the healthy direction.
lightrag.kg.memgraph_impl uses lightrag.types, so a change to lightrag.types can break lightrag.kg.memgraph_impl, while a change to lightrag.kg.memgraph_impl can't break lightrag.types.
Position
Below the diagonal: lightrag.kg.memgraph_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.memgraph_impl uses lightrag.base, so a change to lightrag.base can break lightrag.kg.memgraph_impl, while a change to lightrag.kg.memgraph_impl can't break lightrag.base.
Position
Below the diagonal: lightrag.kg.memgraph_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.milvus_impl uses lightrag.base, so a change to lightrag.base can break lightrag.kg.milvus_impl, while a change to lightrag.kg.milvus_impl can't break lightrag.base.
Position
Below the diagonal: lightrag.kg.milvus_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.mongo_impl uses lightrag.types, so a change to lightrag.types can break lightrag.kg.mongo_impl, while a change to lightrag.kg.mongo_impl can't break lightrag.types.
Position
Below the diagonal: lightrag.kg.mongo_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.mongo_impl uses lightrag.base, so a change to lightrag.base can break lightrag.kg.mongo_impl, while a change to lightrag.kg.mongo_impl can't break lightrag.base.
Position
Below the diagonal: lightrag.kg.mongo_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.neo4j_impl uses lightrag.types, so a change to lightrag.types can break lightrag.kg.neo4j_impl, while a change to lightrag.kg.neo4j_impl can't break lightrag.types.
Position
Below the diagonal: lightrag.kg.neo4j_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.neo4j_impl uses lightrag.base, so a change to lightrag.base can break lightrag.kg.neo4j_impl, while a change to lightrag.kg.neo4j_impl can't break lightrag.base.
Position
Below the diagonal: lightrag.kg.neo4j_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.networkx_impl uses lightrag.types, so a change to lightrag.types can break lightrag.kg.networkx_impl, while a change to lightrag.kg.networkx_impl can't break lightrag.types.
Position
Below the diagonal: lightrag.kg.networkx_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.networkx_impl uses lightrag.base, so a change to lightrag.base can break lightrag.kg.networkx_impl, while a change to lightrag.kg.networkx_impl can't break lightrag.base.
Position
Below the diagonal: lightrag.kg.networkx_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.opensearch_impl uses lightrag.exceptions, so a change to lightrag.exceptions can break lightrag.kg.opensearch_impl, while a change to lightrag.kg.opensearch_impl can't break lightrag.exceptions.
Position
Below the diagonal: lightrag.kg.opensearch_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.opensearch_impl uses lightrag.types, so a change to lightrag.types can break lightrag.kg.opensearch_impl, while a change to lightrag.kg.opensearch_impl can't break lightrag.types.
Position
Below the diagonal: lightrag.kg.opensearch_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.opensearch_impl uses lightrag.base, so a change to lightrag.base can break lightrag.kg.opensearch_impl, while a change to lightrag.kg.opensearch_impl can't break lightrag.base.
Position
Below the diagonal: lightrag.kg.opensearch_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.pgtable_impl uses lightrag.types, so a change to lightrag.types can break lightrag.kg.pgtable_impl, while a change to lightrag.kg.pgtable_impl can't break lightrag.types.
Position
Below the diagonal: lightrag.kg.pgtable_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.pgtable_impl uses lightrag.base, so a change to lightrag.base can break lightrag.kg.pgtable_impl, while a change to lightrag.kg.pgtable_impl can't break lightrag.base.
Position
Below the diagonal: lightrag.kg.pgtable_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.postgres_impl uses lightrag.types, so a change to lightrag.types can break lightrag.kg.postgres_impl, while a change to lightrag.kg.postgres_impl can't break lightrag.types.
Position
Below the diagonal: lightrag.kg.postgres_impl uses a module listed above it, which is the healthy direction.
lightrag.kg.postgres_impl uses lightrag.base, so a change to lightrag.base can break lightrag.kg.postgres_impl, while a change to lightrag.kg.postgres_impl can't break lightrag.base.
Position
Below the diagonal: lightrag.kg.postgres_impl uses a module listed above it, which is the healthy direction.
lightrag.lightrag uses lightrag.operate, so a change to lightrag.operate can break lightrag.lightrag, while a change to lightrag.lightrag can't break lightrag.operate.
Position
Below the diagonal: lightrag.lightrag uses a module listed above it, which is the healthy direction.
lightrag.lightrag uses lightrag.types, so a change to lightrag.types can break lightrag.lightrag, while a change to lightrag.lightrag can't break lightrag.types.
Position
Below the diagonal: lightrag.lightrag uses a module listed above it, which is the healthy direction.
lightrag.lightrag uses lightrag.base, so a change to lightrag.base can break lightrag.lightrag, while a change to lightrag.lightrag can't break lightrag.base.
Position
Below the diagonal: lightrag.lightrag uses a module listed above it, which is the healthy direction.
lightrag_webui.src.features.retrieval uses lightrag_webui.src.api.lightrag, so a change to lightrag_webui.src.api.lightrag can break lightrag_webui.src.features.retrieval, while a change to lightrag_webui.src.features.retrieval can't break lightrag_webui.src.api.lightrag.
Position
Below the diagonal: lightrag_webui.src.features.retrieval uses a module listed above it, which is the healthy direction.
lightrag_webui.src.features.retrieval uses lightrag_webui.src.features.retrieval.useQuerySession, so a change to lightrag_webui.src.features.retrieval.useQuerySession can break lightrag_webui.src.features.retrieval, while a change to lightrag_webui.src.features.retrieval can't break lightrag_webui.src.features.retrieval.useQuerySession.
Position
Below the diagonal: lightrag_webui.src.features.retrieval uses a module listed above it, which is the healthy direction.
lightrag.api.routers uses lightrag.exceptions, so a change to lightrag.exceptions can break lightrag.api.routers, while a change to lightrag.api.routers can't break lightrag.exceptions.
Position
Below the diagonal: lightrag.api.routers uses a module listed above it, which is the healthy direction.
lightrag.api.routers uses lightrag.utils, so a change to lightrag.utils can break lightrag.api.routers, while a change to lightrag.api.routers can't break lightrag.utils.
Position
Below the diagonal: lightrag.api.routers uses a module listed above it, which is the healthy direction.
lightrag.api.routers uses lightrag.base, so a change to lightrag.base can break lightrag.api.routers, while a change to lightrag.api.routers can't break lightrag.base.
Position
Below the diagonal: lightrag.api.routers uses a module listed above it, which is the healthy direction.
lightrag.api.routers uses lightrag.api.routers.document_routes, so a change to lightrag.api.routers.document_routes can break lightrag.api.routers, while a change to lightrag.api.routers can't break lightrag.api.routers.document_routes.
Position
Below the diagonal: lightrag.api.routers uses a module listed above it, which is the healthy direction.
lightrag.api.routers uses lightrag.lightrag, so a change to lightrag.lightrag can break lightrag.api.routers, while a change to lightrag.api.routers can't break lightrag.lightrag.
Position
Below the diagonal: lightrag.api.routers uses a module listed above it, which is the healthy direction.
lightrag.kg uses lightrag.kg.milvus_impl, so a change to lightrag.kg.milvus_impl can break lightrag.kg, while a change to lightrag.kg can't break lightrag.kg.milvus_impl.
Position
Below the diagonal: lightrag.kg uses a module listed above it, which is the healthy direction.
lightrag.kg uses lightrag.kg.opensearch_impl, so a change to lightrag.kg.opensearch_impl can break lightrag.kg, while a change to lightrag.kg can't break lightrag.kg.opensearch_impl.
Position
Below the diagonal: lightrag.kg uses a module listed above it, which is the healthy direction.
lightrag.tools uses lightrag.lightrag, so a change to lightrag.lightrag can break lightrag.tools, while a change to lightrag.tools can't break lightrag.lightrag.
Position
Below the diagonal: lightrag.tools uses a module listed above it, which is the healthy direction.
At a glance — Code Health · 57% · Adequate · gated by D1, D2, X4 ·
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
81
High / Critical
A03:2025 — Software Supply Chain Failures
65
High / Critical
A07:2025 — Authentication Failures
33
High / Critical
A02:2025 — Security Misconfiguration
28
High / Critical
Roadmap
Immediately resolve the twelve leaked secrets in shell and configuration files to secure the codebase. Clean up dependency declarations by removing unused packages and explicitly listing imports to improve maintainability. Enhance security and accessibility by integrating static analysis into the CI pipeline to block regressions and enforcing keyboard operability and accessibility standards in custom controls.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Resolve the 12 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (3), REDACTED (3), REDACTED (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.
Enforce accessibility in the toolchain: add eslint-plugin-jsx-a11y, then assert with your test runner's axe binding (jest-axe, vitest-axe, cypress-axe or @axe-core/playwright) in tests, then gate axe/pa11y/Lighthouse in CI.
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 — 148
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 — 1367
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 — 109
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 14
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. 87 of 87 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); none rely on LLM judgement. 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 — 87 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, 1602 of 1624 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D10 Test Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 561 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 601 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 bun:test run in lightrag_webui/ produced no per-test report (src/features/documentRefreshErrors.test.ts:). 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 bun:test suite in lightrag_webui/ was NOT MEASURED: the bun:test run in lightrag_webui/ produced no per-test report (src/features/documentRefreshErrors.test.ts:). This is OUR limitation, not a defect in the repository, and the suite is excluded from the measurement rather than counted against it.
D14 License Compliance — 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. This repository declares REDACTED, but the licence verdict published here was taken over its Python distribution dependencies. Nothing was read about its npm dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
D19 Documentation Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
D21 Naming Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's deterministic naming rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
D24 Comment Value — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover the language this repository's product is written in, so it had nothing of the product to read. That is a gap in this analyzer's language reach — not a finding about this repository.
D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
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. `lightrag_webui/src/api/lightrag.ts`, `lightrag_webui/src/features/workspace/querySettingsSnapshot.ts` produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
D41 Kernel & Syscall Confinement — 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. K8s-deploy/lightrag/templates/deployment.yaml:3, k8s-deploy/lightrag/templates/statefulset.yaml:4, k8s-deploy/lightrag/values.yaml:42 did not read as a pod spec (a templated manifest such as Helm's that is not YAML until rendered, or a workload whose pod spec this check does not locate), so the seccomp/AppArmor profile in force there was not judged and no row about them can appear on this card.
AC6 Visual & motion safety — 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. Visual & motion safety could not be assessed in this run — the check did not complete, so it is not scored. This is a gap in the analyzer, not a finding about this repository. Engine failure: ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter 'startIndex').
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. User interface: 81 markup document(s) — HTML, Razor, JSX, Vue, Svelte or server templates. Boot: crawled PUBLIC routes only — add a Playwright storageState (e.g. playwright/.auth/user.json) or a test auth-setup to crawl authenticated screens rendered 0/1 surface(s) × 2 renders render failed for http://127.0.0.1:9621: page.goto: net::ERR_CONNECTION_RESET at http://127.0.0.1:9621/
Call log:
- navigating to "http://127.0.0.1:9621/", waiting until "load"
.
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.
C3 Audit Trail — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'sqlite3' is imported (lightrag/tools/chunk_tracking_repair.py:26), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
C4 Data Retention — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'sqlite3' is imported (lightrag/tools/chunk_tracking_repair.py:26), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
C5 Data-Subject Rights — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 'sqlite3' is imported (lightrag/tools/chunk_tracking_repair.py:26), but no entity, schema, table or model declaration this check reads was found beside it, so whether personal data is stored could not be decided.
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.
M4 Documentation accuracy — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9). Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
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. 1 further occurrence(s) are not listed individually; the score already reflects all 41.
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. 25 further occurrence(s) are not listed individually; the score already reflects all 65.
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. 375 further occurrence(s) are not listed individually; the score already reflects all 415.
Repo exclusion declarations: 1 pattern(s) declared (.gitattributes linguist-generated/vendored, .editorconfig generated_code) excluded 0 source file(s) from code-quality scoring. Declarations are the repo's own visible statement that a tree is machine-written or vendored — auditable in any diff, honored by GitHub the same way.
Limitations & what we did not check
Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.
Per-dimension blind spots
For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.
D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
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 publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
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.
D40 Network Egress Confinement: Egress confinement is read from committed Kubernetes manifests — a policy applied out-of-band (cluster-default deny, a service mesh, or a cloud firewall/security group off-repo) is invisible, and a present NetworkPolicy is declared config, not proof the cluster admission-controller actually enforces it at runtime.
D41 Kernel & Syscall Confinement: Syscall/MAC confinement is read from committed manifests — a profile applied by a cluster-wide PodSecurity default or a mutating webhook off-repo isn't seen, and a declared seccomp/AppArmor profile is config presence, not proof the node's kernel actually loaded and enforced it.
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.
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".
P5 DR & Backup: Backup/restore and disaster-recovery readiness is judged from in-repo evidence — a config that exists is not a tested restore, so the absence of positive evidence is reported as "not evidenced", never scored as present.
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.
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.
+ 223 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 1 body over 120 down to 120 or less in Cyclomatic Complexity — start with DocumentManager.DocumentManager (cyclomatic 152). — Refactoring it lifts Cyclomatic Complexity from 2.0 to about 2.5/10.
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.
+ 378 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 45 bodies over 60 down to 60 or less in Cognitive Complexity — start with paragraph_semantic._merge_small_blocks (cognitive 177), operate._merge_edges_then_upsert (cognitive 173), LightRAG._purge_derived_kg_contributions (cognitive 159). — 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 45 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 Classes8.0 / 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 48 FileTooLong finding(s) in God Classes — start with ir_builder.py (2), REDACTED, pipeline.py. — One of this dimension's main actionable groups (48 warning-level).
Resolve the 24 FunctionTooLong finding(s) in God Classes — start with useQuerySession.ts (2), DocumentManager.tsx, useLightragGraph.tsx. — One of this dimension's main actionable groups (24 warning-level).
Resolve the 3 TooManyMethods finding(s) in God Classes — start with pipeline.py, REDACTED, migrate_llm_cache.py. — One of this dimension's main actionable groups (3 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.
308 duplicated block group(s) detected. A further 23 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 14 of the 331 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.
+ 187 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 14 Duplicated block (13 lines × 2) finding(s) in Code Duplication — start with opensearch_impl.py (3), operate.py (3), memgraph_impl.py. — One of this dimension's main actionable groups (14 warning-level).
Resolve the 11 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with REDACTED (2), paragraph_semantic.py, opensearch_impl.py. — One of this dimension's main actionable groups (11 warning-level).
Resolve the 9 Duplicated block (15 lines × 2) finding(s) in Code Duplication — start with opensearch_impl.py (2), redis_impl.py (2), document_routes.py. — One of this dimension's main actionable groups (9 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 · Coupling10.0 / 10Exemplary✓ 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.
2 production modules (npm+Python), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 0 module(s) off the main sequence.
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
Resolve the 1 Low cohesion finding(s) in Cohesion (LCOM4) — start with llm_roles.py. — One of this dimension's main actionable groups (1 warning-level).
Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D9 · Test 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.
7870 test methods: 7794 unit, 44 integration, 0 BDD, 32 e2e. The JavaScript/TypeScript suite contributes 561 `it`/`test` case(s) across 68 test file(s) declaring at least one; its tier split is read from package names and paths only. The Python suite contributes 7309 test function(s) across 540 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 Quality10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
0 skipped, 0 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 561 tests. Measured on the JavaScript/TypeScript suite only — at least 601 test source file(s) (.py) went unread, so its test quality is unmeasured and is not in these counts.
What it measures: Whether dependencies are current, secure, and not bloated.
Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.
0 outdated, 0 yanked pinned Python distributions. 1 of 44 shipped distributions were graded against pypi.org (0 not published there, 43 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, REDACTED, Pipfile.lock, pdm.lock), so a lock-resolved install is outside this verdict. Known CVEs in this dependency graph are D30's question.
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.
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.
Resolve the 12 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (3), REDACTED (3), REDACTED (2). — One of this dimension's main actionable groups (12 issue-level).
Enforce REDACTED Scanning in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d13_recommendation.md · top locations in Appendix A, every location in findings.md.
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 182 shipped Python distribution(s) use a banned license. Licences were resolved from PyPI over the distributions a consumer installs — this repository's 44 declared runtime requirement(s) closed transitively over each distribution's published `requires_dist` (138 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. 8 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 2 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. This repository publishes itself under MIT, which is its own choice and is not judged here. ★ COVERAGE OF THIS VERDICT: it grades this repository's Python distribution dependencies and nothing else. The repository also declares REDACTED, and the licences of those dependencies were NOT read by this pass — a gap in this engine's coverage, not a statement about them. So this result says the graded closure carries no banned licence; it does NOT say this repository's licensing is clear.
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: lightrag/lightrag.py (131×84=11004); lightrag/operate.py (78×90=7020); lightrag/pipeline.py (94×74=6956) Repeated repair below the complexity floor: lightrag/base.py (28 of 47 changes were fixes); lightrag/exceptions.py (16 of 26 changes were fixes); REDACTED (14 of 26 changes were fixes)
Resolve the 59 Hotspot finding(s) in Churn × Complexity Hotspots — start with lightrag.py, operate.py, pipeline.py. — One of this dimension's main actionable groups (59 warning-level).
Resolve the 39 Repeated repair finding(s) in Churn × Complexity Hotspots — start with client.py (2), base.py, exceptions.py. — One of this dimension's main actionable groups (39 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 Factor6.9 / 10Adequate✓ 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.
71 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is lightrag/parser/docx/smart_heading/title_block.py. Counted over 233 of the 340 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Off-boarding risk: anonymized user #1
Further sole-owners (lower concentration)
What to do
Resolve the 1 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).
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.
5 deducted task-comment markers across 174146 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
TodoComment · ×5lightrag/lightrag.py:715
What to do
Resolve the 5 TodoComment finding(s) in Explicit Debt — start with lightrag.py (4), REDACTED. — One of this dimension's main actionable groups (5 warning-level).
Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.
1 of 1 documentation facets pass in full. 66 document(s) read across 1 unit(s).
✓ On the Gold path — maintain.
Detailed fixes: d19_recommendation.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.
2 of 2 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.
20 finding(s): 0 critical, 20 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.
REDACTED
REDACTED
REDACTED
What to do
Resolve the 12 REDACTED finding(s) in Secrets (history) — start with REDACTED (4), REDACTED (2), REDACTED (2). — One of this dimension's main actionable groups (12 issue-level).
Resolve the 8 High secret finding(s) in Secrets (history) — start with REDACTED (2), REDACTED (2), REDACTED (2). — One of this dimension's main actionable groups (8 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).
81 finding(s): 0 critical, 59 high, 22 medium, 0 low. 43 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 11 file(s) — `REDACTED`, `k8s-deploy/lightrag/templates/pvc.yaml`, `k8s-deploy/lightrag/templates/secret.yaml`, `k8s-deploy/lightrag/templates/service.yaml`, `k8s-deploy/lightrag/templates/statefulset.yaml`, … (+6 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
+ 8 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 4 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2), REDACTED, REDACTED. — One of this dimension's main actionable groups (4 issue-level).
Resolve the 4 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (3), REDACTED. — One of this dimension's main actionable groups (4 issue-level).
No action in Static Analysis (SAST) — all 43 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 (43 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.
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 27 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (14), REDACTED (12), REDACTED. — One of this dimension's main actionable groups (27 issue-level).
Resolve the 5 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (5). — One of this dimension's main actionable groups (5 issue-level).
Resolve the 2 Critical vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 issue-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
Resolve the 18 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (5), REDACTED (5), REDACTED (4). — One of this dimension's main actionable groups (18 warning-level).
Resolve the 7 High IaC finding(s) in IaC & Container Security — start with REDACTED (4), REDACTED, REDACTED. — One of this dimension's main actionable groups (7 issue-level).
Resolve the 3 Low IaC finding(s) in IaC & Container Security — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (3 recommendation-level).
Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.
Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.
6 of 233 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is lightrag_webui/src/components/ui/Select.tsx. Counted over 233 of the 340 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Resolve the 1 Change coupling finding(s) in Change Coupling — start with AppSettings.tsx. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.
Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.
Resolve the 5 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (5 warning-level).
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the repository publishes a coordinated-vulnerability-disclosure policy (SECURITY.md or security.txt) with a reporting contact, so finders know how to report a vulnerability. Presence of a policy file with a contact, not whether the policy is adequate or honoured.
Method: Vulnerability-disclosure policy read deterministically from the repo: a SECURITY.md (root/.github/docs) or .well-known/security.txt / security.txt, regex-checked for a reporting contact (email / URL / mailto). Present + contact → 10; present without a contact → 4; NotApplicable when no policy file exists (it may live off-repo). Detects the policy file's presence + contact, not its adequacy.
What it measures: Whether Kubernetes workloads restrict network EGRESS with a NetworkPolicy (or Cilium policy), limiting where a compromised pod can send data or reach a command-and-control server. Presence of committed egress-restricting policy, not runtime enforcement.
Method: Deterministic YAML-manifest inspection (no external tool, no Roslyn — language-agnostic): Kubernetes workloads gate applicability; credits a NetworkPolicy / Cilium policy that restricts egress (policyTypes: [Egress] / egress rules). Reward-leaning (neutral floor climbing to 10, never a deduction — baseline misconfigs stay with D31). Deterministic.
What it measures: Whether Kubernetes workloads confine the kernel boundary — a seccomp profile (RuntimeDefault/Localhost) plus an AppArmor/SELinux mandatory-access-control layer — shrinking the syscall attack surface a container escape would use. Presence of committed confinement config, not runtime enforcement.
Method: Deterministic YAML-manifest inspection (no external tool, no Roslyn): on Kubernetes workloads, credits a seccomp profile (RuntimeDefault/Localhost) and an AppArmor/SELinux MAC layer. Reward-leaning (neutral floor climbing to 10); NotApplicable without workloads. Deterministic.
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 44 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.
✓ On the Gold path — maintain.
Detailed fixes: d44_recommendation.md.
Do you agree with this assessment?
Frontend & cross-cutting dimensions
R = React/JS · M = Maturity · P = Readiness.
AC1 · Text alternatives10.0 / 10Exemplary○ Nothing flagged
Other · Accessibility — Whether non-text content carries a text alternative — img/area/input[type=image] have alt, a meaningful svg has a title or aria-label, video has a captions track, and object/embed/canvas have a name or fallback content. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: every img/area/input[type=image] checked for alt, svg[role=img] for a title/aria-label, video for a captions <track>. Components skipped, spreads suppressed. Deterministic, hard fact per element.
Coverage: Population: image/media elements — img, area, input[type=image], svg, video, object, embed, canvas — across the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and dynamic-attribute elements are skipped. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is NOT read by any producer, so it contributes no element to this population; where such a frontend is present the card discloses it as an analyzer gap rather than scoring around it.
Do you agree with this assessment?
AC2 · Forms & labels4.4 / 10Weak✓ 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 <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id. (×5) — lightrag_webui/src/components/AppSettings.tsx:56, lightrag_webui/src/components/AppSettings.tsx:79, lightrag_webui/src/components/graph/Settings.tsx:417, …
This UI-library field component has no label / aria-label / aria-labelledby / id, and nothing it renders carries one either (a name prop is the form-submission key, not a label). The text inside it does not stand in for one: these compound APIs render a trigger with role="combobox" (or role="button"), and those roles take their name from the AUTHOR, not from their content — so the words on screen never reach the accessibility tree as a name. Name it 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. (×4) — lightrag_webui/src/components/AppSettings.tsx:57, lightrag_webui/src/components/AppSettings.tsx:80, lightrag_webui/src/components/ui/PaginationControls.tsx:164, …
This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it. (×2) — lightrag_webui/src/components/graph/PropertyEditDialog.tsx:120, lightrag_webui/src/components/graph/PropertyEditDialog.tsx:128
A button with no text and no aria-label has no accessible name. Add visible text or an aria-label (an icon-only button still needs one). — lightrag_webui/src/components/ui/UserPromptInputWithHistory.tsx:150
A link with no text, aria-label or labelled child (e.g. an icon-only link) has no accessible name, so assistive tech can't say where it goes. Add visible text or an aria-label. (×2) — lightrag_webui/src/features/SiteHeader.tsx:140, lightrag_webui/src/features/SiteHeader.tsx:146
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.
Other · Accessibility — Whether pages declare a language (well-formed BCP-47) and a non-empty title, expose exactly one main landmark and a sane heading order with non-empty headings, keep zoom enabled, title their iframes, give data tables header cells, and avoid meta-refresh. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: html lang, document <title>, a main landmark and heading order on full documents only, plus zoom-disabling viewports, untitled iframes and meta-refresh anywhere. Deterministic, per structural checkpoint.
Coverage: Population: the PARSED MARKUP documents (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx). The page-level checks — lang, title, single main landmark — fire ONCE PER FULL DOCUMENT (an <html> root) and never on a partial or component fragment, so a repo of fragments is assessed only on the per-element checks (heading order, table headers, iframe titles, meta-refresh, zoom). Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
Other · Accessibility — Whether 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".
A click handler on a plain element isn't keyboard-operable. Use a <button>, or add role + tabIndex={0} + a key handler. (×2) — lightrag_webui/src/components/retrieval/ChatMessage.tsx:257, lightrag_webui/src/components/status/StatusIndicator.tsx:27
This <div> binds mouse-enter and mouse-leave and nothing else — no click, no key handler, no focus handler, and no tabIndex={0}, so it cannot even take focus. A keyboard user cannot hover, so whatever the pair reveals or highlights is reachable with a mouse only. Bind the same state to focus/blur as well, and add tabIndex={0}="0" so the element can receive that focus. — lightrag_webui/src/components/ui/UserPromptInputWithHistory.tsx:136
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.
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 81 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 your test runner's axe binding (jest-axe, vitest-axe, cypress-axe or @axe-core/playwright) in tests, then gate axe/pa11y/Lighthouse in CI.
Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.
Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.
Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.
What to do
The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
Other · Architecture — Whether the codebase has a recognisable, scale-appropriate structure (a named architectural style, or modular enough for its size) rather than being an ad-hoc ball of mud.
Method: Roslyn plus csproj analysis: architecture style detection (DDD, clean, vertical-slice, CQRS) and structure fitness for repo size. Deterministic.
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.
Other · Architecture — Whether feature slices stay independent (no direct cross-slice references) — the discipline that makes vertical-slice architecture pay off.
Method: Roslyn scan (vertical-slice gated): feature slices resolved from namespaces (.Features.*, .Slices.*) or project names; cross-slice type references detected. Deterministic, traceable.
`WorkspaceQueryView` (slice 'workspace') depends on `useQuerySession` from slice 'retrieval'. — lightrag_webui/src/features/workspace/WorkspaceQueryView.tsx:43
`WorkspaceQueryView` (slice 'workspace') depends on `prepareQueryInput` from slice 'retrieval'. — lightrag_webui/src/features/workspace/WorkspaceQueryView.tsx:53
`WorkspaceQueryView` (slice 'workspace') depends on `SUPPORTED_QUERY_MODES` from slice 'retrieval'. — lightrag_webui/src/features/workspace/WorkspaceQueryView.tsx:56
`WorkspaceQueryView` (slice 'workspace') depends on `MessageList` from slice 'retrieval'. — lightrag_webui/src/features/workspace/WorkspaceQueryView.tsx:70
`WorkspaceQueryView` (slice 'workspace') depends on `QueryComposer` from slice 'retrieval'. — lightrag_webui/src/features/workspace/WorkspaceQueryView.tsx:77
What to do
Keep slices independent: share cross-slice needs via an explicit contract/shared-kernel, not direct references between slices.
Do you agree with this assessment?
C2 · Access Controls7.0 / 10Strong✓ Tool-verified
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.
Authorization IS enforced here (by route guards, auth middleware or checks that refuse a caller) — this is NOT a claim that endpoints are unprotected. What's missing is a NAMED rule set: who may do what is encoded inline where it is checked, so the rules can't be listed, reviewed or tested apart from the code that applies them. Recommendation, not a defect.
What to do
Name the access rules — DRF permission classes, django-guardian or django-rules permissions, a casbin or oso policy, or roles and permissions declared once — and consult them where access is checked (permission_classes, @permission_required, Depends), so the rule set is reviewable and testable on its own.
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 an 'Architecture' / 'How it works' section to the root README — the high-level shape.
Add a README to the 1 of 1 project(s) that lack one — worth up to 2 pts.
Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.
Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.
No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
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 repo is organised deliberately — src/test separation and consistent project naming.
Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.
Production code isn't grouped under a src/ folder — it's spread across several top-level directories, so there's no one place that says 'this is the product'.
What to do
Group production code under src/ (or split deliberately, e.g. backend/ + frontend/) so production and tooling code aren't mixed at the root.
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.
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).
Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.
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 29919 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.
Dependabot is configured but does not watch `npm` — add that `package-ecosystem` entry to REDACTED so those dependencies get the same automatic update and advisory pressure as the ones it already covers.
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.
Do you agree with this assessment?
P5 · DR & Backup7.0 / 10Strong✓ Tool-verified
Readiness · Readiness — Whether disaster recovery is planned and codified — backups, geo-recovery, RTO/RPO, persistence guarantees — from IaC + container manifests + docs, never the live cloud.
Method: Filesystem scan: disaster recovery, backup, geo-recovery, RTO/RPO, persistence guarantees from IaC, manifests, and docs. Exhaustive, deterministic, never a live environment.
What to do
Document RTO/RPO and a tested restore procedure (a backup config alone isn't disaster recovery).
Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.
Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.
No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
What to do
Keep a changelog (e.g. Keep-a-Changelog) recording what shipped in each release.
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.
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.
`_send_request` is async and calls requests.post — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — examples/unofficial-sample/lightrag_cloudflare_demo.py:53
What to do
Python: await the async equivalent (asyncio.sleep, an async HTTP client such as httpx.AsyncClient or aiohttp, asyncio.create_subprocess_exec), or move the blocking call off the loop with `await asyncio.to_thread(...)`; never call asyncio.run inside a coroutine — await the coroutine.
Do you agree with this assessment?
R1 · Type Safety10.0 / 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.
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.
lightrag_webui/src/components/documents/ClearDocumentsDialog.tsx:22 · lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:21 — the two spans are one implementation copied and then locally edited — 607 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. — lightrag_webui/src/components/documents/ClearDocumentsDialog.tsx:22
lightrag_webui/src/components/ui/AsyncSearch.tsx:132 · lightrag_webui/src/components/ui/AsyncSelect.tsx:103 — the two spans are one implementation copied and then locally edited — 336 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. — lightrag_webui/src/components/ui/AsyncSearch.tsx:132
lightrag_webui/src/components/ui/AsyncSearch.tsx:15 · lightrag_webui/src/components/ui/AsyncSelect.tsx:17 — the two spans are one implementation copied and then locally edited — 318 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. — lightrag_webui/src/components/ui/AsyncSearch.tsx:15
lightrag_webui/src/components/graph/PropertiesView.tsx:272 · lightrag_webui/src/components/graph/PropertiesView.tsx:369 — the two spans are one implementation copied and then locally edited — 260 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. — lightrag_webui/src/components/graph/PropertiesView.tsx:272
lightrag_webui/src/AppRouter.tsx:20 · lightrag_webui/src/WorkspaceAppRouter.tsx:32 — the two spans are one implementation copied and then locally edited — 174 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. — lightrag_webui/src/AppRouter.tsx:20
lightrag_webui/src/components/ui/PaginationControls.tsx:140 · lightrag_webui/src/components/ui/PaginationControls.tsx:219 — the two spans are one implementation copied and then locally edited — 200 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. — lightrag_webui/src/components/ui/PaginationControls.tsx:140
lightrag_webui/src/components/retrieval/QuerySettings.tsx:246 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:286 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:326 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:366 · +1 more site(s) not listed — 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. — lightrag_webui/src/components/retrieval/QuerySettings.tsx:246
lightrag_webui/src/components/retrieval/QuerySettings.tsx:470 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:496 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/components/retrieval/QuerySettings.tsx:470
lightrag_webui/src/features/RetrievalView.tsx:37 · lightrag_webui/src/features/workspace/WorkspaceQueryView.tsx:46 — 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. — lightrag_webui/src/features/RetrievalView.tsx:37
lightrag_webui/src/stores/state.ts:384 · lightrag_webui/src/stores/state.ts:448 — the two spans are one implementation copied and then locally edited — 94 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. — lightrag_webui/src/stores/state.ts:384
lightrag_webui/src/components/retrieval/ChatMessage.tsx:300 · lightrag_webui/src/components/retrieval/ChatMessage.tsx:410 — 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. — lightrag_webui/src/components/retrieval/ChatMessage.tsx:300
lightrag_webui/src/features/workspace/WorkspaceEmptyState.tsx:19 · lightrag_webui/src/features/workspace/WorkspaceWelcome.tsx:130 — the two spans are one implementation copied and then locally edited — 65 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. — lightrag_webui/src/features/workspace/WorkspaceEmptyState.tsx:19
lightrag_webui/src/components/graph/GraphLabels.tsx:93 · lightrag_webui/src/components/graph/GraphLabels.tsx:194 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/components/graph/GraphLabels.tsx:93
lightrag_webui/src/components/retrieval/QuerySettings.tsx:183 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:275 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:315 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:355 · +1 more site(s) not listed — 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. — lightrag_webui/src/components/retrieval/QuerySettings.tsx:183
lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:145 · lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:159 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:145
lightrag_webui/src/components/retrieval/QuerySettings.tsx:449 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:522 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/components/retrieval/QuerySettings.tsx:449
lightrag_webui/src/components/ui/Select.tsx:33 · lightrag_webui/src/components/ui/Select.tsx:47 — 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. — lightrag_webui/src/components/ui/Select.tsx:33
lightrag_webui/src/features/DocumentManager.tsx:1735 · lightrag_webui/src/features/DocumentManager.tsx:1748 — 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. — lightrag_webui/src/features/DocumentManager.tsx:1735
lightrag_webui/src/features/retrieval/MessageList.tsx:314 · lightrag_webui/src/features/retrieval/MessageList.tsx:342 — the two spans are one implementation copied and then locally edited — 58 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. — lightrag_webui/src/features/retrieval/MessageList.tsx:314
lightrag_webui/src/components/retrieval/QuerySettings.tsx:133 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:160 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:190 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:242 · +8 more site(s) not listed — all 12 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. — lightrag_webui/src/components/retrieval/QuerySettings.tsx:133
lightrag_webui/src/components/retrieval/QuerySettings.tsx:166 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:446 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:467 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:493 · +1 more site(s) not listed — 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. — lightrag_webui/src/components/retrieval/QuerySettings.tsx:166
lightrag_webui/src/features/DocumentManager.tsx:1578 · lightrag_webui/src/features/DocumentManager.tsx:1590 · lightrag_webui/src/features/DocumentManager.tsx:1602 · lightrag_webui/src/features/DocumentManager.tsx:1614 · +1 more site(s) not listed — 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. — lightrag_webui/src/features/DocumentManager.tsx:1578
lightrag_webui/src/features/retrieval/QueryComposer.tsx:80 · lightrag_webui/src/features/retrieval/QueryComposer.tsx:111 — the two spans are one implementation copied and then locally edited — 88 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. — lightrag_webui/src/features/retrieval/QueryComposer.tsx:80
lightrag_webui/src/utils/clipboard.ts:66 · lightrag_webui/src/utils/clipboard.ts:111 — 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. — lightrag_webui/src/utils/clipboard.ts:66
lightrag_webui/src/components/graph/ZoomControl.tsx:74 · lightrag_webui/src/components/graph/ZoomControl.tsx:90 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/components/graph/ZoomControl.tsx:74
lightrag_webui/src/components/graph/Settings.tsx:349 · lightrag_webui/src/components/graph/Settings.tsx:365 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/components/graph/Settings.tsx:349
lightrag_webui/src/components/status/StatusCard.tsx:201 · lightrag_webui/src/components/status/StatusCard.tsx:210 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/components/status/StatusCard.tsx:201
lightrag_webui/src/components/ui/Alert.tsx:26 · lightrag_webui/src/components/ui/Card.tsx:5 · lightrag_webui/src/components/ui/Card.tsx:23 · lightrag_webui/src/components/ui/Card.tsx:41 · +1 more site(s) not listed — the 5 copies are spread across 3 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lightrag_webui/src/components/ui/Alert.tsx:26
lightrag_webui/src/components/graph/PropertiesView.tsx:191 · lightrag_webui/src/components/graph/PropertyEditDialog.tsx:43 — 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. — lightrag_webui/src/components/graph/PropertiesView.tsx:191
lightrag_webui/src/components/ui/Card.tsx:6 · lightrag_webui/src/components/ui/Card.tsx:24 · lightrag_webui/src/components/ui/Card.tsx:42 · lightrag_webui/src/components/ui/Table.tsx:33 — the 4 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. — lightrag_webui/src/components/ui/Card.tsx:6
lightrag_webui/src/components/ui/ScrollArea.tsx:19 · lightrag_webui/src/components/ui/Select.tsx:28 · lightrag_webui/src/components/ui/Select.tsx:42 · lightrag_webui/src/components/ui/Select.tsx:56 · +2 more site(s) not listed — the 6 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. — lightrag_webui/src/components/ui/ScrollArea.tsx:19
lightrag_webui/src/features/retrieval/useQuerySession.ts:312 · lightrag_webui/src/features/retrieval/useQuerySession.ts:517 — the two spans are one implementation copied and then locally edited — 60 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. — lightrag_webui/src/features/retrieval/useQuerySession.ts:312
lightrag_webui/src/hooks/useLightragGraph.tsx:255 · lightrag_webui/src/hooks/useLightragGraph.tsx:286 — 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. — lightrag_webui/src/hooks/useLightragGraph.tsx:255
lightrag_webui/src/hooks/useLightragGraph.tsx:817 · lightrag_webui/src/hooks/useLightragGraph.tsx:827 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/hooks/useLightragGraph.tsx:817
lightrag_webui/src/components/graph/GraphControl.tsx:332 · lightrag_webui/src/hooks/useLightragGraph.tsx:776 — the two spans are one implementation copied and then locally edited — 51 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. — lightrag_webui/src/components/graph/GraphControl.tsx:332
lightrag_webui/src/components/graph/PropertiesView.tsx:389 · lightrag_webui/src/components/graph/PropertiesView.tsx:396 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — lightrag_webui/src/components/graph/PropertiesView.tsx:389
lightrag_webui/src/components/ui/Progress.tsx:6 · lightrag_webui/src/components/ui/ScrollArea.tsx:6 · lightrag_webui/src/components/ui/Select.tsx:13 · lightrag_webui/src/components/ui/Select.tsx:105 — the 4 copies are spread across 3 files, 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. — lightrag_webui/src/components/ui/Progress.tsx:6
lightrag_webui/src/components/graph/GraphControl.tsx:28 · lightrag_webui/src/components/graph/GraphControl.tsx:34 · lightrag_webui/src/components/graph/PropertiesView.tsx:15 · lightrag_webui/src/components/graph/Settings.tsx:183 · +5 more site(s) not listed — the 6 copies are spread across 3 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. — lightrag_webui/src/components/graph/GraphControl.tsx:28
lightrag_webui/src/components/retrieval/ChatMessage.tsx:503 · lightrag_webui/src/components/retrieval/ChatMessage.tsx:594 · lightrag_webui/src/components/retrieval/ChatMessage.tsx:607 — 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. — lightrag_webui/src/components/retrieval/ChatMessage.tsx:503
lightrag_webui/src/hooks/useLightragGraph.tsx:838 · lightrag_webui/src/hooks/useLightragGraph.tsx: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. — lightrag_webui/src/hooks/useLightragGraph.tsx:838
What to do
Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
React / JS · Architecture — Conformance to the detected frontend architecture layout (feature-sliced / layered src) plus cross-package deep-import rules (D-386).
Method: Conformance to the detected frontend layout (feature-sliced / layered src) plus cross-package deep-import rules, over the module graph. Deterministic.
lightrag_webui/src/components/retrieval/ChatMessage.tsx:17 imports react-syntax-highlighter/dist/cjs/styles/prism, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — lightrag_webui/src/components/retrieval/ChatMessage.tsx:17
What to do
Fix the listed violations: import through public entries (package exports / slice index), never reach into another layer or package's internals.
React / JS · Code Health — Per-function cyclomatic/cognitive complexity from the token-level function scanner (D-386) — real branching, not a regex heuristic.
Method: Per-function cyclomatic/cognitive complexity from a token-level function scanner (real branching, not a regex heuristic), computed over every frontend function. Deterministic.
DocumentManager has cyclomatic complexity 54 and cognitive complexity 53; 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. — lightrag_webui/src/features/DocumentManager.tsx:381
handleNodeExpand has cyclomatic complexity 52 and cognitive complexity 68; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lightrag_webui/src/hooks/useLightragGraph.tsx:681
ChatMessage has cyclomatic complexity 44 and cognitive complexity 38; 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. — lightrag_webui/src/components/retrieval/ChatMessage.tsx:57
handleSave has cyclomatic complexity 38 and cognitive complexity 65; 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. — lightrag_webui/src/components/graph/EditablePropertyRow.tsx:96
(anonymous) has cyclomatic complexity 27 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. — lightrag_webui/src/features/retrieval/useQuerySession.ts:248
migrateLegacySettingsState has cyclomatic complexity 26 and cognitive complexity 29; 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. — lightrag_webui/src/migrations/legacySettingsChain.ts:32
(anonymous) has cyclomatic complexity 24 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. — lightrag_webui/src/features/DocumentManager.tsx:771
(anonymous) has cyclomatic complexity 23 and cognitive complexity 39; 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. — lightrag_webui/src/components/documents/UploadDocumentsDialog.tsx:100
(anonymous) has cyclomatic complexity 22 and cognitive complexity 21; 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. — lightrag_webui/src/components/retrieval/ChatMessage.tsx:480
runSettingsStorageSplitMigration has cyclomatic complexity 21 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 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. — lightrag_webui/src/migrations/splitSettingsStorage.ts:554
check has cyclomatic complexity 20 and cognitive complexity 36; 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. — lightrag_webui/src/stores/state.ts:88
updateAssistantMessage has cyclomatic complexity 20 and cognitive complexity 18; 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. — lightrag_webui/src/features/retrieval/useQuerySession.ts:333
(anonymous) has cyclomatic complexity 19 and cognitive complexity 24; 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. — lightrag_webui/src/features/DocumentManager.tsx:115
AsyncSelect has cyclomatic complexity 18 and cognitive complexity 13; 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. — lightrag_webui/src/components/ui/AsyncSelect.tsx:74
(anonymous) has cyclomatic complexity 17 and cognitive complexity 21; 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. — lightrag_webui/src/components/status/StatusCard.tsx:59
PipelineStatusDialog has cyclomatic complexity 17 and cognitive complexity 16; 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. — lightrag_webui/src/components/documents/PipelineStatusDialog.tsx:25
(anonymous) has cyclomatic complexity 17 and cognitive complexity 15; 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. — lightrag_webui/src/components/graph/GraphControl.tsx:374
_classifyStreamError has cyclomatic complexity 17 and cognitive complexity 14; 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. — lightrag_webui/src/api/lightrag.ts:802
generateBundle has cyclomatic complexity 16 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 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. — lightrag_webui/vite.config.ts:100
(anonymous) has cyclomatic complexity 16 and cognitive complexity 19; 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. — lightrag_webui/src/hooks/useLightragGraph.tsx:248
What to do
Break down the listed branch-heavy functions; aim P95 cyclomatic ≤ 5.
Do you agree with this assessment?
R3 · Large Files7.1 / 10Strong✓ Tool-verified
React / JS · Code Health — How many source files exceed the large-file threshold.
Method: Components/modules exceeding the large-file threshold, counted exhaustively across the frontend source tree. Deterministic.
lightrag_webui/src/features/DocumentManager.tsx has 1693 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/features/DocumentManager.tsx:1
lightrag_webui/src/api/lightrag.ts has 1272 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/api/lightrag.ts:1
lightrag_webui/src/hooks/useLightragGraph.tsx has 1040 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/hooks/useLightragGraph.tsx:1
lightrag_webui/src/components/retrieval/ChatMessage.tsx has 656 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/components/retrieval/ChatMessage.tsx:1
lightrag_webui/src/migrations/splitSettingsStorage.ts has 639 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/migrations/splitSettingsStorage.ts:1
lightrag_webui/src/features/retrieval/useQuerySession.ts has 628 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/features/retrieval/useQuerySession.ts:1
lightrag_webui/src/components/retrieval/QuerySettings.tsx has 521 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/components/retrieval/QuerySettings.tsx:1
lightrag_webui/src/components/graph/GraphControl.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. — lightrag_webui/src/components/graph/GraphControl.tsx:1
lightrag_webui/src/stores/state.ts has 456 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/stores/state.ts:1
lightrag_webui/src/components/ui/FileUploader.tsx has 427 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/components/ui/FileUploader.tsx:1
lightrag_webui/src/components/graph/Settings.tsx has 410 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lightrag_webui/src/components/graph/Settings.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.1 / 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. (×14) — lightrag_webui/src/components/ui/NumberInput.tsx:1, lightrag_webui/src/AppRouter.tsx:1, lightrag_webui/src/WorkspaceAppRouter.tsx:1, …
What to do
Add tests that import the unreached modules (directly or through their public entry).
Do you agree with this assessment?
R6 · Tooling10.0 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each REDACTED 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: REDACTED scanned for test/lint/typecheck script wiring. Deterministic presence check.
Do you agree with this assessment?
R7 · Dead Code9.5 / 10Exemplary✓ 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 10 application, 6 tooling and 76 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 (10 application, 6 tooling, 76 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 (×7) — lightrag_webui/src/components/ui/NumberInput.tsx, lightrag_webui/src/components/LanguageToggle.tsx, lightrag_webui/src/components/ThemeToggle.tsx, …
no import path from any entry point (10 application, 6 tooling, 76 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (lightrag_webui/src/components/ui/TabContent.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — lightrag_webui/src/contexts/useTabVisibility.ts
Nothing imports this binding — it is safe to review for removal. (×2) — lightrag_webui/src/utils/clipboard.ts:178, lightrag_webui/src/utils/clipboard.ts:188
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.
Imported but not declared in any reachable REDACTED — installs work only by hoisting accident. — lightrag_webui/src/components/graph/LayoutsControl.tsx:6
Imported only as a TYPE and declared in no reachable REDACTED. The import is erased at compile time, so nothing is installed and no runtime resolution depends on it — but type-checking a clean clone will fail. Declare the typings it resolves through (or the package itself) in the owning REDACTED. (×2) — lightrag_webui/src/utils/remarkFootnotes.ts:3, lightrag_webui/src/utils/remarkFootnotes.ts:2
Declared in REDACTED 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. (×3)
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.
Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.
Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.
Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.
Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.
Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.
Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.
Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X17 · Uncapped recursion over a caller-supplied document2.7 / 10Weak✓ Tool-verified
Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.
Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.
`extract_content_list_from_payload` is public and takes `payload: Any` from its caller, and it calls itself at line 1402 (`extract_content_list_from_payload`) with a piece of `payload` (and at line 1406, line 1412) — and nowhere in `extract_content_list_from_payload` 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 `extract_content_list_from_payload` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — REDACTED:1402
`payloads_equal` is public and takes `a: Any` from its caller, and it calls itself at line 140 (`payloads_equal`) with a piece of `a` (and at line 143) — and nowhere in `payloads_equal` 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 `payloads_equal` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — lightrag/tools/migrate_graph_storage.py:140
What to do
Each finding names the externally-callable member that accepts the document and the self-call that descends, and states that no depth parameter or counter exists anywhere in the walk. Confirm from the two, then thread a depth argument through the walk and reject documents past a fixed maximum, or rewrite it with an explicit stack.
Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.
Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.
Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether async functions that make a cancellable request accept or pass on an AbortSignal (adoption curve).
Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.
Only 5/27 async functions that make a cancellable request (fetch, axios, ky, ofetch) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
`silentRefreshGuestToken` awaits `axios.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axios.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:402
`queryGraphs` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:598
`getGraphLabels` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:607
`getPopularLabels` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:612
`searchLabels` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:617
`checkHealth` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:622
`verifyCredentials` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:651
`scanNewDocuments` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:660
`reprocessFailedDocuments` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:665
`insertText` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:993
`insertTexts` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:998
`uploadDocument` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1003
`clearDocuments` awaits `axiosInstance.delete(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.delete(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1048
`deleteDocuments` awaits `axiosInstance.delete(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.delete(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1057
`getAuthStatus` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1068
`getPipelineStatus` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1132
`cancelPipeline` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1139
`loginToServer` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1147
`updateEntity` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1170
`updateRelation` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1192
`checkEntityNameExists` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1210
`getTrackStatus` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`. — lightrag_webui/src/api/lightrag.ts:1225
What to do
Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.
Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.
Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.
Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.
Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.
`debug` at line 5357 is called with an argument built by `"…".join(text_purposes)` (line 5360), 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. — lightrag/operate.py:5357
`debug` at line 450 is called with an argument built by `sorted(item)` (line 457), 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. — lightrag/parser/external/mineru/ir_builder.py:450
`debug` at line 1219 is called with an argument built by `index_config.to_dict()` (line 1220), 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. — lightrag/kg/milvus_impl.py:1219
`debug` at line 354 is called with an argument built by `list(first_ref.keys())` (line 354), 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. — lightrag/evaluation/eval_rag_quality.py:354
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 unescaped6.3 / 10Adequate✓ Tool-verified
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.
`svg` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — lightrag_webui/src/components/retrieval/ChatMessage.tsx:578
`value` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — lightrag_webui/src/utils/entityName.ts:28
What to do
Each finding names the expression, the attribute it lands in and the line. Confirm the value's origin from the read this analyzer traced, then escape it at the sink or validate it against the shape the attribute accepts before interpolating.
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.
`this module` looks up `"entity_name"` and falls back to `entity_to_change_into` when the caller supplies none — but line 499 of this same type looks up `"entity_name"` and falls back to `entity_name`, which is the member that key names. The two cannot both be right: every caller who configures `entity_name` and passes no `"entity_name"` override silently gets `entity_to_change_into` instead, and nothing reports that the value was ignored. Fall back to `entity_name` here as line 499 does — or, if `entity_to_change_into` genuinely is the intended source, look it up under its own key so the two sites stop disagreeing. — lightrag/api/routers/graph_routes.py:845
What to do
Each finding names the spans that disagree — the knob the caller supplies and the site that ignores it, whether by re-spelling its default, by falling back under the wrong key, by parsing with no format provider at all, or by printing under whatever culture the host supplies. Confirm from those spans, then decide which of the two the type meant: read the knob at the named site, or drop the knob so the signature stops advertising something the type cannot feel. Leaving both is the one option that cannot be right.
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.
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. (×29) — lightrag_webui/src/utils/SearchHistoryManager.ts:248, lightrag_webui/src/stores/graph.ts:233, lightrag_webui/src/stores/graph.ts:245, …
`catch` 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. (×2) — lightrag_webui/src/migrations/splitSettingsStorage.ts:307, lightrag_webui/src/migrations/splitSettingsStorage.ts:570
`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. (×9) — lightrag/pipeline.py:6886, lightrag/pipeline.py:8108, REDACTED:1434, …
What to do
Swallowed exception (empty catch)
Do you agree with this assessment?
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.
Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.
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 `REDACTED` 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.
`warning` at line 83 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. — lightrag/file_atomic.py:83
`info` at line 118 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. — lightrag/file_atomic.py:118
`warning` at line 122 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. — lightrag/file_atomic.py:122
`warning` at line 151 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. — lightrag/file_atomic.py:151
`debug` at line 156 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog. — lightrag/file_atomic.py:156
`warning` at line 188 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. — lightrag/file_atomic.py:188
`warning` at line 451 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. — lightrag/operate.py:451
`warning` at line 487 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. — lightrag/operate.py:487
`info` at line 504 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. — lightrag/operate.py:504
`warning` at line 624 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. — lightrag/operate.py:624
`warning` at line 646 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. — lightrag/operate.py:646
`warning` at line 680 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. — lightrag/operate.py:680
`warning` at line 689 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. — lightrag/operate.py:689
`warning` at line 694 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. — lightrag/operate.py:694
`warning` at line 702 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. — lightrag/operate.py:702
`warning` at line 718 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. — lightrag/operate.py:718
`info` at line 729 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. — lightrag/operate.py:729
`warning` at line 748 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. — lightrag/operate.py:748
`error` at line 763 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. — lightrag/operate.py:763
`error` at line 768 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. — lightrag/operate.py:768
`warning` at line 784 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. — lightrag/operate.py:784
`info` at line 796 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. — lightrag/operate.py:796
`info` at line 802 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. — lightrag/operate.py:802
`debug` at line 808 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog. — lightrag/operate.py:808
`warning` at line 822 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. — lightrag/operate.py:822
`warning` at line 843 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. — lightrag/operate.py:843
`warning` at line 848 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. — lightrag/operate.py:848
`warning` at line 949 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. — lightrag/operate.py:949
`warning` at line 965 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. — lightrag/operate.py:965
`info` at line 977 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. — lightrag/operate.py:977
`warning` at line 995 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. — lightrag/operate.py:995
`warning` at line 1018 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. — lightrag/operate.py:1018
`warning` at line 1026 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. — lightrag/operate.py:1026
`info` at line 1040 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. — lightrag/operate.py:1040
`info` at line 1045 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. — lightrag/operate.py:1045
`debug` at line 1050 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog. — lightrag/operate.py:1050
`warning` at line 1063 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. — lightrag/operate.py:1063
`warning` at line 1094 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. — lightrag/operate.py:1094
`warning` at line 1452 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. — lightrag/operate.py:1452
`warning` at line 1455 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. — lightrag/operate.py:1455
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.3 `!` null assertions per 1k TypeScript source lines — 8 assertion(s) across the 24620 source line(s) of the 153 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: lightrag_webui/src/components/ui/NumberInput.tsx (2), lightrag_webui/src/hooks/useLightragGraph.tsx (2), lightrag_webui/src/api/lightrag.ts (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 13 of 55 WCAG 2.2 Level A/AA success criteria (24%; ≈26% of the 50 WCAG 2.1 AA criteria for EN 301 549). The other 42 require runtime or manual evaluation. Partial signal only (a clean result is necessary, not sufficient; static analysis fully verifies none). This is accessibility readiness, not a conformance claim — a WCAG conformance claim requires manual evaluation (WCAG-EM 1.0).
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Unscored — 3 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X6 Hand-rolled structured-format parsing — 5 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 5 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 3 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
C3 Audit Trail — Not assessed: this repository stores data through 'sqlite3' (lightrag/tools/chunk_tracking_repair.py:26) but declares no persisted model this check reads (Django, SQLAlchemy, SQLModel, Peewee, Tortoise and MongoEngine model fields, Alembic and Django migration columns, CREATE TABLE and ALTER TABLE … ADD columns in SQL files). Personal data may be written through raw SQL or a hosted backend, so whether its changes need an audit trail could not be established, and the trail's absence is not scored.
C4 Data Retention — Not assessed: this repository stores data through 'sqlite3' (lightrag/tools/chunk_tracking_repair.py:26) but declares no persisted model this check reads (Django, SQLAlchemy, SQLModel, Peewee, Tortoise and mongoengine model fields, Alembic and Django migration columns, SQL schemas). Personal data may be written through raw SQL or a hosted backend, so whether a retention limit applies here could not be established, and its absence is not scored.
C5 Data-Subject Rights — Not assessed: this repository stores data through 'sqlite3' (lightrag/tools/chunk_tracking_repair.py:26) but declares no persisted model this check reads (Django, SQLAlchemy, SQLModel, Peewee, Tortoise and mongoengine model fields, Alembic and Django migration columns, CREATE TABLE and ALTER TABLE … ADD columns in SQL files). Personal data may be written through raw SQL or a hosted backend, so whether data-subject rights apply here could not be established, and their absence is not scored.
Not included — 40 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.
AC6 Visual & motion safety — Visual & motion safety could not be assessed in this run — the check did not complete, so it is not scored. This is a gap in the analyzer, not a finding about this repository.
AX1 Captive dependencies — Not applicable: this repository's Python imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's; this repository's TypeScript imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
AX4 Dependency direction — not applicable to a vertical-slice architecture (the inward-dependency rule is for layered/clean styles)
AX8 Test isolation — no test/production split to check
AX9 CQS / query purity — no CQRS query handlers detected — query purity is not applicable to this codebase
AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
AXR1 Runtime accessibility — The runtime tier booted this repository's service, but crawled PUBLIC routes only — add a Playwright storageState (e.g. playwright/.auth/user.json) or a test auth-setup to crawl authenticated screens rendered 0/1 surface(s) × 2 renders render failed for http://127.0.0.1:9621: page.goto: net::ERR_CONNECTION_RESET at http://127.0.0.1:9621/
Call log:
- navigating to "http://127.0.0.1:9621/", waiting until "load"
. This repository also has a user interface (81 markup document(s) — HTML, Razor, JSX, Vue, Svelte or server templates) that the booted service does not serve, and this scan has no strategy that reaches it — so no WCAG success criterion was verified in a rendered page on this run. That is a gap in OUR tooling, not a finding about your application: nothing here says the interface is inaccessible. The static accessibility checks still ran.
AXS1 Runtime exposed surface — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
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.
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.
D21 Naming Consistency — Naming consistency is measured on C# only; Python, TypeScript not measured.
D22 Internal API Consistency — API consistency is measured on C# only; the exposed Python surface was not measured.
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 — D24 reads C# and Visual Basic comments only — this repository's production source is .py, .ts, .tsx, which was left unread. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D25 ADR Conformance — no ADRs to check
D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.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) — 2 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
D42 Runtime Threat Enforcement — The repository ships application workloads but no cluster-governance resources (CRDs, admission webhooks, or a committed policy engine). Runtime threat-detection (Falco/Tetragon) and admission control (Kyverno/OPA-Gatekeeper/PodSecurity) are cluster-OPERATOR controls owned by the platform, not shipped by an application repo/chart — nothing for this repo to assess.
D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
D8 Code Coverage — Coverage NOT MEASURED: the JavaScript/TypeScript half could not be measured — the bun:test suite in lightrag_webui/ ran and not one test passed (src/features/documentRefreshErrors.test.ts:), so the coverage report describes the failed run, not the code. Coverage is excluded from the score rather than counted as a near-zero. The named suite step is one the repository's maintainers can perform; once it passes, the real number is measured on the next scan. Alternatively, commit the lcov/Cobertura report your CI produces and it is read without a re-run.
DM1 Domain Modelling — not scored — this repository shows only 1 of the 3 signals this lens looks for (133 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'.
P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (`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, or wire coverage collection into CI, to enable this cross-layer check
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.
R5 Dependency Freshness — uses a bun lockfile — dependency freshness not measured here; JS/npm CVEs are scored in D30 (Dependency Vulnerabilities), which answers every ecosystem
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.
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· <label> that labels no control · ×5
<label> that labels no control lightrag_webui/src/components/AppSettings.tsx:56— This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
<label> that labels no control lightrag_webui/src/components/AppSettings.tsx:79— This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
<label> that labels no control lightrag_webui/src/components/graph/Settings.tsx:417— This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
<label> that labels no control lightrag_webui/src/components/ui/Text.tsx:21— This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
<label> that labels no control lightrag_webui/src/components/ui/Text.tsx:34— This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
AC2 · Forms & labels· <textarea> without a programmatic label · ×2
<textarea> without a programmatic label lightrag_webui/src/components/graph/PropertyEditDialog.tsx:120— This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
<textarea> without a programmatic label lightrag_webui/src/components/graph/PropertyEditDialog.tsx:128— 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· Link with no accessible name · ×2
Link with no accessible name lightrag_webui/src/features/SiteHeader.tsx:140— A link with no text, aria-label or labelled child (e.g. an icon-only link) has no accessible name, so assistive tech can't say where it goes. Add visible text or an aria-label.
Link with no accessible name lightrag_webui/src/features/SiteHeader.tsx:146— A link with no text, aria-label or labelled child (e.g. an icon-only link) has no accessible name, so assistive tech can't say where it goes. Add visible text or an aria-label.
AC4 · Keyboard semantics· Click handler on a non-interactive <div> · ×2
Click handler on a non-interactive <div> lightrag_webui/src/components/retrieval/ChatMessage.tsx:257— A click handler on a plain element isn't keyboard-operable. Use a <button>, or add role + tabIndex={0} + a key handler.
Click handler on a non-interactive <div> lightrag_webui/src/components/status/StatusIndicator.tsx:27— A click handler on a plain element isn't keyboard-operable. Use a <button>, or add role + tabIndex={0} + a key handler.
AC2 · Forms & labels· <button> with no accessible text · ×1
<button> with no accessible text lightrag_webui/src/components/ui/UserPromptInputWithHistory.tsx:150— A button with no text and no aria-label has no accessible name. Add visible text or an aria-label (an icon-only button still needs one).
AC4 · Keyboard semantics· Hover-only interaction on <div> · ×1
Hover-only interaction on <div> lightrag_webui/src/components/ui/UserPromptInputWithHistory.tsx:136— This <div> binds mouse-enter and mouse-leave and nothing else — no click, no key handler, no focus handler, and no tabIndex={0}, so it cannot even take focus. A keyboard user cannot hover, so whatever the pair reveals or highlights is reachable with a mouse only. Bind the same state to focus/blur as well, and add tabIndex={0}="0" so the element can receive that focus.
Unlisted import '@react-sigma/layout-core' lightrag_webui/src/components/graph/LayoutsControl.tsx:6— Imported but not declared in any reachable REDACTED — installs work only by hoisting accident.
Hotspot: lightrag/lightrag.py lightrag/lightrag.py:6265— lightrag/lightrag.py changed 131 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 84 in LightRAG._purge_derived_kg_contributions at line 6265. 79 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/lightrag.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: lightrag/operate.py lightrag/operate.py:2782— lightrag/operate.py changed 78 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 90 in operate._merge_edges_then_upsert at line 2782. 46 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/operate.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: lightrag/pipeline.py lightrag/pipeline.py:4991— lightrag/pipeline.py changed 94 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 74 in _PipelineMixin.process_single_document at line 4991. 60 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/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:4707— REDACTED changed 110 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 47 in utils.aexport_data at line 4707. 80 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +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: lightrag/utils_graph.py lightrag/utils_graph.py:2703— lightrag/utils_graph.py changed 69 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 63 in utils_graph._merge_entities_impl at line 2703. 57 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/utils_graph.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: lightrag/api/routers/document_routes.py lightrag/api/routers/document_routes.py:3674— lightrag/api/routers/document_routes.py changed 100 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in document_routes.run_scanning_process at line 3674. 61 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/api/routers/document_routes.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: lightrag_webui/src/features/DocumentManager.tsx lightrag_webui/src/features/DocumentManager.tsx:381— lightrag_webui/src/features/DocumentManager.tsx changed 19 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 152 in DocumentManager.DocumentManager at line 381. 18 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/features/DocumentManager.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: lightrag/api/lightrag_server.py lightrag/api/lightrag_server.py:1436— lightrag/api/lightrag_server.py changed 53 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 53 in lightrag_server.create_app at line 1436. 29 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/api/lightrag_server.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: lightrag/kg/networkx_impl.py lightrag/kg/networkx_impl.py:1087— lightrag/kg/networkx_impl.py changed 62 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 30 in NetworkXStorage.get_knowledge_graph at line 1087. 48 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/networkx_impl.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:4243— REDACTED changed 39 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 41 in PGVectorStorage.setup_table at line 4243. 24 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +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: REDACTED REDACTED:907— REDACTED changed 42 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 32 in FaissVectorDBStorage._flush_pending_locked at line 907. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +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: lightrag/kg/opensearch_impl.py lightrag/kg/opensearch_impl.py:5558— lightrag/kg/opensearch_impl.py changed 53 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in OpenSearchGraphStorage._bfs_subgraph_ppl at line 5558. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/opensearch_impl.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:531— REDACTED changed 35 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 29 in NanoVectorDBStorage._flush_pending_locked at line 531. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +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: lightrag/kg/mongo_impl.py lightrag/kg/mongo_impl.py:1997— lightrag/kg/mongo_impl.py changed 41 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 24 in MongoGraphStorage._dedupe_legacy_edges at line 1997. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/mongo_impl.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:346— REDACTED changed 22 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 38 in config.parse_args at line 346. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +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: lightrag/llm/openai.py lightrag/llm/openai.py:305— lightrag/llm/openai.py changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 63 in openai.openai_complete_if_cache at line 305. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/llm/openai.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: lightrag/api/ui_customization.py lightrag/api/ui_customization.py:647— lightrag/api/ui_customization.py changed 16 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 46 in ui_customization.load_ui_customization_snapshot at line 647. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/api/ui_customization.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: lightrag/kg/shared_storage.py lightrag/kg/shared_storage.py:4001— lightrag/kg/shared_storage.py changed 49 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 15 in shared_storage.finalize_share_data at line 4001. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/shared_storage.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: lightrag_webui/src/components/retrieval/ChatMessage.tsx lightrag_webui/src/components/retrieval/ChatMessage.tsx:57— lightrag_webui/src/components/retrieval/ChatMessage.tsx changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 57 in ChatMessage.ChatMessage at line 57. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/components/retrieval/ChatMessage.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: lightrag_webui/src/features/LoginPage.tsx lightrag_webui/src/features/LoginPage.tsx:45— lightrag_webui/src/features/LoginPage.tsx changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 36 in LoginPage.LoginPage at line 45. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/features/LoginPage.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: lightrag/kg/milvus_impl.py lightrag/kg/milvus_impl.py:2262— lightrag/kg/milvus_impl.py changed 27 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in MilvusVectorDBStorage._create_collection_if_not_exist at line 2262. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/milvus_impl.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: lightrag/parser/markdown/extract.py lightrag/parser/markdown/extract.py:359— lightrag/parser/markdown/extract.py changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 22 in extract.extract_markdown at line 359. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/parser/markdown/extract.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: lightrag_webui/src/features/retrieval/useQuerySession.ts lightrag_webui/src/features/retrieval/useQuerySession.ts:248— lightrag_webui/src/features/retrieval/useQuerySession.ts changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 50 in useQuerySession.useQuerySession.submitQuery at line 248. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/features/retrieval/useQuerySession.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: lightrag/kg/json_doc_status_impl.py lightrag/kg/json_doc_status_impl.py:428— lightrag/kg/json_doc_status_impl.py changed 27 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 15 in JsonDocStatusStorage.get_docs_paginated at line 428. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/json_doc_status_impl.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: lightrag/llm/ollama.py lightrag/llm/ollama.py:209— lightrag/llm/ollama.py changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 31 in ollama._ollama_model_if_cache at line 209. 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-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/llm/ollama.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.
FileTooLong: REDACTED REDACTED— FileTooLong — 4571 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 4071 over it, 9.14× 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: lightrag/pipeline.py lightrag/pipeline.py— FileTooLong — 4459 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3959 over it, 8.92× 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: kg/opensearch_impl.py lightrag/kg/opensearch_impl.py— FileTooLong — 4416 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3916 over it, 8.83× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: lightrag/operate.py lightrag/operate.py— FileTooLong — 4330 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3830 over it, 8.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: lightrag/lightrag.py lightrag/lightrag.py— FileTooLong — 4289 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3789 over it, 8.58× 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 — 4010 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3510 over it, 8.02× 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: routers/document_routes.py lightrag/api/routers/document_routes.py— FileTooLong — 3681 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3181 over it, 7.36× 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: kg/mongo_impl.py lightrag/kg/mongo_impl.py— FileTooLong — 2877 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 2377 over it, 5.75× 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: kg/shared_storage.py lightrag/kg/shared_storage.py— FileTooLong — 2287 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1787 over it, 4.57× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: api/lightrag_server.py lightrag/api/lightrag_server.py— FileTooLong — 2112 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1612 over it, 4.22× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: smart_heading/heading_flow.py lightrag/parser/docx/smart_heading/heading_flow.py— FileTooLong — 2029 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1529 over it, 4.06× 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: kg/milvus_impl.py lightrag/kg/milvus_impl.py— FileTooLong — 2018 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1518 over it, 4.04× 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: lightrag/utils_graph.py lightrag/utils_graph.py— FileTooLong — 1825 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1325 over it, 3.65× 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: kg/redis_impl.py lightrag/kg/redis_impl.py— FileTooLong — 1659 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1159 over it, 3.32× 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: chunker/paragraph_semantic.py lightrag/chunker/paragraph_semantic.py— FileTooLong — 1309 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 809 over it, 2.62× 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: features/DocumentManager.tsx lightrag_webui/src/features/DocumentManager.tsx— FileTooLong — 1175 significant lines (blank, comment-only and punctuation-only lines excluded), about 77% of them inside a single declaration: DocumentManager (381-1853). The bar is 500 significant lines; this is 675 over it, 2.35× 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: smart_heading/title_block.py lightrag/parser/docx/smart_heading/title_block.py— FileTooLong — 993 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 493 over it, 1.99× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: tools/chunk_tracking_repair.py lightrag/tools/chunk_tracking_repair.py— FileTooLong — 946 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 446 over it, 1.89× 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: markdown/parser.py lightrag/parser/markdown/parser.py— FileTooLong — 920 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 420 over it, 1.84× 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: kg/qdrant_impl.py lightrag/kg/qdrant_impl.py— FileTooLong — 908 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 408 over it, 1.82× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: api/lightrag.ts lightrag_webui/src/api/lightrag.ts— FileTooLong — 849 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 349 over it, 1.70× 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 — 846 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 346 over it, 1.69× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: parser/routing.py lightrag/parser/routing.py— FileTooLong — 842 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 342 over it, 1.68× 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 — 836 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 336 over it, 1.67× 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: tools/migrate_llm_cache.py lightrag/tools/migrate_llm_cache.py— FileTooLong — 814 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 314 over it, 1.63× 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.
Repeated repair: lightrag/base.py lightrag/base.py:1749— lightrag/base.py changed 47 times in last 90 days and 28 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 5 (its worst body is DocStatusStorage._row_points_at_as_duplicate at line 1749), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(storage): tell a lost reference from a durable one when a chunk commit raises”; “fix(kg): list a self-loop once on the AGE backend too”; “fix(kg): make the self-loop rule a data invariant, and batch the degree lookups”; “fix: withhold the cache at shutdown over retained chunk operations”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/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.
Repeated repair: lightrag/exceptions.py lightrag/exceptions.py:738— lightrag/exceptions.py changed 26 times in last 90 days and 16 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 9 (its worst body is VectorSpaceMismatchError.__init__ at line 738), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(pipeline): let the enqueue-stall fence spare the holders it was raised about”; “fix(pipeline): force_reset must drop the reservations the enqueue fence waited on”; “fix(pipeline): cover /upload, bound the drain wait, pin the fix with tests”; “fix(storage): tell a lost reference from a durable one when a chunk commit raises”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/exceptions.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.
Repeated repair: REDACTED REDACTED:144— REDACTED changed 26 times in last 90 days and 14 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 14 (its worst body is utils_pipeline.build_chunks_dict_from_chunking_result at line 144), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(chunker): correct drift diagnostics and selection ergonomics”; “fix(docs): repair parentheticals the issue-reference removal gutted, and guard them”; “fix(pipeline): keep generated failure summary within varchar(255)”; “Fix lintings”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +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.
Repeated repair: lightrag/llm/hf.py lightrag/llm/hf.py:299— lightrag/llm/hf.py changed 13 times in last 90 days and 13 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 8 (its worst body is hf.hf_embed at line 299), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(hf): keep decoding inside the serialized inference job”; “fix(hf): serialize model loading with generate to cap GPU residency at one model”; “fix(hf): recreate the inference executor after a fork via os.register_at_fork”; “fix(hf): serialise local inference safely”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/llm/hf.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.
Repeated repair: lightrag_webui/src/features/workspace/WorkspaceApp.tsx lightrag_webui/src/features/workspace/WorkspaceApp.tsx:37— lightrag_webui/src/features/workspace/WorkspaceApp.tsx changed 15 times in last 90 days and 12 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 14 (its worst body is WorkspaceApp.WorkspaceApp at line 37), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(webui): expose descriptions on touch devices”; “fix(webui): make workspace tooltip keyboard accessible”; “fix(webui): show workspace description in tooltip”; “🐛 fix(webui): start the API-key dialog baseline at the mount's own counter”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/features/workspace/WorkspaceApp.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.
Repeated repair: lightrag/kg/file_fingerprint.py lightrag/kg/file_fingerprint.py:247— lightrag/kg/file_fingerprint.py changed 17 times in last 90 days and 10 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 6 (its worst body is file_fingerprint.divergence_detected at line 247), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(networkx): resolve an unrecorded fingerprint before serving the graph”; “fix(networkx): refuse to reload on an unreadable sample”; “🐛 fix(networkx): count peer commit before failed-save reload”; “fix(kg): keep the dedupe marker unless a concrete state was adopted”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/file_fingerprint.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.
Repeated repair: lightrag/kg/json_kv_impl.py lightrag/kg/json_kv_impl.py:469— lightrag/kg/json_kv_impl.py changed 14 times in last 90 days and 10 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is JsonKVStorage._migrate_legacy_cache_structure at line 469), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: correct four misspelled strings in exceptions and logs”; “fix(docs): repair nine more rewrite artifacts, and scope the pointer check per contract”; “fix(storage): preserve KV create_time with server-side conditional writes”; “fix(storage): preserve create_time on KV replacement upserts”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/json_kv_impl.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.
Repeated repair: lightrag/api/routers/query_routes.py lightrag/api/routers/query_routes.py:189— lightrag/api/routers/query_routes.py changed 14 times in last 90 days and 10 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is QueryRequest.conversation_history_role_check at line 189), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(query): restore QueryParam positional order, budget the real template”; “fix(query): refuse empty prompts and stop walking whole queries”; “fix(query): enforce meaningful RAG query length”; “🐛 fix(relation): repair evidence floor and chunk tracking”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/api/routers/query_routes.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.
Repeated repair: lightrag/query_validation.py lightrag/query_validation.py:101— lightrag/query_validation.py changed 10 times in last 90 days and 9 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 4 (its worst body is query_validation.meets_min_rag_query_weight at line 101), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(query): keep the width table to Chinese, Japanese and Korean”; “fix(query): end every width range on a block boundary”; “fix(query): weigh the supplementary Chinese iteration marks”; “fix(query): weigh Bopomofo, iteration marks and CJK numerals”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/query_validation.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.
Repeated repair: lightrag_webui/src/utils/queryValidation.ts lightrag_webui/src/utils/queryValidation.ts:55— lightrag_webui/src/utils/queryValidation.ts changed 10 times in last 90 days and 9 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 4 (its worst body is queryValidation.meetsMinRagQueryWeight at line 55), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(query): keep the width table to Chinese, Japanese and Korean”; “fix(query): end every width range on a block boundary”; “fix(query): weigh the supplementary Chinese iteration marks”; “fix(query): weigh Bopomofo, iteration marks and CJK numerals”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/utils/queryValidation.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.
Repeated repair: lightrag/api/routers/ollama_api.py lightrag/api/routers/ollama_api.py:211— lightrag/api/routers/ollama_api.py changed 9 times in last 90 days and 9 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 8 (its worst body is ollama_api.parse_request_body at line 211), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(api): require a word boundary after unsuffixed context mode keys”; “fix(query): forward Ollama prompts verbatim, weigh letters only”; “fix(query): refuse empty prompts and stop walking whole queries”; “fix(query): enforce meaningful RAG query length”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/api/routers/ollama_api.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.
Repeated repair: lightrag/api/routers/graph_routes.py lightrag/api/routers/graph_routes.py:88— lightrag/api/routers/graph_routes.py changed 10 times in last 90 days and 8 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 3 (its worst body is EntityUpdateRequest.validate_rename_target_name at line 88), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(api): surface the admin-write hold ceiling's outcome to REST clients”; “fix(graph): enforce relation evidence weight floor”; “fix(graph): validate attributes on the manual entity/relation APIs”; “fix(graph): normalize entity merge names”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/api/routers/graph_routes.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.
Repeated repair: lightrag_webui/src/lib/loginIdentity.ts lightrag_webui/src/lib/loginIdentity.ts:45— lightrag_webui/src/lib/loginIdentity.ts changed 8 times in last 90 days and 8 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 6 (its worst body is loginIdentity.loginIdentityFromToken at line 45), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(webui): decide the login identity from the granted token, not the typed name”; “🐛 fix(webui): read JWT payloads as UTF-8, without wiping the histories it fixes”; “🐛 fix(webui): restore streaming auto-scroll and decode JWT payloads as base64url”; “🐛 fix(webui): apply the identity-change rule in the cross-tab handler too”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/lib/loginIdentity.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.
Repeated repair: lightrag/tools/source_conflict_repair.py lightrag/tools/source_conflict_repair.py:737— lightrag/tools/source_conflict_repair.py changed 9 times in last 90 days and 7 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is source_conflict_repair._async_main at line 737), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(pipeline): never drop a source-conflict repair guard on force_reset”; “🔒 fix(repair): linearize the commit against the processing duplicate marking”; “🔒 fix(repair): unverified is not verified, and refuse a primary already doomed”; “🔒 fix(repair): fail closed when the chosen primary cannot be verified”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/tools/source_conflict_repair.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.
Repeated repair: lightrag/kg/pgtable_impl.py lightrag/kg/pgtable_impl.py:1137— lightrag/kg/pgtable_impl.py changed 11 times in last 90 days and 6 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 7 (its worst body is PGTableGraphStorage._bfs_frontier at line 1137), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(kg): make the self-loop rule a data invariant, and batch the degree lookups”; “fix(storage): bound chunk tracking repair memory”; “fix(tools): address maintainer review on the graph-migration tool”; “fix(kg): charge the endpoint array against the edge-upsert payload cap”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/pgtable_impl.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.
Repeated repair: lightrag_webui/src/components/customization/useCustomizedContent.ts lightrag_webui/src/components/customization/useCustomizedContent.ts:88— lightrag_webui/src/components/customization/useCustomizedContent.ts changed 10 times in last 90 days and 6 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 7 (its worst body is useCustomizedContent.useCustomizedContent at line 88), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(webui): preserve description access and bounds”; “fix(webui): preserve deployment title on fallback”; “fix(webui): keep the consent gate honest across a language switch”; “fix(api,webui): browser-language fallback, bounded customization retry, credential re-probe, SVG root check”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/components/customization/useCustomizedContent.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.
Repeated repair: lightrag/api/login_rate_limit.py lightrag/api/login_rate_limit.py:116— lightrag/api/login_rate_limit.py changed 8 times in last 90 days and 6 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 5 (its worst body is LoginRateLimiter.retry_after at line 116), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(api): accurate Retry-After when a login block is only from pending”; “fix(api): drop idle rate-limit entries so capacity isn't falsely exhausted”; “fix(api): separate in-flight reservations from confirmed failures”; “fix(api): correct false lockout alert and sanitize alert log values”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/api/login_rate_limit.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.
Repeated repair: lightrag/parser/external/docling/client.py lightrag/parser/external/docling/client.py:110— lightrag/parser/external/docling/client.py changed 6 times in last 90 days and 6 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 8 (its worst body is DoclingRawClient.__init__ at line 110), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(parser): correct Python 3.10 timeout handling and HTTP error detail loss”; “fix(parser): decouple the download streaming cap from the uncompressed-size cap”; “fix(parser): use async-timeout backport for Python 3.10 compatibility”; “fix(parser): bound external result downloads for MinerU and Docling”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/parser/external/docling/client.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.
Repeated repair: lightrag_webui/src/stores/settings.ts lightrag_webui/src/stores/settings.ts:238— lightrag_webui/src/stores/settings.ts changed 8 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 5 (its worst body is migrate at line 238), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(webui): never persist over an unmigrated envelope; destroy histories version-agnostically on identity change”; “fix(webui): preserve legacy explicit language choices; extend future-envelope guard to all split keys”; “fix(webui): API-key capture on the workspace entry; per-write guard for future settings envelopes”; “fix(webui): identity-change cleanup on guest activation; never downgrade future settings envelopes”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/stores/settings.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.
Repeated repair: REDACTED REDACTED:51— REDACTED changed 6 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is AuthHandler.__init__ at line 51), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(auth): keep AUTH_ACCOUNTS passwords byte-for-byte”; “fix(api): share the subject cap with account config; renew at the API key exit”; “fix(api): bound the token-renewal cache and stop pre-auth writes”; “fix(auth): dummy bcrypt for plaintext accounts too, to equalize login timing”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +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.
Repeated repair: lightrag/parser/external/_common.py lightrag/parser/external/_common.py:116— lightrag/parser/external/_common.py changed 5 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is _common.response_error_detail at line 116), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(parser): restrict result downloads to identity Content-Encoding”; “fix(parser): correct Python 3.10 timeout handling and HTTP error detail loss”; “fix(parser): decouple the download streaming cap from the uncompressed-size cap”; “fix(parser): use async-timeout backport for Python 3.10 compatibility”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/parser/external/_common.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.
Repeated repair: lightrag/parser/external/mineru/client.py lightrag/parser/external/mineru/client.py:268— lightrag/parser/external/mineru/client.py changed 5 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is MinerURawClient._download_official at line 268), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(parser): correct Python 3.10 timeout handling and HTTP error detail loss”; “fix(parser): decouple the download streaming cap from the uncompressed-size cap”; “fix(parser): use async-timeout backport for Python 3.10 compatibility”; “fix(parser): bound external result downloads for MinerU and Docling”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/parser/external/mineru/client.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.
Repeated repair: lightrag/kg/pipeline_ingress.py lightrag/kg/pipeline_ingress.py:184— lightrag/kg/pipeline_ingress.py changed 7 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 5 (its worst body is pipeline_ingress._validate_document_message at line 184), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “🔒 fix(pipeline): fence the blocked drain, and make force_reset actually unblock it”; “🐛 fix(scan): a failed stub delete is an error, not a resume”; “🐛 fix(pipeline): publish inside the status lock + restore signals consumed before a cancel”; “♻️ refactor(kg): hub topology + review fixes for pipeline ingress”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag/kg/pipeline_ingress.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.
Repeated repair: lightrag_webui/src/features/RetrievalView.tsx lightrag_webui/src/features/RetrievalView.tsx:19— lightrag_webui/src/features/RetrievalView.tsx changed 6 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 2 (its worst body is RetrievalView.RetrievalView at line 19), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(webui): reduce retrieval bottom spacing”; “fix(webui): align query validation feedback”; “fix(query): enforce meaningful RAG query length”; “fix(webui): reliable follow-scroll recovery and jump-to-bottom button”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/features/RetrievalView.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.
Repeated repair: lightrag_webui/src/stores/customization.ts lightrag_webui/src/stores/customization.ts:149— lightrag_webui/src/stores/customization.ts changed 6 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 14 (its worst body is customization.useCustomizationStore at line 149), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(webui): keep the consent gate honest across a language switch”; “fix(api,webui): browser-language fallback, bounded customization retry, credential re-probe, SVG root check”; “fix(webui): retry customization when the target locale is not the loaded one”; “fix(webui): five workspace interaction-contract fixes”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-16..2026-10-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-16 22:55:37 +08:00' --until='2026-10-14 22:55:37 +08:00' --full-history --no-merges -- lightrag_webui/src/stores/customization.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.
Swallowed exception (empty catch) lightrag_webui/src/utils/SearchHistoryManager.ts:248— 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) lightrag_webui/src/stores/graph.ts:233— 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) lightrag_webui/src/stores/graph.ts:245— 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) lightrag_webui/src/stores/retrievalHistory.ts:83— 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) lightrag_webui/src/migrations/splitSettingsStorage.ts:407— 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) lightrag_webui/src/lib/loginIdentity.ts:53— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) lightrag_webui/src/components/graph/GraphControl.tsx:208— 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) lightrag_webui/src/components/graph/GraphControl.tsx:251— 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) lightrag_webui/src/components/graph/LayoutsControl.tsx:171— 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) lightrag_webui/src/components/graph/LayoutsControl.tsx:187— 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) lightrag_webui/src/api/lightrag.ts:760— 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) lightrag_webui/src/api/lightrag.ts:871— 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) lightrag/lightrag.py:7922— 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:2267— 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:2274— 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:2279— 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:3424— 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:6599— 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:6616— 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) lightrag/tools/clean_llm_query_cache.py:1227— 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) lightrag/tools/clean_llm_query_cache.py:1235— 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) lightrag/tools/migrate_graph_storage.py:1105— 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) lightrag/tools/migrate_llm_cache.py:1545— 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) lightrag/tools/migrate_llm_cache.py:1550— 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) lightrag/tools/migrate_llm_cache.py:1558— 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.
FunctionTooLong: DocumentManager.DocumentManager lightrag_webui/src/features/DocumentManager.tsx:381— FunctionTooLong — DocumentManager runs 904 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 804 over it, 9.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: useLightragGraph.useLightrangeGraph lightrag_webui/src/hooks/useLightragGraph.tsx:328— FunctionTooLong — useLightrangeGraph runs 475 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 375 over it, 4.75× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: useQuerySession.useQuerySession lightrag_webui/src/features/retrieval/useQuerySession.ts:151— FunctionTooLong — useQuerySession runs 324 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 224 over it, 3.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: Settings.Settings lightrag_webui/src/components/graph/Settings.tsx:182— FunctionTooLong — Settings runs 213 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 113 over it, 2.13× 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: MessageList.MessageList lightrag_webui/src/features/retrieval/MessageList.tsx:39— FunctionTooLong — MessageList runs 211 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 111 over it, 2.11× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: EditablePropertyRow.EditablePropertyRow lightrag_webui/src/components/graph/EditablePropertyRow.tsx:43— FunctionTooLong — EditablePropertyRow runs 203 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 103 over it, 2.03× 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: QueryComposer.QueryComposer lightrag_webui/src/features/retrieval/QueryComposer.tsx:24— FunctionTooLong — QueryComposer runs 195 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 95 over it, 1.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: useQuerySession.useQuerySession.submitQuery lightrag_webui/src/features/retrieval/useQuerySession.ts:248— FunctionTooLong — useQuerySession.submitQuery runs 195 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 95 over it, 1.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: PaginationControls.PaginationControls lightrag_webui/src/components/ui/PaginationControls.tsx:36— FunctionTooLong — PaginationControls runs 191 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 91 over it, 1.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: GraphLabels.GraphLabels lightrag_webui/src/components/graph/GraphLabels.tsx:18— FunctionTooLong — GraphLabels runs 188 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 88 over it, 1.88× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: StatusCard.StatusCard lightrag_webui/src/components/status/StatusCard.tsx:148— FunctionTooLong — StatusCard runs 175 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 75 over it, 1.75× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: graph.useGraphStoreBase lightrag_webui/src/stores/graph.ts:192— FunctionTooLong — useGraphStoreBase runs 164 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 64 over it, 1.64× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: FileUploader.FileUploader lightrag_webui/src/components/ui/FileUploader.tsx:151— FunctionTooLong — FileUploader runs 161 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 61 over it, 1.61× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: UploadDocumentsDialog.UploadDocumentsDialog lightrag_webui/src/components/documents/UploadDocumentsDialog.tsx:38— FunctionTooLong — UploadDocumentsDialog runs 157 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 57 over it, 1.57× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: AsyncSelect.AsyncSelect lightrag_webui/src/components/ui/AsyncSelect.tsx:74— FunctionTooLong — AsyncSelect runs 144 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 44 over it, 1.44× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: App.App lightrag_webui/src/App.tsx:31— FunctionTooLong — App runs 142 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 42 over it, 1.42× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: UserPromptInputWithHistory.UserPromptInputWithHistory lightrag_webui/src/components/ui/UserPromptInputWithHistory.tsx:17— FunctionTooLong — UserPromptInputWithHistory runs 142 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 42 over it, 1.42× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: PropertyEditDialog.PropertyEditDialog lightrag_webui/src/components/graph/PropertyEditDialog.tsx:31— FunctionTooLong — PropertyEditDialog runs 132 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 32 over it, 1.32× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ClearDocumentsDialog.ClearDocumentsDialog lightrag_webui/src/components/documents/ClearDocumentsDialog.tsx:41— FunctionTooLong — ClearDocumentsDialog runs 131 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 31 over it, 1.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: DeleteDocumentsDialog.DeleteDocumentsDialog lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:41— FunctionTooLong — DeleteDocumentsDialog runs 129 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 29 over it, 1.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: AsyncSearch.AsyncSearch lightrag_webui/src/components/ui/AsyncSearch.tsx:62— FunctionTooLong — AsyncSearch runs 125 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 25 over it, 1.25× 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: WorkspaceWelcome.WorkspaceWelcome lightrag_webui/src/features/workspace/WorkspaceWelcome.tsx:28— FunctionTooLong — WorkspaceWelcome runs 111 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 11 over it, 1.11× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: WorkspaceApp.WorkspaceApp lightrag_webui/src/features/workspace/WorkspaceApp.tsx:37— FunctionTooLong — WorkspaceApp runs 108 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 8 over it, 1.08× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: LayoutsControl.LayoutsControl lightrag_webui/src/components/graph/LayoutsControl.tsx:267— FunctionTooLong — LayoutsControl runs 103 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 3 over it, 1.03× 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.
X2 · Cancellation propagation· Async function without AbortSignal · ×22
Async function without AbortSignal: silentRefreshGuestToken lightrag_webui/src/api/lightrag.ts:402— `silentRefreshGuestToken` awaits `axios.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axios.get(url, { signal })`.
Async function without AbortSignal: queryGraphs lightrag_webui/src/api/lightrag.ts:598— `queryGraphs` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: getGraphLabels lightrag_webui/src/api/lightrag.ts:607— `getGraphLabels` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: getPopularLabels lightrag_webui/src/api/lightrag.ts:612— `getPopularLabels` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: searchLabels lightrag_webui/src/api/lightrag.ts:617— `searchLabels` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: checkHealth lightrag_webui/src/api/lightrag.ts:622— `checkHealth` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: verifyCredentials lightrag_webui/src/api/lightrag.ts:651— `verifyCredentials` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: scanNewDocuments lightrag_webui/src/api/lightrag.ts:660— `scanNewDocuments` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: reprocessFailedDocuments lightrag_webui/src/api/lightrag.ts:665— `reprocessFailedDocuments` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: insertText lightrag_webui/src/api/lightrag.ts:993— `insertText` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: insertTexts lightrag_webui/src/api/lightrag.ts:998— `insertTexts` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: uploadDocument lightrag_webui/src/api/lightrag.ts:1003— `uploadDocument` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: clearDocuments lightrag_webui/src/api/lightrag.ts:1048— `clearDocuments` awaits `axiosInstance.delete(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.delete(url, { signal })`.
Async function without AbortSignal: deleteDocuments lightrag_webui/src/api/lightrag.ts:1057— `deleteDocuments` awaits `axiosInstance.delete(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.delete(url, { signal })`.
Async function without AbortSignal: getAuthStatus lightrag_webui/src/api/lightrag.ts:1068— `getAuthStatus` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: getPipelineStatus lightrag_webui/src/api/lightrag.ts:1132— `getPipelineStatus` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: cancelPipeline lightrag_webui/src/api/lightrag.ts:1139— `cancelPipeline` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: loginToServer lightrag_webui/src/api/lightrag.ts:1147— `loginToServer` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: updateEntity lightrag_webui/src/api/lightrag.ts:1170— `updateEntity` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: updateRelation lightrag_webui/src/api/lightrag.ts:1192— `updateRelation` awaits `axiosInstance.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.post(url, { signal })`.
Async function without AbortSignal: checkEntityNameExists lightrag_webui/src/api/lightrag.ts:1210— `checkEntityNameExists` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
Async function without AbortSignal: getTrackStatus lightrag_webui/src/api/lightrag.ts:1225— `getTrackStatus` awaits `axiosInstance.get(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axiosInstance.get(url, { signal })`.
D30 · Dependency Vulnerabilities· Medium CVE · ×18
Duplicated block (13 lines × 2) lightrag/kg/memgraph_impl.py:747— lightrag/kg/memgraph_impl.py:747-759 | lightrag/kg/neo4j_impl.py:1141-1153 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 2) REDACTED:1357— REDACTED:1357-1369 | REDACTED:1457-1469 — both copies are in the same file, so extract the 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) lightrag/kg/opensearch_impl.py:1665— lightrag/kg/opensearch_impl.py:1665-1677 | lightrag/kg/opensearch_impl.py:6861-6873 — both copies are in the same file, so extract the block into 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) lightrag/kg/opensearch_impl.py:2790— lightrag/kg/opensearch_impl.py:2790-2802 | lightrag/kg/opensearch_impl.py:2817-2829 — both copies are in the same file, so extract the block into 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) lightrag/kg/opensearch_impl.py:3051— lightrag/kg/opensearch_impl.py:3051-3065 | lightrag/kg/opensearch_impl.py:3373-3385 — both copies are in the same file, so extract the block into 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) REDACTED:3857— REDACTED:3857-3869 | REDACTED:7240-7252 — both copies are in the same file, so extract the 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:3857` 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 (13 lines × 2) lightrag/kg/scan_job_store.py:452— lightrag/kg/scan_job_store.py:452-464 | lightrag/kg/scan_job_store.py:539-551 — both copies are in the same file, so extract the 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) lightrag/operate.py:963— lightrag/operate.py:963-975 | lightrag/operate.py:1024-1036 — both copies are in the same file, so extract the 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) lightrag/operate.py:5459— lightrag/operate.py:5459-5471 | lightrag/operate.py:5474-5486 — both copies are in the same file, so extract the block into 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) lightrag/operate.py:5614— lightrag/operate.py:5614-5627 | lightrag/operate.py:5632-5644 — both copies are in the same file, so extract the 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 `lightrag/operate.py:5614` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) lightrag/parser/external/_common.py:36— lightrag/parser/external/_common.py:36-48 | lightrag/parser/external/mineru/cache.py:93-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 (13 lines × 2) lightrag/tools/migrate_llm_cache.py:1251— lightrag/tools/migrate_llm_cache.py:1251-1263 | lightrag/tools/migrate_llm_cache.py:1343-1355 — both copies are in the same file, so extract the 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 `lightrag/tools/migrate_llm_cache.py:1251` 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 (13 lines × 2) lightrag/api/lightrag_server.py:3391— lightrag/api/lightrag_server.py:3391-3403 | lightrag/api/run_with_gunicorn.py:17-29 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (13 lines × 2) examples/lightrag_ollama_demo.py:100— examples/lightrag_ollama_demo.py:100-112 | examples/lightrag_openai_compatible_demo.py:116-128 — before extracting anything, compare `examples/lightrag_ollama_demo.py` and `examples/lightrag_openai_compatible_demo.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/lightrag_ollama_demo.py:100` 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, `examples/lightrag_ollama_demo.py:115` calls `print_stream` and `examples/lightrag_openai_compatible_demo.py:131` 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.
R4 · Test Coverage· No test reaches this file · ×14
No test reaches this file lightrag_webui/src/components/ui/NumberInput.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.
No test reaches this file lightrag_webui/src/AppRouter.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.
No test reaches this file lightrag_webui/src/WorkspaceAppRouter.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.
No test reaches this file lightrag_webui/src/components/MigrationErrorScreen.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.
No test reaches this file lightrag_webui/src/components/LanguageToggle.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.
No test reaches this file lightrag_webui/src/components/ThemeToggle.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.
No test reaches this file lightrag_webui/src/bootstrap/webuiEntry.ts: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 lightrag_webui/src/components/ui/TabContent.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.
No test reaches this file lightrag_webui/src/components/ui/Badge.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.
No test reaches this file lightrag_webui/src/components/ui/Progress.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.
No test reaches this file lightrag_webui/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.
No test reaches this file lightrag_webui/src/workspace-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.
No test reaches this file lightrag_webui/src/contexts/useTabVisibility.ts: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 lightrag_webui/src/components/Root.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.
Duplicated block (9 lines × 2) lightrag/chunker/paragraph_semantic.py:484— lightrag/chunker/paragraph_semantic.py:484-492 | lightrag/chunker/paragraph_semantic.py:592-602 — both copies are in the same file, so extract the 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 (9 lines × 2) lightrag/kg/opensearch_impl.py:3115— lightrag/kg/opensearch_impl.py:3115-3123 | lightrag/kg/opensearch_impl.py:3466-3474 — both copies are in the same file, so extract the block into 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) REDACTED:5294— REDACTED:5294-5302 | REDACTED:5345-5353 — both copies are in the same file, so extract the block into 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) REDACTED:9349— REDACTED:9349-9357 | REDACTED:9360-9368 — both copies are in the same file, so extract the block into 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) lightrag/kg/redis_impl.py:614— lightrag/kg/redis_impl.py:614-622 | lightrag/kg/redis_impl.py:1181-1189 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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) REDACTED:471— REDACTED:471-479 | REDACTED:482-490 — both copies are in the same file, so extract the 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 (9 lines × 2) lightrag/parser/external/docling/ir_builder.py:586— lightrag/parser/external/docling/ir_builder.py:586-594 | lightrag/parser/external/docling/ir_builder.py:602-610 — both copies are in the same file, so extract the 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, `lightrag/parser/external/docling/ir_builder.py:601` calls `_has_usable_picture_image` and `lightrag/parser/external/docling/ir_builder.py:585` 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 × 2) lightrag/parser/routing.py:583— lightrag/parser/routing.py:583-591 | lightrag/parser/routing.py:613-621 — both copies are in the same file, so extract the block into 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) lightrag/tools/clean_llm_query_cache.py:616— lightrag/tools/clean_llm_query_cache.py:616-624 | lightrag/tools/clean_llm_query_cache.py:665-673 — both copies are in the same file, so extract the block into 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) reproduce/Step_1_openai_compatible.py:17— reproduce/Step_1_openai_compatible.py:17-25 | reproduce/Step_3_openai_compatible.py:15-23 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from 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) examples/lightrag_openai_compatible_demo.py:91— examples/lightrag_openai_compatible_demo.py:91-99 | examples/unofficial-sample/lightrag_embedding_prefixes.py:91-99 — before extracting anything, compare `examples/lightrag_openai_compatible_demo.py` and `examples/unofficial-sample/lightrag_embedding_prefixes.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. 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) lightrag_webui/src/migrations/splitSettingsStorage.ts:307— `catch` 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) lightrag_webui/src/migrations/splitSettingsStorage.ts:570— `catch` 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) lightrag/pipeline.py:6886— `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) lightrag/pipeline.py:8108— `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:1434— `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) lightrag/tools/clean_llm_query_cache.py:182— `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) lightrag/tools/migrate_llm_cache.py:191— `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) lightrag/parser/external/_common.py:135— `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) lightrag/parser/external/_common.py:147— `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:406— `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) lightrag/parser/docx/numbering_resolver.py:615— `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 (15 lines × 2) lightrag/api/routers/document_routes.py:6663— lightrag/api/routers/document_routes.py:6663-6677 | lightrag/api/routers/document_routes.py:6815-6829 — both copies are in the same file, so extract the block into 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) lightrag/kg/opensearch_impl.py:289— lightrag/kg/opensearch_impl.py:289-303 | REDACTED:310-324 — 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 `lightrag/kg/opensearch_impl.py:289` 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 (15 lines × 2) lightrag/kg/opensearch_impl.py:1681— lightrag/kg/opensearch_impl.py:1681-1695 | lightrag/kg/opensearch_impl.py:6873-6887 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:1681` 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) REDACTED:8875— REDACTED:8875-8889 | REDACTED:8891-8905 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) lightrag/kg/redis_impl.py:785— lightrag/kg/redis_impl.py:785-799 | lightrag/kg/redis_impl.py:1408-1422 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) lightrag/kg/redis_impl.py:1224— lightrag/kg/redis_impl.py:1224-1238 | lightrag/kg/redis_impl.py:1837-1851 — both copies are in the same file, so extract the block into 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) lightrag/llm/hf.py:266— lightrag/llm/hf.py:266-280 | lightrag/llm/llama_index_impl.py:186-200 — 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 (15 lines × 2) lightrag/utils_graph.py:808— lightrag/utils_graph.py:808-822 | lightrag/utils_graph.py:1910-1924 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) reproduce/Step_1.py:10— reproduce/Step_1.py:10-24 | reproduce/Step_1_openai_compatible.py:41-55 — before extracting anything, compare `reproduce/Step_1.py` and `reproduce/Step_1_openai_compatible.py` as WHOLE FILES: 91% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×7
Members sharing a duplicated core (4 members, 50+ identical tokens) lightrag/kg/json_doc_status_impl.py:770— lightrag/kg/json_doc_status_impl.py:770-804 | lightrag/kg/mongo_impl.py:1329-1353 | lightrag/kg/opensearch_impl.py:2970-2998 | lightrag/kg/redis_impl.py:2081-2102 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) lightrag/kg/memgraph_impl.py:915— lightrag/kg/memgraph_impl.py:915-943 | lightrag/kg/memgraph_impl.py:959-992 | lightrag/kg/neo4j_impl.py:1769-1790 | lightrag/kg/neo4j_impl.py:1832-1858 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) lightrag/kg/milvus_impl.py:2816— lightrag/kg/milvus_impl.py:2816-2872 | lightrag/kg/mongo_impl.py:219-258 | REDACTED:243-283 | lightrag/kg/qdrant_impl.py:660-705 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) lightrag/kg/milvus_impl.py:3475— lightrag/kg/milvus_impl.py:3475-3523 | lightrag/kg/mongo_impl.py:4426-4452 | REDACTED:4577-4629 | lightrag/kg/qdrant_impl.py:1353-1396 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:1857— REDACTED:1857-1885 | REDACTED:1888-1916 | REDACTED:1919-1973 | REDACTED:1976-2029 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:3266— REDACTED:3266-3284 | REDACTED:4518-4574 | REDACTED:5690-5708 | REDACTED:7482-7585 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:102— examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:102-135 | examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py:104-137 | examples/unofficial-sample/lightrag_llamaindex_litellm_opik_demo.py:115-148 | examples/unofficial-sample/lightrag_lmdeploy_demo.py:70-103 — 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 (18 lines × 2) lightrag/kg/memgraph_impl.py:449— lightrag/kg/memgraph_impl.py:449-466 | lightrag/kg/neo4j_impl.py:981-998 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 2) lightrag/kg/memgraph_impl.py:1243— lightrag/kg/memgraph_impl.py:1243-1260 | lightrag/kg/neo4j_impl.py:1866-1883 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/memgraph_impl.py:1240` calls `RuntimeError` and `lightrag/kg/neo4j_impl.py:1864` 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 (18 lines × 2) lightrag/kg/opensearch_impl.py:1195— lightrag/kg/opensearch_impl.py:1195-1212 | lightrag/kg/opensearch_impl.py:5149-5166 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:1195` 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 first that the copies are not typed on the same thing: the declarations holding them bind `batch_size` to `int = 1000` in one and `int` 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/opensearch_impl.py:5146` calls `_refresh_graph_indices_if_dirty` and `lightrag/kg/opensearch_impl.py:1192` 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 (18 lines × 2) lightrag/llm/anthropic.py:91— lightrag/llm/anthropic.py:91-108 | lightrag/llm/lmdeploy.py:115-132 — 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 (18 lines × 2) lightrag/operate.py:3728— lightrag/operate.py:3728-3745 | lightrag/operate.py:3812-3829 — both copies are in the same file, so extract the block into 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) lightrag/tools/clean_llm_query_cache.py:913— lightrag/tools/clean_llm_query_cache.py:913-930 | lightrag/tools/migrate_llm_cache.py:1385-1402 — 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. Note first that the copies are not typed on the same thing: the declarations holding them bind `stats` to `CleanupStats` in one and `MigrationStats` 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) lightrag/tools/migrate_llm_cache.py:392— lightrag/tools/migrate_llm_cache.py:392-409 | lightrag/tools/migrate_llm_cache.py:783-800 — both copies are in the same file, so extract the 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) lightrag/kg/opensearch_impl.py:3199— lightrag/kg/opensearch_impl.py:3199-3210 | lightrag/kg/opensearch_impl.py:3259-3270 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:3199` 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 (12 lines × 2) REDACTED:5376— REDACTED:5376-5387 | lightrag/kg/qdrant_impl.py:1225-1236 — 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) lightrag/kg/scan_job_store.py:439— lightrag/kg/scan_job_store.py:439-455 | lightrag/kg/scan_job_store.py:572-583 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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) lightrag/kg/shared_storage.py:3269— lightrag/kg/shared_storage.py:3269-3280 | lightrag/kg/shared_storage.py:3351-3362 — both copies are in the same file, so extract the 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) lightrag/parser/docx/numbering_resolver.py:187— lightrag/parser/docx/numbering_resolver.py:187-198 | lightrag/parser/docx/numbering_resolver.py:274-285 — both copies are in the same file, so extract the 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) examples/lightrag_azure_openai_demo.py:109— examples/lightrag_azure_openai_demo.py:109-120 | examples/lightrag_gemini_demo.py:106-117 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (8 lines × 2) lightrag/chunker/paragraph_semantic.py:1851— lightrag/chunker/paragraph_semantic.py:1851-1858 | lightrag/chunker/paragraph_semantic.py:1985-1992 — both copies are in the same file, so extract the block into 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) lightrag/llm/_vision_utils.py:59— lightrag/llm/_vision_utils.py:59-66 | lightrag/parser/markdown/parser.py:130-137 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. 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) lightrag/operate.py:718— lightrag/operate.py:718-725 | lightrag/operate.py:784-791 — both copies are in the same file, so extract the 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) lightrag/tools/clean_llm_query_cache.py:931— lightrag/tools/clean_llm_query_cache.py:931-938 | lightrag/tools/migrate_llm_cache.py:1403-1410 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (8 lines × 2) lightrag/kg/milvus_impl.py:3069— lightrag/kg/milvus_impl.py:3069-3076 | lightrag/kg/mongo_impl.py:4883-4890 — 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, `lightrag/kg/milvus_impl.py:3066` calls `result` and `lightrag/kg/mongo_impl.py:4880` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) reproduce/Step_3.py:8— reproduce/Step_3.py:8-15 | reproduce/Step_3_openai_compatible.py:39-46 — before extracting anything, compare `reproduce/Step_3.py` and `reproduce/Step_3_openai_compatible.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. 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.
TodoComment lightrag/lightrag.py:715— # TODO: Deprecated, use setup_logger in REDACTED instead — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment lightrag/lightrag.py:1276— # TODO: Deprecated (LightRAG will never initialize storage automatically on creation,and finalize should be call before destroying) — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment lightrag/lightrag.py:2379— # TODO: deprecated, use insert instead — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment lightrag/lightrag.py:2393— # TODO: deprecated, use ainsert instead — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment REDACTED:152— # TODO: Add support for m:rPr and m:scr to support different character styles — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
Duplicated block (32 lines × 2) lightrag/api/routers/document_routes.py:5657— lightrag/api/routers/document_routes.py:5657-5688 | lightrag/api/routers/document_routes.py:5821-5852 — both copies are in the same file, so extract the 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 `lightrag/api/routers/document_routes.py:5657` 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 (32 lines × 2) lightrag/pipeline.py:2002— lightrag/pipeline.py:2002-2033 | lightrag/pipeline.py:2053-2084 — both copies are in the same file, so extract the 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 (32 lines × 2) lightrag/tools/clean_llm_query_cache.py:152— lightrag/tools/clean_llm_query_cache.py:152-183 | lightrag/tools/migrate_llm_cache.py:161-192 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from 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 (32 lines × 2) lightrag/tools/clean_llm_query_cache.py:186— lightrag/tools/clean_llm_query_cache.py:186-217 | lightrag/tools/migrate_llm_cache.py:195-226 — 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 (32 lines × 2) lightrag/tools/clean_llm_query_cache.py:252— lightrag/tools/clean_llm_query_cache.py:252-283 | lightrag/tools/migrate_llm_cache.py:289-320 — 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 (30 lines × 2) REDACTED:703— REDACTED:703-732 | REDACTED:1091-1120 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (30 lines × 2) REDACTED:1060— REDACTED:1060-1089 | REDACTED:643-672 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1060` 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 (30 lines × 2) lightrag/kg/json_doc_status_impl.py:437— lightrag/kg/json_doc_status_impl.py:437-466 | lightrag/kg/redis_impl.py:1689-1718 — 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 (30 lines × 2) lightrag/operate.py:1943— lightrag/operate.py:1943-1972 | lightrag/operate.py:2135-2164 — both copies are in the same file, so extract the 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 `lightrag/operate.py:1943` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/operate.py:2133` calls `get` and `lightrag/operate.py:1942` 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 (30 lines × 2) lightrag/tools/clean_llm_query_cache.py:220— lightrag/tools/clean_llm_query_cache.py:220-249 | lightrag/tools/migrate_llm_cache.py:257-286 — 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 (21 lines × 2) lightrag/kg/memgraph_impl.py:1077— lightrag/kg/memgraph_impl.py:1077-1097 | lightrag/kg/neo4j_impl.py:1330-1350 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/memgraph_impl.py:1077` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/neo4j_impl.py:1329` calls `_get_raw_workspace_label` and `lightrag/kg/memgraph_impl.py:1076` 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 (21 lines × 2) lightrag/kg/mongo_impl.py:616— lightrag/kg/mongo_impl.py:616-636 | lightrag/kg/mongo_impl.py:889-909 — both copies are in the same file, so extract the 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) lightrag/llm/anthropic.py:191— lightrag/llm/anthropic.py:191-211 | lightrag/llm/openai.py:551-571 — 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, `lightrag/llm/openai.py:548` calls `str`, `lower`, `warning` and `lightrag/llm/anthropic.py:190` 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 (21 lines × 2) lightrag/llm/binding_options.py:184— lightrag/llm/binding_options.py:184-204 | lightrag/llm/binding_options.py:212-232 — both copies are in the same file, so extract the 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) lightrag/parser/external/_manifest.py:94— lightrag/parser/external/_manifest.py:94-114 | lightrag/parser/external/mineru/manifest.py:92-112 — before extracting anything, compare `lightrag/parser/external/_manifest.py` and `lightrag/parser/external/mineru/manifest.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lightrag/parser/external/_manifest.py:115` calls `dict`, `get` and `lightrag/parser/external/mineru/manifest.py:113` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (19 lines × 2) REDACTED:1798— REDACTED:1798-1816 | REDACTED:1406-1424 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19 lines × 2) lightrag/kg/redis_impl.py:828— lightrag/kg/redis_impl.py:828-846 | lightrag/kg/redis_impl.py:2836-2854 — both copies are in the same file, so extract the 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 `lightrag/kg/redis_impl.py:828` 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 (19 lines × 2) lightrag/llm/zhipu.py:109— lightrag/llm/zhipu.py:109-127 | lightrag/llm/zhipu.py:223-241 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (19 lines × 2) lightrag/parser/param_schema.py:212— lightrag/parser/param_schema.py:212-230 | lightrag/parser/param_schema.py:526-544 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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) lightrag/tools/clean_llm_query_cache.py:131— lightrag/tools/clean_llm_query_cache.py:131-149 | lightrag/tools/migrate_llm_cache.py:140-158 — 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 (15–18 lines × 2) lightrag/chunker/paragraph_semantic.py:495— lightrag/chunker/paragraph_semantic.py:495-509 | lightrag/chunker/paragraph_semantic.py:605-622 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15–18 lines × 2) lightrag/kg/redis_impl.py:1313— lightrag/kg/redis_impl.py:1313-1327 | lightrag/kg/redis_impl.py:1370-1387 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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–18 lines × 2) lightrag/operate.py:3214— lightrag/operate.py:3214-3228 | lightrag/operate.py:3345-3362 — both copies are in the same file, so extract the 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 `lightrag/operate.py:3214` 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, `lightrag/operate.py:3343` calls `upsert_node` and `lightrag/operate.py:3213` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15–18 lines × 2) lightrag/pipeline.py:4183— lightrag/pipeline.py:4183-4200 | lightrag/pipeline.py:4229-4243 — both copies are in the same file, so extract the 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 `lightrag/pipeline.py:4183` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–18 lines × 2) REDACTED:1476— REDACTED:1476-1493 | REDACTED:1753-1767 — both copies are in the same file, so extract the block into 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) lightrag/kg/opensearch_impl.py:3212— lightrag/kg/opensearch_impl.py:3212-3227 | lightrag/kg/opensearch_impl.py:3271-3286 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:3212` 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) lightrag/kg/opensearch_impl.py:5886— lightrag/kg/opensearch_impl.py:5886-5901 | lightrag/kg/opensearch_impl.py:5935-5950 — both copies are in the same file, so extract the 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) REDACTED:3963— REDACTED:3963-3978 | REDACTED:7263-7278 — both copies are in the same file, so extract the 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) lightrag/kg/redis_impl.py:2251— lightrag/kg/redis_impl.py:2251-2266 | lightrag/kg/redis_impl.py:2296-2313 — both copies are in the same file, so extract the 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) lightrag/parser/param_schema.py:243— lightrag/parser/param_schema.py:243-258 | lightrag/parser/param_schema.py:562-577 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/parser/param_schema.py:243` 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–10 lines × 2) lightrag/api/routers/ollama_api.py:702— lightrag/api/routers/ollama_api.py:702-710 | lightrag/api/routers/ollama_api.py:871-880 — both copies are in the same file, so extract the 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 `lightrag/api/routers/ollama_api.py:702` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) lightrag/kg/opensearch_impl.py:1882— lightrag/kg/opensearch_impl.py:1882-1890 | lightrag/kg/opensearch_impl.py:3654-3663 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:1882` 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 `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 (9–10 lines × 2) REDACTED:8326— REDACTED:8326-8334 | REDACTED:8450-8459 — both copies are in the same file, so extract the 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:8326` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) lightrag/parser/external/_manifest.py:148— lightrag/parser/external/_manifest.py:148-156 | lightrag/parser/external/mineru/manifest.py:142-151 — before extracting anything, compare `lightrag/parser/external/_manifest.py` and `lightrag/parser/external/mineru/manifest.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (9–10 lines × 2) lightrag/tools/migrate_llm_cache.py:376— lightrag/tools/migrate_llm_cache.py:376-385 | lightrag/tools/migrate_llm_cache.py:766-774 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
AC2 · Forms & labels· <Select> field component without a label · ×4
<Select> field component without a label lightrag_webui/src/components/AppSettings.tsx:57— This UI-library field component has no label / aria-label / aria-labelledby / id, and nothing it renders carries one either (a name prop is the form-submission key, not a label). The text inside it does not stand in for one: these compound APIs render a trigger with role="combobox" (or role="button"), and those roles take their name from the AUTHOR, not from their content — so the words on screen never reach the accessibility tree as a name. Name it 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.
<Select> field component without a label lightrag_webui/src/components/AppSettings.tsx:80— This UI-library field component has no label / aria-label / aria-labelledby / id, and nothing it renders carries one either (a name prop is the form-submission key, not a label). The text inside it does not stand in for one: these compound APIs render a trigger with role="combobox" (or role="button"), and those roles take their name from the AUTHOR, not from their content — so the words on screen never reach the accessibility tree as a name. Name it 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.
<Select> field component without a label lightrag_webui/src/components/ui/PaginationControls.tsx:164— This UI-library field component has no label / aria-label / aria-labelledby / id, and nothing it renders carries one either (a name prop is the form-submission key, not a label). The text inside it does not stand in for one: these compound APIs render a trigger with role="combobox" (or role="button"), and those roles take their name from the AUTHOR, not from their content — so the words on screen never reach the accessibility tree as a name. Name it 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.
<Select> field component without a label lightrag_webui/src/components/ui/PaginationControls.tsx:257— This UI-library field component has no label / aria-label / aria-labelledby / id, and nothing it renders carries one either (a name prop is the form-submission key, not a label). The text inside it does not stand in for one: these compound APIs render a trigger with role="combobox" (or role="button"), and those roles take their name from the AUTHOR, not from their content — so the words on screen never reach the accessibility tree as a name. Name it 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.
Duplicated block (29 lines × 2) lightrag/api/routers/document_routes.py:5614— lightrag/api/routers/document_routes.py:5614-5642 | lightrag/api/routers/document_routes.py:5771-5799 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lightrag/api/routers/document_routes.py:5806` calls `_reweight_enqueue_slot` and `lightrag/api/routers/document_routes.py:5645` 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 (29 lines × 2) lightrag/operate.py:6498— lightrag/operate.py:6498-6526 | lightrag/operate.py:6795-6823 — both copies are in the same file, so extract the 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 `lightrag/operate.py:6498` 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 lines × 2) lightrag/utils_graph.py:1087— lightrag/utils_graph.py:1087-1115 | lightrag/utils_graph.py:3003-3031 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (29 lines × 2) examples/lightrag_gemini_postgres_demo.py:133— examples/lightrag_gemini_postgres_demo.py:133-161 | examples/lightrag_openai_opensearch_graph_demo.py:133-161 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (24 lines × 2) lightrag/kg/memgraph_impl.py:650— lightrag/kg/memgraph_impl.py:650-673 | lightrag/kg/neo4j_impl.py:1273-1296 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (24 lines × 2) lightrag/kg/shared_storage.py:3420— lightrag/kg/shared_storage.py:3420-3443 | lightrag/kg/shared_storage.py:3613-3636 — both copies are in the same file, so extract the block into 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) lightrag/parser/docx/utils.py:587— lightrag/parser/docx/utils.py:587-610 | lightrag/parser/docx/utils.py:663-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. 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 (24 lines × 2) reproduce/Step_3.py:29— reproduce/Step_3.py:29-52 | reproduce/Step_3_openai_compatible.py:60-83 — before extracting anything, compare `reproduce/Step_3.py` and `reproduce/Step_3_openai_compatible.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (20 lines × 2) REDACTED:1818— REDACTED:1818-1837 | REDACTED:1426-1445 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (20 lines × 2) lightrag/kg/memgraph_impl.py:971— lightrag/kg/memgraph_impl.py:971-990 | lightrag/kg/neo4j_impl.py:1837-1856 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (20 lines × 2) REDACTED:3885— REDACTED:3885-3904 | REDACTED:7025-7044 — both copies are in the same file, so extract the 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 lines × 2) lightrag/operate.py:3768— lightrag/operate.py:3768-3787 | lightrag/operate.py:3865-3884 — both copies are in the same file, so extract the 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 `lightrag/operate.py:3768` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) lightrag/kg/json_doc_status_impl.py:107— lightrag/kg/json_doc_status_impl.py:107-123 | lightrag/kg/json_kv_impl.py:72-88 — before extracting anything, compare `lightrag/kg/json_doc_status_impl.py` and `lightrag/kg/json_kv_impl.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 200 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (17 lines × 2) lightrag/kg/opensearch_impl.py:5339— lightrag/kg/opensearch_impl.py:5339-5355 | lightrag/kg/opensearch_impl.py:5959-5975 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17 lines × 2) lightrag/utils_graph.py:3333— lightrag/utils_graph.py:3333-3357 | lightrag/utils_graph.py:3359-3375 — both copies are in the same file, so extract the 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 `lightrag/utils_graph.py:3333` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) lightrag/kg/mongo_impl.py:173— lightrag/kg/mongo_impl.py:173-189 | lightrag/kg/opensearch_impl.py:633-649 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. 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–15 lines × 2) lightrag/api/routers/graph_routes.py:896— lightrag/api/routers/graph_routes.py:896-908 | lightrag/api/routers/graph_routes.py:940-954 — both copies are in the same file, so extract the 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 `lightrag/api/routers/graph_routes.py:896` 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 (13–15 lines × 2) lightrag/chunker/paragraph_semantic.py:1870— lightrag/chunker/paragraph_semantic.py:1870-1882 | lightrag/chunker/paragraph_semantic.py:2012-2026 — both copies are in the same file, so extract the 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 `lightrag/chunker/paragraph_semantic.py:1870` 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) lightrag/kg/mongo_impl.py:2074— lightrag/kg/mongo_impl.py:2074-2088 | lightrag/kg/opensearch_impl.py:682-694 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lightrag/kg/mongo_impl.py:2098` calls `set`, `_edge_source_id_list` and `lightrag/kg/opensearch_impl.py:695` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–15 lines × 2) lightrag/kg/opensearch_impl.py:1638— lightrag/kg/opensearch_impl.py:1638-1652 | lightrag/kg/opensearch_impl.py:6837-6849 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 2) lightrag/kg/mongo_impl.py:4238— lightrag/kg/mongo_impl.py:4238-4252 | lightrag/kg/qdrant_impl.py:518-531 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (14–15 lines × 2) lightrag/kg/opensearch_impl.py:1434— lightrag/kg/opensearch_impl.py:1434-1448 | lightrag/kg/opensearch_impl.py:2365-2378 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 2) lightrag/kg/redis_impl.py:451— lightrag/kg/redis_impl.py:451-465 | lightrag/kg/redis_impl.py:1069-1082 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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, `lightrag/kg/redis_impl.py:1087` calls `_rebuild_scheduling_sidecar` and `lightrag/kg/redis_impl.py:466` 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–15 lines × 2) lightrag/operate.py:1994— lightrag/operate.py:1994-2007 | lightrag/operate.py:2210-2224 — both copies are in the same file, so extract the 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 `lightrag/operate.py:1994` 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) lightrag/chunker/paragraph_semantic.py:1888— lightrag/chunker/paragraph_semantic.py:1888-1901 | lightrag/chunker/paragraph_semantic.py:2031-2044 — both copies are in the same file, so extract the 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 `lightrag/chunker/paragraph_semantic.py: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.
Duplicated block (14 lines × 2) lightrag/kg/opensearch_impl.py:5168— lightrag/kg/opensearch_impl.py:5168-5181 | lightrag/kg/opensearch_impl.py:5987-6000 — both copies are in the same file, so extract the 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) REDACTED:3337— REDACTED:3337-3350 | REDACTED:3514-3527 — both copies are in the same file, so extract the block into 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) lightrag/operate.py:5674— lightrag/operate.py:5674-5687 | lightrag/operate.py:5694-5707 — both copies are in the same file, so extract the 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) examples/generate_query.py:9— examples/generate_query.py:9-19 | reproduce/Step_2.py:9-19 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (11 lines × 2) lightrag/kg/memgraph_impl.py:548— lightrag/kg/memgraph_impl.py:548-558 | lightrag/kg/memgraph_impl.py:640-650 — both copies are in the same file, so extract the 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, `lightrag/kg/memgraph_impl.py:543` calls `ValueError` and `lightrag/kg/memgraph_impl.py:637` 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) lightrag/multimodal_context.py:442— lightrag/multimodal_context.py:442-452 | lightrag/multimodal_context.py:476-486 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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, `lightrag/multimodal_context.py:439` calls `dumps` and `lightrag/multimodal_context.py:473` 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 lines × 2) REDACTED:207— REDACTED:207-217 | REDACTED:547-557 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2 locations) lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:145— lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:145 · lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:159 — both copies are in the same file, so extract the block into 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 locations) lightrag_webui/src/components/retrieval/QuerySettings.tsx:449— lightrag_webui/src/components/retrieval/QuerySettings.tsx:449 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:522 — both copies are in the same file, so extract the block into 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 locations) lightrag_webui/src/components/ui/Select.tsx:33— lightrag_webui/src/components/ui/Select.tsx:33 · lightrag_webui/src/components/ui/Select.tsx:47 — 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 (13 lines × 2 locations) lightrag_webui/src/features/DocumentManager.tsx:1735— lightrag_webui/src/features/DocumentManager.tsx:1735 · lightrag_webui/src/features/DocumentManager.tsx:1748 — 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.
TooManyMethods: _PipelineMixin lightrag/pipeline.py:624— TooManyMethods — 56 methods. The bar is 30 methods; this is 26 over it, 1.87× 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: PostgreSQLDB REDACTED:456— TooManyMethods — 38 methods. The bar is 30 methods; this is 8 over it, 1.27× 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: MigrationTool lightrag/tools/migrate_llm_cache.py:129— TooManyMethods — 35 methods. The bar is 30 methods; this is 5 over it, 1.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Duplicated block (28 lines × 2) lightrag/operate.py:2532— lightrag/operate.py:2532-2559 | lightrag/operate.py:2912-2939 — both copies are in the same file, so extract the 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 `lightrag/operate.py:2532` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/operate.py:2911` calls `get` and `lightrag/operate.py:2531` 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 lines × 2) lightrag/operate.py:2698— lightrag/operate.py:2698-2725 | lightrag/operate.py:3129-3156 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (28 lines × 2) lightrag/rerank.py:524— lightrag/rerank.py:524-551 | lightrag/rerank.py:564-591 — both copies are in the same file, so extract the 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 `lightrag/rerank.py:524` 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 (24–26 lines × 2) lightrag/api/routers/graph_routes.py:516— lightrag/api/routers/graph_routes.py:516-541 | lightrag/api/routers/graph_routes.py:652-675 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/api/routers/graph_routes.py:516` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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–26 lines × 2) lightrag/kg/memgraph_impl.py:414— lightrag/kg/memgraph_impl.py:414-439 | lightrag/kg/neo4j_impl.py:940-963 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (24–26 lines × 2) lightrag/kg/redis_impl.py:425— lightrag/kg/redis_impl.py:425-448 | lightrag/kg/redis_impl.py:1041-1066 — both copies are in the same file, so extract the 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 `lightrag/kg/redis_impl.py:1041` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) lightrag/kg/redis_impl.py:485— lightrag/kg/redis_impl.py:485-506 | lightrag/kg/redis_impl.py:1099-1120 — both copies are in the same file, so extract the 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, `lightrag/kg/redis_impl.py:1094` calls `close` and `lightrag/kg/redis_impl.py:480` 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 lines × 2) lightrag/operate.py:2586— lightrag/operate.py:2586-2607 | lightrag/operate.py:3022-3043 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22 lines × 2) lightrag/kg/json_doc_status_impl.py:558— lightrag/kg/json_doc_status_impl.py:558-580 | lightrag/kg/json_kv_impl.py:398-419 — before extracting anything, compare `lightrag/kg/json_doc_status_impl.py` and `lightrag/kg/json_kv_impl.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 200 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (18–19 lines × 2) lightrag/kg/opensearch_impl.py:1192— lightrag/kg/opensearch_impl.py:1192-1210 | lightrag/kg/opensearch_impl.py:2485-2502 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18–19 lines × 2) lightrag/operate.py:2668— lightrag/operate.py:2668-2685 | lightrag/operate.py:3098-3116 — both copies are in the same file, so extract the 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 `lightrag/operate.py:2668` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18–19 lines × 2) lightrag/pipeline.py:4433— lightrag/pipeline.py:4433-4451 | lightrag/pipeline.py:4817-4834 — both copies are in the same file, so extract the 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–13 lines × 2) REDACTED:116— REDACTED:116-128 | REDACTED:109-120 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (12–13 lines × 2) REDACTED:6473— REDACTED:6473-6484 | REDACTED:6751-6763 — both copies are in the same file, so extract the 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–13 lines × 2) lightrag/parser/external/docling/ir_builder.py:164— lightrag/parser/external/docling/ir_builder.py:164-175 | lightrag/parser/external/mineru/ir_builder.py:242-254 — 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 `lightrag/parser/external/docling/ir_builder.py:164` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–12 lines × 2) lightrag/kg/neo4j_impl.py:365— lightrag/kg/neo4j_impl.py:365-376 | lightrag/kg/neo4j_impl.py:409-419 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lightrag/kg/neo4j_impl.py:380` calls `get` and `lightrag/kg/neo4j_impl.py:422` 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–12 lines × 2) lightrag/kg/opensearch_impl.py:1216— lightrag/kg/opensearch_impl.py:1216-1227 | lightrag/kg/opensearch_impl.py:2518-2528 — both copies are in the same file, so extract the 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 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 (11–12 lines × 2) lightrag/parser/external/docling/ir_builder.py:725— lightrag/parser/external/docling/ir_builder.py:725-735 | lightrag/parser/external/docling/ir_builder.py:880-891 — both copies are in the same file, so extract the 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 `lightrag/parser/external/docling/ir_builder.py:880` 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) lightrag/chunk_schema.py:307— lightrag/chunk_schema.py:307-316 | lightrag/chunk_schema.py:320-329 — both copies are in the same file, so extract the 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 (10 lines × 2) lightrag/parser/external/_common.py:90— lightrag/parser/external/_common.py:90-99 | lightrag/parser/external/mineru/cache.py:128-137 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. 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) examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py:64— examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py:64-73 | examples/unofficial-sample/lightrag_llamaindex_litellm_opik_demo.py:75-84 — before extracting anything, compare `examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py` and `examples/unofficial-sample/lightrag_llamaindex_litellm_opik_demo.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) lightrag/chunker/semantic_vector.py:381— lightrag/chunker/semantic_vector.py:381-386 | lightrag/chunker/token_size.py:35-40 — 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 (6 lines × 2) lightrag/kg/mongo_impl.py:164— lightrag/kg/mongo_impl.py:164-169 | lightrag/kg/opensearch_impl.py:624-629 — 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 (6 lines × 2) lightrag/parser/external/_common.py:81— lightrag/parser/external/_common.py:81-86 | lightrag/parser/external/mineru/cache.py:119-124 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. 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 locations) lightrag_webui/src/components/graph/PropertiesView.tsx:191— lightrag_webui/src/components/graph/PropertiesView.tsx:191 · lightrag_webui/src/components/graph/PropertyEditDialog.tsx:43 — 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 (8 lines × 2 locations) lightrag_webui/src/hooks/useLightragGraph.tsx:255— lightrag_webui/src/hooks/useLightragGraph.tsx:255 · lightrag_webui/src/hooks/useLightragGraph.tsx:286 — 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 (8 lines × 2 locations) lightrag_webui/src/hooks/useLightragGraph.tsx:817— lightrag_webui/src/hooks/useLightragGraph.tsx:817 · lightrag_webui/src/hooks/useLightragGraph.tsx:827 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
cache.is_bundle_valid (cyclomatic 21) lightrag/parser/external/docling/cache.py:146— cache.is_bundle_valid 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.
cache.is_bundle_valid (cyclomatic 21) lightrag/parser/external/mineru/cache.py:333— cache.is_bundle_valid 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.
D4 · Code Duplication· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×2
Members sharing a duplicated core (6 members, 50+ identical tokens) examples/lightrag_ollama_demo.py:19— examples/lightrag_ollama_demo.py:19-78 | examples/lightrag_openai_compatible_demo.py:20-81 | examples/lightrag_openai_demo.py:13-72 | examples/unofficial-sample/lightrag_cloudflare_demo.py:132-193 | examples/unofficial-sample/lightrag_embedding_prefixes.py:20-81 | lightrag/api/lightrag_server.py:3310-3387 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) lightrag/kg/opensearch_impl.py:1340— lightrag/kg/opensearch_impl.py:1340-1404 | lightrag/kg/opensearch_impl.py:1407-1460 | lightrag/kg/opensearch_impl.py:2321-2352 | lightrag/kg/opensearch_impl.py:2355-2390 | lightrag/kg/opensearch_impl.py:3186-3237 | lightrag/kg/opensearch_impl.py:3245-3305 — 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 (5 members, 50+ identical tokens) · ×2
Members sharing a duplicated core (5 members, 50+ identical tokens) lightrag/kg/milvus_impl.py:3185— lightrag/kg/milvus_impl.py:3185-3196 | lightrag/kg/mongo_impl.py:4869-4880 | lightrag/kg/opensearch_impl.py:7209-7225 | REDACTED:5103-5119 | lightrag/kg/qdrant_impl.py:1013-1024 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) examples/lightrag_ollama_demo.py:121— examples/lightrag_ollama_demo.py:121-212 | examples/lightrag_openai_compatible_demo.py:132-222 | examples/lightrag_openai_demo.py:93-180 | examples/unofficial-sample/lightrag_cloudflare_demo.py:233-347 | examples/unofficial-sample/lightrag_embedding_prefixes.py:137-228 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Duplicated block (40 lines × 2) lightrag/operate.py:2626— lightrag/operate.py:2626-2665 | lightrag/operate.py:3059-3098 — both copies are in the same file, so extract the 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 `lightrag/operate.py:2626` 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, `lightrag/operate.py:2666` calls `get` and `lightrag/operate.py:3101` 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 (40 lines × 2) REDACTED:1526— REDACTED:1526-1565 | REDACTED:1128-1170 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (34 lines × 2) REDACTED:5928— REDACTED:5928-5961 | REDACTED:6006-6039 — both copies are in the same file, so extract the 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:5928` 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 (34 lines × 2) lightrag/kg/redis_impl.py:509— lightrag/kg/redis_impl.py:509-542 | lightrag/kg/redis_impl.py:1123-1156 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23–25 lines × 2) lightrag/kg/memgraph_impl.py:369— lightrag/kg/memgraph_impl.py:369-393 | lightrag/kg/neo4j_impl.py:1729-1751 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/memgraph_impl.py:369` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (23–25 lines × 2) lightrag/kg/mongo_impl.py:4614— lightrag/kg/mongo_impl.py:4614-4636 | lightrag/kg/qdrant_impl.py:772-796 — 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 (25 lines × 2) lightrag/kg/memgraph_impl.py:1273— lightrag/kg/memgraph_impl.py:1273-1297 | lightrag/kg/neo4j_impl.py:1892-1916 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `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 (25 lines × 2) lightrag/parser/external/docling/cache.py:223— lightrag/parser/external/docling/cache.py:223-247 | lightrag/parser/external/mineru/cache.py:394-418 — 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 (23–24 lines × 2) lightrag/kg/memgraph_impl.py:38— lightrag/kg/memgraph_impl.py:38-60 | lightrag/kg/neo4j_impl.py:92-115 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (23–24 lines × 2) REDACTED:476— REDACTED:476-499 | lightrag/parser/docx/table_extractor.py:73-95 — 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:476` 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 (22–23 lines × 2) REDACTED:4494— REDACTED:4494-4515 | lightrag/kg/qdrant_impl.py:493-515 — 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:4494` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–23 lines × 2) lightrag/operate.py:6445— lightrag/operate.py:6445-6467 | lightrag/operate.py:6740-6761 — both copies are in the same file, so extract the 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 `lightrag/operate.py:6445` 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 (21–23 lines × 2) lightrag/operate.py:2313— lightrag/operate.py:2313-2335 | lightrag/operate.py:3389-3409 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (21–23 lines × 2) lightrag/parser/external/_base.py:89— lightrag/parser/external/_base.py:89-111 | lightrag/parser/native_base.py:227-247 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (19–20 lines × 2) lightrag/kg/memgraph_impl.py:811— lightrag/kg/memgraph_impl.py:811-830 | lightrag/kg/neo4j_impl.py:1170-1188 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/memgraph_impl.py:811` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19–20 lines × 2) lightrag/operate.py:4325— lightrag/operate.py:4325-4344 | lightrag/operate.py:4346-4364 — both copies are in the same file, so extract the 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 `lightrag/operate.py:4325` 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–17 lines × 2) lightrag/kg/memgraph_impl.py:860— lightrag/kg/memgraph_impl.py:860-876 | lightrag/kg/neo4j_impl.py:1220-1235 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (16–17 lines × 2) lightrag/llm/anthropic.py:169— lightrag/llm/anthropic.py:169-185 | lightrag/llm/openai.py:507-522 — 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 `lightrag/llm/openai.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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lightrag/llm/openai.py:523` calls `is_permanent_rate_limit_error` and `lightrag/llm/anthropic.py:186` 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 × 3) lightrag/kg/memgraph_impl.py:1272— lightrag/kg/memgraph_impl.py:1272-1291 | lightrag/kg/memgraph_impl.py:1352-1367 | lightrag/kg/neo4j_impl.py:1891-1910 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/memgraph_impl.py:1269` calls `RuntimeError` and `lightrag/kg/neo4j_impl.py:1889` 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 × 3) REDACTED:3266— REDACTED:3266-3281 | REDACTED:5690-5705 | REDACTED:7482-7497 — 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 (15 lines × 4) lightrag/kg/milvus_impl.py:3401— lightrag/kg/milvus_impl.py:3401-3415 | lightrag/kg/mongo_impl.py:5046-5060 | lightrag/kg/opensearch_impl.py:7137-7151 | lightrag/kg/qdrant_impl.py:1268-1282 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. 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) REDACTED:3270— REDACTED:3270-3284 | REDACTED:4537-4551 | REDACTED:5694-5708 | REDACTED:7486-7500 — 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:3270` 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 × 3) REDACTED:4940— REDACTED:4940-4953 | REDACTED:4958-4971 | REDACTED:4973-4986 — 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:4940` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:4938` calls `write`, `join`, `keys` and `REDACTED:4973` 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 (14 lines × 3) examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:84— examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:84-97 | examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py:86-99 | examples/unofficial-sample/lightrag_llamaindex_litellm_opik_demo.py:97-110 — before extracting anything, compare `examples/unofficial-sample/lightrag_llamaindex_direct_demo.py` and `examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 3) lightrag/kg/scan_job_store.py:449— lightrag/kg/scan_job_store.py:449-458 | lightrag/kg/scan_job_store.py:536-545 | lightrag/kg/scan_job_store.py:577-586 — 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 `lightrag/kg/scan_job_store.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. 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 × 3) REDACTED:493— REDACTED:493-502 | REDACTED:507-516 | REDACTED:559-568 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) REDACTED:5808— REDACTED:5808-5817 | REDACTED:5940-5948 | REDACTED:6018-6026 | REDACTED:6930-6939 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) lightrag/llm/hf.py:80— lightrag/llm/hf.py:80-88 | REDACTED:3298-3306 | REDACTED:3363-3371 | REDACTED:4031-4039 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. 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 × 3) lightrag/kg/opensearch_impl.py:2790— lightrag/kg/opensearch_impl.py:2790-2798 | lightrag/kg/opensearch_impl.py:2816-2825 | lightrag/kg/opensearch_impl.py:2923-2931 — 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 `lightrag/kg/opensearch_impl.py:2790` 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 (9 lines × 3) lightrag/kg/json_doc_status_impl.py:1080— lightrag/kg/json_doc_status_impl.py:1080-1088 | lightrag/kg/mongo_impl.py:1559-1567 | REDACTED:6501-6509 — 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 (8 lines × 3) lightrag/kg/opensearch_impl.py:1881— lightrag/kg/opensearch_impl.py:1881-1888 | lightrag/kg/opensearch_impl.py:3653-3662 | lightrag/kg/opensearch_impl.py:7323-7332 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 3) lightrag/kg/mongo_impl.py:4228— lightrag/kg/mongo_impl.py:4228-4235 | lightrag/kg/opensearch_impl.py:6232-6239 | lightrag/kg/qdrant_impl.py:182-189 — 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.
R10 · Code Duplication· Duplicated block with local edits (39 matched lines × 2 locations) · ×2
Duplicated block with local edits (39 matched lines × 2 locations) lightrag_webui/src/AppRouter.tsx:20— lightrag_webui/src/AppRouter.tsx:20 · lightrag_webui/src/WorkspaceAppRouter.tsx:32 — the two spans are one implementation copied and then locally edited — 174 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 with local edits (39 matched lines × 2 locations) lightrag_webui/src/components/ui/PaginationControls.tsx:140— lightrag_webui/src/components/ui/PaginationControls.tsx:140 · lightrag_webui/src/components/ui/PaginationControls.tsx:219 — the two spans are one implementation copied and then locally edited — 200 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 (12 lines × 5 locations) lightrag_webui/src/components/retrieval/QuerySettings.tsx:166— lightrag_webui/src/components/retrieval/QuerySettings.tsx:166 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:446 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:467 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:493 · +1 more site(s) not listed — 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 (12 lines × 5 locations) lightrag_webui/src/features/DocumentManager.tsx:1578— lightrag_webui/src/features/DocumentManager.tsx:1578 · lightrag_webui/src/features/DocumentManager.tsx:1590 · lightrag_webui/src/features/DocumentManager.tsx:1602 · lightrag_webui/src/features/DocumentManager.tsx:1614 · +1 more site(s) not listed — 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 (9 lines × 2 locations) lightrag_webui/src/components/graph/Settings.tsx:349— lightrag_webui/src/components/graph/Settings.tsx:349 · lightrag_webui/src/components/graph/Settings.tsx:365 — both copies are in the same file, so extract the block into 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 locations) lightrag_webui/src/components/status/StatusCard.tsx:201— lightrag_webui/src/components/status/StatusCard.tsx:201 · lightrag_webui/src/components/status/StatusCard.tsx:210 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
X17 · Uncapped recursion over a caller-supplied document· Recursive walk over a caller-supplied document has no depth cap · ×2
Recursive walk over a caller-supplied document has no depth cap REDACTED:1402— `extract_content_list_from_payload` is public and takes `payload: Any` from its caller, and it calls itself at line 1402 (`extract_content_list_from_payload`) with a piece of `payload` (and at line 1406, line 1412) — and nowhere in `extract_content_list_from_payload` 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 `extract_content_list_from_payload` 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 lightrag/tools/migrate_graph_storage.py:140— `payloads_equal` is public and takes `a: Any` from its caller, and it calls itself at line 140 (`payloads_equal`) with a piece of `a` (and at line 143) — and nowhere in `payloads_equal` 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 `payloads_equal` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
X24 · Document value interpolated into markup unescaped· Untrusted text written into markup unescaped · ×2
Untrusted text written into markup unescaped lightrag_webui/src/components/retrieval/ChatMessage.tsx:578— `svg` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped lightrag_webui/src/utils/entityName.ts:28— `value` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
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 81 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.
DocumentManager.DocumentManager (cyclomatic 152) lightrag_webui/src/features/DocumentManager.tsx:381— DocumentManager.DocumentManager has cyclomatic complexity 152 (threshold 15). Of this number, 54 points are the body's own statements and 98 belong to 28 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.
useLightragGraph.useLightrangeGraph (cyclomatic 102) lightrag_webui/src/hooks/useLightragGraph.tsx:328— useLightragGraph.useLightrangeGraph has cyclomatic complexity 102 (threshold 15). Most of this is not in the body itself: 1 of the 102 points is its own statement and the rest belongs to 14 function literals inside it that branch (lines 681, 477, 1103, …). 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.
operate._merge_edges_then_upsert (cyclomatic 90) lightrag/operate.py:2782— operate._merge_edges_then_upsert has cyclomatic complexity 90 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LightRAG._purge_derived_kg_contributions (cyclomatic 84) lightrag/lightrag.py:6265— LightRAG._purge_derived_kg_contributions has cyclomatic complexity 84 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
GraphControl.GraphControl (cyclomatic 78) lightrag_webui/src/components/graph/GraphControl.tsx:23— GraphControl.GraphControl has cyclomatic complexity 78 (threshold 15). Most of this is not in the body itself: 2 of the 78 points are its own statements and the rest belongs to 23 function literals inside it that branch (lines 374, 426, 459, …). 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.
_PipelineMixin.process_single_document (cyclomatic 74) lightrag/pipeline.py:4991— _PipelineMixin.process_single_document has cyclomatic complexity 74 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
heading_flow.gate_candidates (cyclomatic 71) lightrag/parser/docx/smart_heading/heading_flow.py:391— heading_flow.gate_candidates has cyclomatic complexity 71 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
_PipelineMixin.apipeline_enqueue_documents (cyclomatic 71) lightrag/pipeline.py:740— _PipelineMixin.apipeline_enqueue_documents has cyclomatic complexity 71 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
title_block.find_title_block_candidates (cyclomatic 66) lightrag/parser/docx/smart_heading/title_block.py:504— title_block.find_title_block_candidates has cyclomatic complexity 66 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LightRAG.ainsert_custom_chunks (cyclomatic 65) lightrag/lightrag.py:2394— LightRAG.ainsert_custom_chunks has cyclomatic complexity 65 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LightRAG.adelete_by_doc_id (cyclomatic 63) lightrag/lightrag.py:6727— LightRAG.adelete_by_doc_id 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.
openai.openai_complete_if_cache (cyclomatic 63) lightrag/llm/openai.py:305— openai.openai_complete_if_cache 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.
_PipelineMixin.analyze_multimodal (cyclomatic 63) lightrag/pipeline.py:6841— _PipelineMixin.analyze_multimodal 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.
utils_graph._merge_entities_impl (cyclomatic 63) lightrag/utils_graph.py:2703— utils_graph._merge_entities_impl 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.
ChatMessage.ChatMessage (cyclomatic 57) lightrag_webui/src/components/retrieval/ChatMessage.tsx:57— ChatMessage.ChatMessage has cyclomatic complexity 57 (threshold 15). Of this number, 46 points are the body's own statements and 11 belong to 5 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.
operate._merge_nodes_then_upsert (cyclomatic 55) lightrag/operate.py:2429— operate._merge_nodes_then_upsert 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.
heading_flow.run_smart_heading (cyclomatic 54) lightrag/parser/docx/smart_heading/heading_flow.py:2942— heading_flow.run_smart_heading 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.
lightrag_server.create_app (cyclomatic 53) lightrag/api/lightrag_server.py:1436— lightrag_server.create_app has cyclomatic complexity 53 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
operate._rebuild_single_relationship (cyclomatic 52) lightrag/operate.py:2027— operate._rebuild_single_relationship 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.
heading_flow.correct_numbering_skeleton (cyclomatic 51) lightrag/parser/docx/smart_heading/heading_flow.py:2325— heading_flow.correct_numbering_skeleton 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.
PGKVStorage.get_by_ids (cyclomatic 50) REDACTED:3447— PGKVStorage.get_by_ids 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.
ChatMessage.CodeHighlight (cyclomatic 48) lightrag_webui/src/components/retrieval/ChatMessage.tsx:456— ChatMessage.CodeHighlight has cyclomatic complexity 48 (threshold 15). Most of this is not in the body itself: 10 of the 48 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 480, a function literal at line 469, a function literal at line 575, …). 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.
utils.aexport_data (cyclomatic 47) REDACTED:4707— utils.aexport_data has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ui_customization.load_ui_customization_snapshot (cyclomatic 46) lightrag/api/ui_customization.py:647— ui_customization.load_ui_customization_snapshot 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.
paragraph_semantic._merge_small_blocks (cyclomatic 46) lightrag/chunker/paragraph_semantic.py:1823— paragraph_semantic._merge_small_blocks 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.
paragraph_semantic._split_table_text (cyclomatic 45) lightrag/chunker/paragraph_semantic.py:664— paragraph_semantic._split_table_text 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.
operate._perform_kg_search (cyclomatic 45) lightrag/operate.py:5280— operate._perform_kg_search 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.
parse_document._assemble_blocks_smart (cyclomatic 45) REDACTED:1263— parse_document._assemble_blocks_smart 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.
_PipelineMixin._parse_worker (cyclomatic 44) lightrag/pipeline.py:4409— _PipelineMixin._parse_worker 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.
PGKVStorage.get_by_id (cyclomatic 43) REDACTED:3292— PGKVStorage.get_by_id 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.
paragraph_semantic.chunking_by_paragraph_semantic (cyclomatic 42) lightrag/chunker/paragraph_semantic.py:2057— paragraph_semantic.chunking_by_paragraph_semantic 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.
TableExtractor.extract_with_metadata (cyclomatic 42) lightrag/parser/docx/table_extractor.py:243— TableExtractor.extract_with_metadata 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.
PGVectorStorage.setup_table (cyclomatic 41) REDACTED:4243— PGVectorStorage.setup_table 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.
utils.is_gemini_retryable (cyclomatic 41) lightrag/parser/docx/utils.py:316— utils.is_gemini_retryable has cyclomatic complexity 41 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MessageList.MessageList (cyclomatic 41) lightrag_webui/src/features/retrieval/MessageList.tsx:39— MessageList.MessageList has cyclomatic complexity 41 (threshold 15). Most of this is not in the body itself: 4 of the 41 points are its own statements and the rest belongs to 11 function literals inside it that branch (lines 212, 308, 104, …). 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.
GraphLabels.GraphLabels (cyclomatic 40) lightrag_webui/src/components/graph/GraphLabels.tsx:18— GraphLabels.GraphLabels has cyclomatic complexity 40 (threshold 15). Most of this is not in the body itself: 6 of the 40 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 156, 285, 124, …). 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.
operate.rebuild_knowledge_from_chunks (cyclomatic 39) lightrag/operate.py:1102— operate.rebuild_knowledge_from_chunks 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.
heading_flow.anchor_outline_levels (cyclomatic 39) lightrag/parser/docx/smart_heading/heading_flow.py:1678— heading_flow.anchor_outline_levels 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.
utils_graph._edit_entity_impl (cyclomatic 39) lightrag/utils_graph.py:970— utils_graph._edit_entity_impl 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.
config.parse_args (cyclomatic 38) REDACTED:346— config.parse_args 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.
_PipelineMixin._build_mm_chunks_from_sidecars (cyclomatic 38) lightrag/pipeline.py:7956— _PipelineMixin._build_mm_chunks_from_sidecars 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.
bedrock.bedrock_complete_if_cache (cyclomatic 37) lightrag/llm/bedrock.py:187— bedrock.bedrock_complete_if_cache 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.
MinerUIRBuilder._build_ir_table (cyclomatic 37) lightrag/parser/external/mineru/ir_builder.py:506— MinerUIRBuilder._build_ir_table 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.
EditablePropertyRow.EditablePropertyRow::handleSave (cyclomatic 37) lightrag_webui/src/components/graph/EditablePropertyRow.tsx:96— EditablePropertyRow.EditablePropertyRow::handleSave 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.
MilvusVectorDBStorage._migrate_collection_schema_attempt (cyclomatic 36) lightrag/kg/milvus_impl.py:1829— MilvusVectorDBStorage._migrate_collection_schema_attempt 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.
MinerUIRBuilder._normalize_content_list (cyclomatic 36) lightrag/parser/external/mineru/ir_builder.py:182— MinerUIRBuilder._normalize_content_list has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LoginPage.LoginPage (cyclomatic 36) lightrag_webui/src/features/LoginPage.tsx:45— LoginPage.LoginPage has cyclomatic complexity 36 (threshold 15). Most of this is not in the body itself: 13 of the 36 points are its own statements and the rest belongs to 2 function items inside it that branch (a function literal at line 99, handleSubmit). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
document_routes.run_scanning_process (cyclomatic 35) lightrag/api/routers/document_routes.py:3674— document_routes.run_scanning_process 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.
QdrantVectorDBStorage.setup_collection (cyclomatic 35) lightrag/kg/qdrant_impl.py:192— QdrantVectorDBStorage.setup_collection 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.
LightRAG.__post_init__ (cyclomatic 35) lightrag/lightrag.py:1638— LightRAG.__post_init__ 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.
writer.write_sidecar (cyclomatic 35) REDACTED:60— writer.write_sidecar 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.
DocumentManager.formatMetadata (cyclomatic 35) lightrag_webui/src/features/DocumentManager.tsx:115— DocumentManager.formatMetadata has cyclomatic complexity 35 (threshold 15). Of this number, 19 points are the body's own statements and 16 belong to 4 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ir_builder._build_ir_drawing (cyclomatic 34) lightrag/parser/external/docling/ir_builder.py:857— ir_builder._build_ir_drawing 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.
AsyncSelect.AsyncSelect (cyclomatic 34) lightrag_webui/src/components/ui/AsyncSelect.tsx:74— AsyncSelect.AsyncSelect has cyclomatic complexity 34 (threshold 15). Of this number, 18 points are the body's own statements and 16 belong to 9 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.
graph.useGraphStoreBase (cyclomatic 34) lightrag_webui/src/stores/graph.ts:192— graph.useGraphStoreBase has cyclomatic complexity 34 (threshold 15). Most of this is not in the body itself: 1 of the 34 points is its own statement and the rest belongs to 7 function literals inside it that branch (lines 327, 441, 350, …). 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.
paragraph_semantic._split_long_block (cyclomatic 33) lightrag/chunker/paragraph_semantic.py:1252— paragraph_semantic._split_long_block 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.
anthropic.anthropic_complete_if_cache (cyclomatic 33) lightrag/llm/anthropic.py:53— anthropic.anthropic_complete_if_cache 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.
NumberingResolver.get_label (cyclomatic 33) lightrag/parser/docx/numbering_resolver.py:402— NumberingResolver.get_label 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.
parse_document._read_document_records (cyclomatic 33) REDACTED:684— parse_document._read_document_records 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.
QueryComposer.QueryComposer (cyclomatic 33) lightrag_webui/src/features/retrieval/QueryComposer.tsx:24— QueryComposer.QueryComposer has cyclomatic complexity 33 (threshold 15). Most of this is not in the body itself: 8 of the 33 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 81, 60, 92, …). 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.
FaissVectorDBStorage._flush_pending_locked (cyclomatic 32) REDACTED:907— FaissVectorDBStorage._flush_pending_locked 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.
OMMLParser.parse_d (cyclomatic 32) REDACTED:303— OMMLParser.parse_d 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.
guardrails.verify_content_preservation (cyclomatic 32) lightrag/parser/docx/smart_heading/guardrails.py:878— guardrails.verify_content_preservation 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.
heading_flow.backfill_top_level (cyclomatic 32) lightrag/parser/docx/smart_heading/heading_flow.py:1381— heading_flow.backfill_top_level 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.
rerank.generic_rerank_api (cyclomatic 32) lightrag/rerank.py:240— rerank.generic_rerank_api 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.
PGVectorStorage._flush_pending_vector_ops (cyclomatic 31) REDACTED:4781— PGVectorStorage._flush_pending_vector_ops 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.
LightRAG._rollback_one_custom_chunk_patch (cyclomatic 31) lightrag/lightrag.py:3436— LightRAG._rollback_one_custom_chunk_patch 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.
gemini.gemini_complete_if_cache (cyclomatic 31) lightrag/llm/gemini.py:312— gemini.gemini_complete_if_cache 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.
ollama._ollama_model_if_cache (cyclomatic 31) lightrag/llm/ollama.py:209— ollama._ollama_model_if_cache 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.
heading_flow.assign_levels_by_size (cyclomatic 31) lightrag/parser/docx/smart_heading/heading_flow.py:1265— heading_flow.assign_levels_by_size 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.
heading_flow.demote_strong_body_headings (cyclomatic 31) lightrag/parser/docx/smart_heading/heading_flow.py:2083— heading_flow.demote_strong_body_headings 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.
_StorageMigrationMixin._migrate_chunk_tracking_storage (cyclomatic 31) lightrag/storage_migrations.py:226— _StorageMigrationMixin._migrate_chunk_tracking_storage 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.
kg_integrity_repair.audit_kg_integrity (cyclomatic 31) lightrag/tools/kg_integrity_repair.py:70— kg_integrity_repair.audit_kg_integrity 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.
UploadDocumentsDialog.UploadDocumentsDialog (cyclomatic 31) lightrag_webui/src/components/documents/UploadDocumentsDialog.tsx:38— UploadDocumentsDialog.UploadDocumentsDialog has cyclomatic complexity 31 (threshold 15). Most of this is not in the body itself: 2 of the 31 points are its own statements and the rest belongs to 6 function literals inside it that branch (lines 100, 56, 74, …). 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.
NetworkXStorage.get_knowledge_graph (cyclomatic 30) lightrag/kg/networkx_impl.py:1087— NetworkXStorage.get_knowledge_graph 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.
App.App (cyclomatic 30) lightrag_webui/src/App.tsx:31— App.App has cyclomatic complexity 30 (threshold 15). Most of this is not in the body itself: 7 of the 30 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 111, 66, 68, …). 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.
NanoVectorDBStorage._flush_pending_locked (cyclomatic 29) REDACTED:531— NanoVectorDBStorage._flush_pending_locked 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.
PostgreSQLDB.check_tables (cyclomatic 29) REDACTED:2437— PostgreSQLDB.check_tables has cyclomatic complexity 29 (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.
operate._rebuild_single_entity (cyclomatic 29) lightrag/operate.py:1755— operate._rebuild_single_entity 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.
_PipelineMixin.apipeline_process_enqueue_documents (cyclomatic 29) lightrag/pipeline.py:1724— _PipelineMixin.apipeline_process_enqueue_documents 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.
MigrationTool.setup_storage (cyclomatic 29) lightrag/tools/migrate_llm_cache.py:1006— MigrationTool.setup_storage 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.
PipelineStatusDialog.PipelineStatusDialog (cyclomatic 29) lightrag_webui/src/components/documents/PipelineStatusDialog.tsx:25— PipelineStatusDialog.PipelineStatusDialog has cyclomatic complexity 29 (threshold 15). Of this number, 17 points are the body's own statements and 12 belong to 6 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.
UserPromptInputWithHistory.UserPromptInputWithHistory (cyclomatic 29) lightrag_webui/src/components/ui/UserPromptInputWithHistory.tsx:17— UserPromptInputWithHistory.UserPromptInputWithHistory has cyclomatic complexity 29 (threshold 15). Most of this is not in the body itself: 10 of the 29 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 49, a function literal at line 117, a function literal at line 35, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
document_routes.background_delete_documents (cyclomatic 28) lightrag/api/routers/document_routes.py:4150— document_routes.background_delete_documents 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.
operate.kg_query (cyclomatic 28) lightrag/operate.py:4693— operate.kg_query has cyclomatic complexity 28 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
operate._find_related_text_unit_from_relations (cyclomatic 28) lightrag/operate.py:6621— operate._find_related_text_unit_from_relations 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.
PostgreSQLDB.configure_age_extension (cyclomatic 27) REDACTED:1004— PostgreSQLDB.configure_age_extension 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.
utils_graph.aedit_entity (cyclomatic 27) lightrag/utils_graph.py:1550— utils_graph.aedit_entity 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.
QuerySettings.QuerySettings (cyclomatic 27) lightrag_webui/src/components/retrieval/QuerySettings.tsx:43— QuerySettings.QuerySettings has cyclomatic complexity 27 (threshold 15). Most of this is not in the body itself: 5 of the 27 points are its own statements and the rest belongs to 12 function literals inside it that branch (lines 258, 262, 298, …). 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.
lightrag_server.create_optimized_embedding_function (cyclomatic 26) lightrag/api/lightrag_server.py:651— lightrag_server.create_optimized_embedding_function 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.
LightRAG._purge_kg_contributions (cyclomatic 26) lightrag/lightrag.py:6015— LightRAG._purge_kg_contributions 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.
guardrails._detect_plain_numbered_toc (cyclomatic 26) lightrag/parser/docx/smart_heading/guardrails.py:611— guardrails._detect_plain_numbered_toc 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.
title_block.judge_title_block (cyclomatic 26) lightrag/parser/docx/smart_heading/title_block.py:1481— title_block.judge_title_block 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.
AsyncSearch.AsyncSearch (cyclomatic 26) lightrag_webui/src/components/ui/AsyncSearch.tsx:62— AsyncSearch.AsyncSearch has cyclomatic complexity 26 (threshold 15). Of this number, 13 points are the body's own statements and 13 belong to 9 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.
FileUploader.FileUploader (cyclomatic 26) lightrag_webui/src/components/ui/FileUploader.tsx:151— FileUploader.FileUploader has cyclomatic complexity 26 (threshold 15). Most of this is not in the body itself: 4 of the 26 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 185, a function literal at line 328, a function literal at line 294, …). 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.
useQuerySession.useQuerySession.submitQuery (cyclomatic 26) lightrag_webui/src/features/retrieval/useQuerySession.ts:248— useQuerySession.useQuerySession.submitQuery has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (useQuerySession.useQuerySession.submitQuery::updateAssistantMessage) 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.
ui_customization._completes_svg_start_tag (cyclomatic 25) lightrag/api/ui_customization.py:353— ui_customization._completes_svg_start_tag 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.
PGKVStorage.upsert (cyclomatic 25) REDACTED:3642— PGKVStorage.upsert 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.
LightRAG._resolve_purge_recovery_proof (cyclomatic 25) lightrag/lightrag.py:5674— LightRAG._resolve_purge_recovery_proof 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.
_PipelineMixin._validate_and_fix_document_consistency (cyclomatic 25) lightrag/pipeline.py:2913— _PipelineMixin._validate_and_fix_document_consistency 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.
_PipelineMixin._resolve_source_file_for_parser (cyclomatic 25) lightrag/pipeline.py:6721— _PipelineMixin._resolve_source_file_for_parser 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.
chunk_tracking_repair.run (cyclomatic 25) lightrag/tools/chunk_tracking_repair.py:1080— chunk_tracking_repair.run 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.
CleanupTool.run (cyclomatic 25) lightrag/tools/clean_llm_query_cache.py:1055— CleanupTool.run 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.
utils.enforce_chunk_token_limit_before_embedding (cyclomatic 25) REDACTED:4265— utils.enforce_chunk_token_limit_before_embedding 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.
utils.normalize_extracted_info (cyclomatic 25) REDACTED:5838— utils.normalize_extracted_info 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.
GraphSearch.GraphSearchInput (cyclomatic 25) lightrag_webui/src/components/graph/GraphSearch.tsx:66— GraphSearch.GraphSearchInput has cyclomatic complexity 25 (threshold 15). Most of this is not in the body itself: 3 of the 25 points are its own statements and the rest belongs to 6 function literals inside it that branch (lines 126, 166, 87, …). 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.
legacySettingsChain.migrateLegacySettingsState (cyclomatic 25) lightrag_webui/src/migrations/legacySettingsChain.ts:32— legacySettingsChain.migrateLegacySettingsState 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.
MongoGraphStorage._dedupe_legacy_edges (cyclomatic 24) lightrag/kg/mongo_impl.py:1997— MongoGraphStorage._dedupe_legacy_edges 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.
PGVectorStorage.get_vectors_by_ids (cyclomatic 24) REDACTED:5392— PGVectorStorage.get_vectors_by_ids 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.
PaginationControls.PaginationControls (cyclomatic 24) lightrag_webui/src/components/ui/PaginationControls.tsx:36— PaginationControls.PaginationControls has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 10 of the 24 points are its own statements and the rest belongs to 7 function literals inside it that branch (lines 64, 98, 104, …). 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.
state.useBackendStateStoreBase (cyclomatic 24) lightrag_webui/src/stores/state.ts:75— state.useBackendStateStoreBase has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 1 of the 24 points is its own statement and the rest belongs to 5 function literals inside it that branch (lines 88, 163, 167, …). 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.
utils_api.display_splash_screen (cyclomatic 23) lightrag/api/utils_api.py:618— utils_api.display_splash_screen 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.
OpenSearchGraphStorage._bfs_subgraph_ppl (cyclomatic 23) lightrag/kg/opensearch_impl.py:5558— OpenSearchGraphStorage._bfs_subgraph_ppl 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.
PGGraphStorage._bfs_subgraph (cyclomatic 23) REDACTED:9026— PGGraphStorage._bfs_subgraph 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.
operate.extract_entities (cyclomatic 23) lightrag/operate.py:3942— operate.extract_entities 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.
operate._find_related_text_unit_from_entities (cyclomatic 23) lightrag/operate.py:6350— operate._find_related_text_unit_from_entities 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.
DrawingExtractionContext.export_embedded_image (cyclomatic 23) REDACTED:124— DrawingExtractionContext.export_embedded_image 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.
heading_flow.merge_split_headings (cyclomatic 23) lightrag/parser/docx/smart_heading/heading_flow.py:1872— heading_flow.merge_split_headings 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.
Manifest.from_dict (cyclomatic 23) lightrag/parser/external/_manifest.py:83— Manifest.from_dict 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.
ir_builder._precompute_consumed_refs (cyclomatic 23) lightrag/parser/external/docling/ir_builder.py:549— ir_builder._precompute_consumed_refs 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.
_StorageMigrationMixin._migrate_entity_relation_data (cyclomatic 23) lightrag/storage_migrations.py:109— _StorageMigrationMixin._migrate_entity_relation_data 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.
rebuild_vdb.check_vdb_consistency (cyclomatic 23) lightrag/tools/rebuild_vdb.py:518— rebuild_vdb.check_vdb_consistency 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.
utils.use_llm_func_with_cache (cyclomatic 23) REDACTED:5515— utils.use_llm_func_with_cache 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.
utils_graph.aedit_relation (cyclomatic 23) lightrag/utils_graph.py:1850— utils_graph.aedit_relation 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.
NanoVectorDBStorage.get_vectors_by_ids (cyclomatic 22) REDACTED:1383— NanoVectorDBStorage.get_vectors_by_ids 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.
zhipu.zhipu_complete_if_cache (cyclomatic 22) lightrag/llm/zhipu.py:45— zhipu.zhipu_complete_if_cache 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.
heading_flow.gate_with_cb1 (cyclomatic 22) lightrag/parser/docx/smart_heading/heading_flow.py:1065— heading_flow.gate_with_cb1 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.
heading_flow.nest_numbered_under_parent (cyclomatic 22) lightrag/parser/docx/smart_heading/heading_flow.py:2537— heading_flow.nest_numbered_under_parent 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.
Manifest.from_dict (cyclomatic 22) lightrag/parser/external/mineru/manifest.py:81— Manifest.from_dict has cyclomatic complexity 22 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
extract.extract_markdown (cyclomatic 22) lightrag/parser/markdown/extract.py:359— extract.extract_markdown 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.
RebuildTool.run (cyclomatic 22) lightrag/tools/rebuild_vdb.py:1094— RebuildTool.run 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.
splitSettingsStorage.runSettingsStorageSplitMigration (cyclomatic 22) lightrag_webui/src/migrations/splitSettingsStorage.ts:554— splitSettingsStorage.runSettingsStorageSplitMigration 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.
registry.resolve_chunker (cyclomatic 21) lightrag/chunker/registry.py:242— registry.resolve_chunker 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.
QdrantVectorDBStorage._flush_pending_vector_ops (cyclomatic 21) lightrag/kg/qdrant_impl.py:848— QdrantVectorDBStorage._flush_pending_vector_ops 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.
RedisDocStatusStorage.get_docs_paginated (cyclomatic 21) lightrag/kg/redis_impl.py:1680— RedisDocStatusStorage.get_docs_paginated 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.
LightRAG._prune_doc_recovery_anchors (cyclomatic 21) lightrag/lightrag.py:3692— LightRAG._prune_doc_recovery_anchors 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.
LightRAG.ainsert_custom_kg (cyclomatic 21) lightrag/lightrag.py:4340— LightRAG.ainsert_custom_kg 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.
_RoleLLMMixin._apply_llm_role_config_update (cyclomatic 21) lightrag/llm_roles.py:309— _RoleLLMMixin._apply_llm_role_config_update 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.
operate._merge_all_chunks (cyclomatic 21) lightrag/operate.py:5765— operate._merge_all_chunks 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.
operate.naive_query (cyclomatic 21) lightrag/operate.py:6852— operate.naive_query 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.
title_block.detect_imprint_regions (cyclomatic 21) lightrag/parser/docx/smart_heading/title_block.py:402— title_block.detect_imprint_regions 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.
check_initialization.check_lightrag_setup (cyclomatic 21) lightrag/tools/check_initialization.py:30— check_initialization.check_lightrag_setup 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.
GraphViewer.GraphViewer (cyclomatic 21) lightrag_webui/src/features/GraphViewer.tsx:145— GraphViewer.GraphViewer has cyclomatic complexity 21 (threshold 15). Of this number, 12 points are the body's own statements and 9 belong to 5 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.
Neo4JStorage._create_fulltext_index (cyclomatic 20) lightrag/kg/neo4j_impl.py:335— Neo4JStorage._create_fulltext_index 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.
PGGraphStorage._record_to_dict (cyclomatic 20) REDACTED:7597— PGGraphStorage._record_to_dict 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.
QdrantVectorDBStorage.get_vectors_by_ids (cyclomatic 20) lightrag/kg/qdrant_impl.py:1248— QdrantVectorDBStorage.get_vectors_by_ids 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.
LightRAG._upsert_custom_chunk_status (cyclomatic 20) lightrag/lightrag.py:3139— LightRAG._upsert_custom_chunk_status 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.
features.parse_styles_attributes (cyclomatic 20) REDACTED:188— features.parse_styles_attributes 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.
utils.safe_vdb_operation_with_exception (cyclomatic 20) REDACTED:156— utils.safe_vdb_operation_with_exception 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.
utils.process_chunks_unified (cyclomatic 20) REDACTED:7055— utils.process_chunks_unified 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.
useQuerySession.useQuerySession.submitQuery::updateAssistantMessage (cyclomatic 20) lightrag_webui/src/features/retrieval/useQuerySession.ts:333— useQuerySession.useQuerySession.submitQuery::updateAssistantMessage 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. This shape REPEATS in the file: one other method here (useQuerySession.useQuerySession.submitQuery) 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.
document_routes.pipeline_enqueue_file (cyclomatic 19) lightrag/api/routers/document_routes.py:2359— document_routes.pipeline_enqueue_file 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.
MilvusVectorDBStorage._create_collection_if_not_exist (cyclomatic 19) lightrag/kg/milvus_impl.py:2262— MilvusVectorDBStorage._create_collection_if_not_exist 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.
MongoGraphStorage.get_knowledge_subgraph_in_out_bound_bfs (cyclomatic 19) lightrag/kg/mongo_impl.py:3327— MongoGraphStorage.get_knowledge_subgraph_in_out_bound_bfs 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.
MongoVectorDBStorage._flush_pending_vector_ops (cyclomatic 19) lightrag/kg/mongo_impl.py:4718— MongoVectorDBStorage._flush_pending_vector_ops 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.
OpenSearchGraphStorage._migrate_edges_to_canonical_id_if_needed (cyclomatic 19) lightrag/kg/opensearch_impl.py:3897— OpenSearchGraphStorage._migrate_edges_to_canonical_id_if_needed 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.
OpenSearchVectorDBStorage._flush_pending_vector_ops (cyclomatic 19) lightrag/kg/opensearch_impl.py:6685— OpenSearchVectorDBStorage._flush_pending_vector_ops 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.
AsyncioScanJobStore.update (cyclomatic 19) lightrag/kg/scan_job_store.py:430— AsyncioScanJobStore.update 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.
bedrock.bedrock_embed (cyclomatic 19) lightrag/llm/bedrock.py:566— bedrock.bedrock_embed 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.
operate._handle_entity_relation_summary (cyclomatic 19) lightrag/operate.py:372— operate._handle_entity_relation_summary 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.
operate._process_json_extraction_result (cyclomatic 19) lightrag/operate.py:907— operate._process_json_extraction_result 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.
operate.merge_nodes_and_edges (cyclomatic 19) lightrag/operate.py:3514— operate.merge_nodes_and_edges 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.
operate._apply_token_truncation (cyclomatic 19) lightrag/operate.py:5501— operate._apply_token_truncation 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.
NumberingResolver._parse_numbering_xml (cyclomatic 19) lightrag/parser/docx/numbering_resolver.py:186— NumberingResolver._parse_numbering_xml 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.
utils.wait_tasks_with_drain (cyclomatic 19) REDACTED:4581— utils.wait_tasks_with_drain 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.
recursive_character._split_text_with_regex_spans (cyclomatic 18) lightrag/chunker/recursive_character.py:61— recursive_character._split_text_with_regex_spans 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.
FaissVectorDBStorage.get_vectors_by_ids (cyclomatic 18) REDACTED:1774— FaissVectorDBStorage.get_vectors_by_ids 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.
Neo4JStorage.get_knowledge_graph (cyclomatic 18) lightrag/kg/neo4j_impl.py:1301— Neo4JStorage.get_knowledge_graph 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.
OpenSearchDocStatusStorage.get_docs_paginated (cyclomatic 18) lightrag/kg/opensearch_impl.py:2558— OpenSearchDocStatusStorage.get_docs_paginated 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.
OpenSearchVectorDBStorage.get_vectors_by_ids (cyclomatic 18) lightrag/kg/opensearch_impl.py:7125— OpenSearchVectorDBStorage.get_vectors_by_ids 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.
LightRAG._persist_custom_chunk_recovery_warning (cyclomatic 18) lightrag/lightrag.py:3568— LightRAG._persist_custom_chunk_recovery_warning 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.
LightRAG._discard_pending_index_ops (cyclomatic 18) lightrag/lightrag.py:3814— LightRAG._discard_pending_index_ops 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.
openai.openai_embed (cyclomatic 18) lightrag/llm/openai.py:1054— openai.openai_embed 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.
OMMLParser.parse_func (cyclomatic 18) REDACTED:435— OMMLParser.parse_func 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.
param_schema.parse_chunk_params (cyclomatic 18) lightrag/parser/param_schema.py:196— param_schema.parse_chunk_params 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.
param_schema.parse_engine_params (cyclomatic 18) lightrag/parser/param_schema.py:500— param_schema.parse_engine_params has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
routing._validate_filename_hint_for_resolution (cyclomatic 18) lightrag/parser/routing.py:930— routing._validate_filename_hint_for_resolution 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.
MigrationTool.run (cyclomatic 18) lightrag/tools/migrate_llm_cache.py:1419— MigrationTool.run 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.
utils.merge_truncation_metadata (cyclomatic 18) REDACTED:5359— utils.merge_truncation_metadata 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.
lightrag._readNdjsonStream (cyclomatic 18) lightrag_webui/src/api/lightrag.ts:695— lightrag._readNdjsonStream has cyclomatic complexity 18 (threshold 15). Of this number, 11 points are the body's own statements and 7 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Settings.LabeledNumberInput (cyclomatic 18) lightrag_webui/src/components/graph/Settings.tsx:56— Settings.LabeledNumberInput has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 4 of the 18 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 105, 96, 125, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
document_routes.delete_file_variants_by_file_path (cyclomatic 17) lightrag/api/routers/document_routes.py:2232— document_routes.delete_file_variants_by_file_path 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.
recursive_character.chunking_by_recursive_character (cyclomatic 17) lightrag/chunker/recursive_character.py:436— recursive_character.chunking_by_recursive_character 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.
token_size.chunking_by_token_size (cyclomatic 17) lightrag/chunker/token_size.py:133— token_size.chunking_by_token_size 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.
Neo4JStorage._robust_fallback (cyclomatic 17) lightrag/kg/neo4j_impl.py:1531— Neo4JStorage._robust_fallback 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.
OpenSearchGraphStorage._bfs_subgraph (cyclomatic 17) lightrag/kg/opensearch_impl.py:5726— OpenSearchGraphStorage._bfs_subgraph 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.
PostgreSQLDB._create_ssl_context (cyclomatic 17) REDACTED:530— PostgreSQLDB._create_ssl_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.
PGGraphStorage.get_knowledge_graph (cyclomatic 17) REDACTED:9242— PGGraphStorage.get_knowledge_graph 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.
RedisDocStatusStorage.get_docs_by_statuses_page (cyclomatic 17) lightrag/kg/redis_impl.py:2104— RedisDocStatusStorage.get_docs_by_statuses_page 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.
multimodal_context.enrich_sidecars_with_surrounding (cyclomatic 17) lightrag/multimodal_context.py:978— multimodal_context.enrich_sidecars_with_surrounding 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.
operate._process_extraction_result (cyclomatic 17) lightrag/operate.py:1508— operate._process_extraction_result 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.
zip_budget.enforce_docx_decompression_budget (cyclomatic 17) lightrag/parser/docx/zip_budget.py:82— zip_budget.enforce_docx_decompression_budget 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.
NativeMarkdownIRBuilder.normalize (cyclomatic 17) lightrag/parser/markdown/ir_builder.py:64— NativeMarkdownIRBuilder.normalize 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.
NativeParserBase.parse (cyclomatic 17) lightrag/parser/native_base.py:226— NativeParserBase.parse 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.
migrate_graph_storage._unrepresentable_paths (cyclomatic 17) lightrag/tools/migrate_graph_storage.py:209— migrate_graph_storage._unrepresentable_paths 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.
EmbeddingFunc.__call__ (cyclomatic 17) REDACTED:775— EmbeddingFunc.__call__ 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.
utils_graph._merge_attributes (cyclomatic 17) lightrag/utils_graph.py:3579— utils_graph._merge_attributes 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.
lightrag._classifyStreamError (cyclomatic 17) lightrag_webui/src/api/lightrag.ts:802— lightrag._classifyStreamError 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.
Settings.Settings (cyclomatic 17) lightrag_webui/src/components/graph/Settings.tsx:182— Settings.Settings has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 6 of the 17 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 371, 254, 355, …). 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.
StatusCard.formatMinerU (cyclomatic 17) lightrag_webui/src/components/status/StatusCard.tsx:59— StatusCard.formatMinerU 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.
ui_customization.normalize_locale (cyclomatic 16) lightrag/api/ui_customization.py:110— ui_customization.normalize_locale 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.
paragraph_semantic._expand_block_with_table_splits (cyclomatic 16) lightrag/chunker/paragraph_semantic.py:969— paragraph_semantic._expand_block_with_table_splits 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.
RAGEvaluator._calculate_benchmark_stats (cyclomatic 16) lightrag/evaluation/eval_rag_quality.py:789— RAGEvaluator._calculate_benchmark_stats 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.
MemgraphStorage.get_knowledge_graph (cyclomatic 16) lightrag/kg/memgraph_impl.py:1051— MemgraphStorage.get_knowledge_graph has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MilvusVectorDBStorage.get_vectors_by_ids (cyclomatic 16) lightrag/kg/milvus_impl.py:3391— MilvusVectorDBStorage.get_vectors_by_ids 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.
NanoVectorDBStorage.get_by_ids (cyclomatic 16) REDACTED:1316— NanoVectorDBStorage.get_by_ids 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.
PostgreSQLDB._migrate_field_lengths (cyclomatic 16) REDACTED:2294— PostgreSQLDB._migrate_field_lengths 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.
PGGraphStorage.get_edges_batch (cyclomatic 16) REDACTED:8807— PGGraphStorage.get_edges_batch 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.
QdrantVectorDBStorage.get_by_ids (cyclomatic 16) lightrag/kg/qdrant_impl.py:1176— QdrantVectorDBStorage.get_by_ids 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.
RedisDocStatusStorage.get_doc_by_content_hash (cyclomatic 16) lightrag/kg/redis_impl.py:1972— RedisDocStatusStorage.get_doc_by_content_hash 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.
_vision_utils._read_jpeg_dimensions (cyclomatic 16) lightrag/llm/_vision_utils.py:195— _vision_utils._read_jpeg_dimensions 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.
multimodal_context._build_leading (cyclomatic 16) lightrag/multimodal_context.py:505— multimodal_context._build_leading has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (multimodal_context._build_trailing) 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.
multimodal_context._build_trailing (cyclomatic 16) lightrag/multimodal_context.py:629— multimodal_context._build_trailing has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (multimodal_context._build_leading) 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.
drawing_image_extractor.load_relationships (cyclomatic 16) REDACTED:381— drawing_image_extractor.load_relationships 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.
NativeDocxIRBuilder.normalize (cyclomatic 16) lightrag/parser/docx/ir_builder.py:250— NativeDocxIRBuilder.normalize 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.
heading_flow._try_cb1_graduated_demotion (cyclomatic 16) lightrag/parser/docx/smart_heading/heading_flow.py:965— heading_flow._try_cb1_graduated_demotion 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.
style_key._extract_unit_and_ordinal (cyclomatic 16) lightrag/parser/docx/smart_heading/style_key.py:308— style_key._extract_unit_and_ordinal 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.
ir_builder._build_ir_table (cyclomatic 16) lightrag/parser/external/docling/ir_builder.py:688— ir_builder._build_ir_table 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.
routing._filename_hint_match (cyclomatic 16) lightrag/parser/routing.py:858— routing._filename_hint_match 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.
_PipelineMixin._refetch_for_decision (cyclomatic 16) lightrag/pipeline.py:3924— _PipelineMixin._refetch_for_decision 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.
CleanupTool.setup_storage (cyclomatic 16) lightrag/tools/clean_llm_query_cache.py:947— CleanupTool.setup_storage 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.
MigrationTool.stream_default_caches_redis (cyclomatic 16) lightrag/tools/migrate_llm_cache.py:736— MigrationTool.stream_default_caches_redis 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.
utils.apply_rerank_if_enabled (cyclomatic 16) REDACTED:6924— utils.apply_rerank_if_enabled 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.
ClearDocumentsDialog.ClearDocumentsDialog (cyclomatic 16) lightrag_webui/src/components/documents/ClearDocumentsDialog.tsx:41— ClearDocumentsDialog.ClearDocumentsDialog has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 3 of the 16 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 78, 54, 70, …). 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.
LayoutsControl.WorkerLayoutControl (cyclomatic 16) lightrag_webui/src/components/graph/LayoutsControl.tsx:106— LayoutsControl.WorkerLayoutControl has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 3 of the 16 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 160, 137, 119, …). 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.
PropertiesView.PropertyRow (cyclomatic 16) lightrag_webui/src/components/graph/PropertiesView.tsx:161— PropertiesView.PropertyRow has cyclomatic complexity 16 (threshold 15). Of this number, 13 points are the body's own statements and 3 belong to 2 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.
useLightragGraph.createSigmaGraph (cyclomatic 16) lightrag_webui/src/hooks/useLightragGraph.tsx:248— useLightragGraph.createSigmaGraph 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.
paragraph_semantic._merge_small_blocks (cognitive 177) lightrag/chunker/paragraph_semantic.py:1823— paragraph_semantic._merge_small_blocks has cognitive complexity 177 (threshold 15). Drivers by points: if/else 26 (139 pts), loops 7 (24 pts), boolean chains 14 (nesting depth added 130). 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.
operate._merge_edges_then_upsert (cognitive 173) lightrag/operate.py:2782— operate._merge_edges_then_upsert has cognitive complexity 173 (threshold 15). Drivers by points: if/else 70 (144 pts), boolean chains 16, loops 7 (8 pts), ternaries 2 (3 pts), error handling 1 (2 pts) (nesting depth added 77). 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.
LightRAG._purge_derived_kg_contributions (cognitive 159) lightrag/lightrag.py:6265— LightRAG._purge_derived_kg_contributions has cognitive complexity 159 (threshold 15). Drivers by points: if/else 47 (106 pts), loops 12 (25 pts), boolean chains 13, error handling 7 (11 pts), ternaries 2 (4 pts) (nesting depth added 78). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DocumentManager.DocumentManager (cognitive 157) lightrag_webui/src/features/DocumentManager.tsx:381— DocumentManager.DocumentManager has cognitive complexity 157 (threshold 15). Drivers by points: if/else 54 (76 pts), boolean chains 45, ternaries 22 (30 pts), error handling 4 (5 pts), match/switch 1 (nesting depth added 31). Of this number, 49 points are the body's own statements and 108 belong to 28 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.
useLightragGraph.useLightrangeGraph (cognitive 143) lightrag_webui/src/hooks/useLightragGraph.tsx:328— useLightragGraph.useLightrangeGraph has cognitive complexity 143 (threshold 15). Drivers by points: if/else 55 (90 pts), boolean chains 32, loops 13, error handling 4 (8 pts) (nesting depth added 39). None of this is in the body itself: all 143 points belong to 14 function literals inside it that branch (lines 681, 477, 395, …). 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.
TableExtractor.extract_with_metadata (cognitive 132) lightrag/parser/docx/table_extractor.py:243— TableExtractor.extract_with_metadata has cognitive complexity 132 (threshold 15). Drivers by points: if/else 27 (104 pts), loops 6 (19 pts), ternaries 3 (5 pts), boolean chains 4 (nesting depth added 92). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
openai.openai_complete_if_cache (cognitive 128) lightrag/llm/openai.py:305— openai.openai_complete_if_cache has cognitive complexity 128 (threshold 15). Drivers by points: if/else 36 (70 pts), error handling 13 (24 pts), ternaries 6 (19 pts), boolean chains 13, loops 1 (2 pts) (nesting depth added 59). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
title_block.find_title_block_candidates (cognitive 123) lightrag/parser/docx/smart_heading/title_block.py:504— title_block.find_title_block_candidates has cognitive complexity 123 (threshold 15). Drivers by points: if/else 32 (73 pts), boolean chains 24, loops 10 (19 pts), ternaries 2 (7 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.
utils_graph._merge_entities_impl (cognitive 120) lightrag/utils_graph.py:2703— utils_graph._merge_entities_impl has cognitive complexity 120 (threshold 15). Drivers by points: if/else 33 (72 pts), loops 14 (25 pts), error handling 7 (10 pts), ternaries 5 (7 pts), boolean chains 6 (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.
PGKVStorage.get_by_ids (cognitive 119) REDACTED:3447— PGKVStorage.get_by_ids has cognitive complexity 119 (threshold 15). Drivers by points: if/else 20 (44 pts), error handling 9 (36 pts), ternaries 6 (18 pts), loops 7 (14 pts), boolean chains 7 (nesting depth added 70). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LightRAG.adelete_by_doc_id (cognitive 116) lightrag/lightrag.py:6727— LightRAG.adelete_by_doc_id has cognitive complexity 116 (threshold 15). Drivers by points: if/else 33 (61 pts), error handling 16 (31 pts), boolean chains 9, ternaries 3 (8 pts), loops 2 (7 pts) (nesting depth added 53). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.aexport_data (cognitive 113) REDACTED:4707— utils.aexport_data has cognitive complexity 113 (threshold 15). Drivers by points: if/else 35 (70 pts), loops 11 (29 pts), ternaries 5 (12 pts), boolean chains 2 (nesting depth added 60). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_PipelineMixin.apipeline_enqueue_documents (cognitive 110) lightrag/pipeline.py:740— _PipelineMixin.apipeline_enqueue_documents has cognitive complexity 110 (threshold 15). Drivers by points: if/else 44 (66 pts), boolean chains 12, ternaries 5 (12 pts), loops 7 (11 pts), error handling 5 (9 pts) (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_PipelineMixin.process_single_document (cognitive 107) lightrag/pipeline.py:4991— _PipelineMixin.process_single_document has cognitive complexity 107 (threshold 15). Drivers by points: if/else 36 (61 pts), boolean chains 32, error handling 3 (7 pts), ternaries 4 (5 pts), loops 1 (2 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow.gate_candidates (cognitive 105) lightrag/parser/docx/smart_heading/heading_flow.py:391— heading_flow.gate_candidates has cognitive complexity 105 (threshold 15). Drivers by points: if/else 30 (79 pts), boolean chains 14, loops 9 (11 pts), ternaries 1 (nesting depth added 51). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_PipelineMixin.analyze_multimodal (cognitive 104) lightrag/pipeline.py:6841— _PipelineMixin.analyze_multimodal has cognitive complexity 104 (threshold 15). Drivers by points: if/else 35 (65 pts), boolean chains 13, loops 7 (13 pts), error handling 7 (11 pts), ternaries 1 (2 pts) (nesting depth added 41). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow.correct_numbering_skeleton (cognitive 102) lightrag/parser/docx/smart_heading/heading_flow.py:2325— heading_flow.correct_numbering_skeleton has cognitive complexity 102 (threshold 15). Drivers by points: if/else 26 (67 pts), loops 15 (23 pts), boolean chains 9, ternaries 1 (3 pts) (nesting depth added 51). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils_graph._edit_entity_impl (cognitive 100) lightrag/utils_graph.py:970— utils_graph._edit_entity_impl has cognitive complexity 100 (threshold 15). Drivers by points: if/else 24 (60 pts), ternaries 4 (18 pts), error handling 4 (8 pts), loops 3 (8 pts), boolean chains 6 (nesting depth added 59). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
heading_flow.run_smart_heading (cognitive 97) lightrag/parser/docx/smart_heading/heading_flow.py:2942— heading_flow.run_smart_heading has cognitive complexity 97 (threshold 15). Drivers by points: if/else 31 (58 pts), loops 14 (24 pts), ternaries 3 (9 pts), boolean chains 6 (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.
parse_document._assemble_blocks_smart (cognitive 96) REDACTED:1263— parse_document._assemble_blocks_smart has cognitive complexity 96 (threshold 15). Drivers by points: if/else 27 (76 pts), boolean chains 13, loops 2 (4 pts), ternaries 1 (3 pts) (nesting depth added 53). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GraphControl.GraphControl (cognitive 91) lightrag_webui/src/components/graph/GraphControl.tsx:23— GraphControl.GraphControl has cognitive complexity 91 (threshold 15). Drivers by points: if/else 45 (61 pts), boolean chains 17, ternaries 7 (9 pts), error handling 4 (nesting depth added 18). Most of this is not in the body itself: 1 of the 91 points is its own statement and the rest belongs to 23 function literals inside it that branch (lines 426, 374, 459, …). 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.
_PipelineMixin._parse_worker (cognitive 90) lightrag/pipeline.py:4409— _PipelineMixin._parse_worker has cognitive complexity 90 (threshold 15). Drivers by points: if/else 27 (64 pts), boolean chains 9, ternaries 4 (9 pts), error handling 3 (7 pts), 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.
parse_document._read_document_records (cognitive 89) REDACTED:684— parse_document._read_document_records has cognitive complexity 89 (threshold 15). Drivers by points: if/else 21 (71 pts), boolean chains 7, ternaries 2 (6 pts), loops 2 (5 pts) (nesting depth added 57). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
LightRAG.ainsert_custom_chunks (cognitive 88) lightrag/lightrag.py:2394— LightRAG.ainsert_custom_chunks has cognitive complexity 88 (threshold 15). Drivers by points: if/else 32 (46 pts), boolean chains 24, error handling 4 (8 pts), ternaries 4 (6 pts), loops 2 (4 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
operate._perform_kg_search (cognitive 88) lightrag/operate.py:5280— operate._perform_kg_search has cognitive complexity 88 (threshold 15). Drivers by points: if/else 30 (67 pts), boolean chains 10, loops 4 (8 pts), error handling 1 (3 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.
NetworkXStorage.get_knowledge_graph (cognitive 84) lightrag/kg/networkx_impl.py:1087— NetworkXStorage.get_knowledge_graph has cognitive complexity 84 (threshold 15). Drivers by points: if/else 23 (63 pts), loops 6 (16 pts), boolean chains 5 (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.
operate._merge_nodes_then_upsert (cognitive 84) lightrag/operate.py:2429— operate._merge_nodes_then_upsert has cognitive complexity 84 (threshold 15). Drivers by points: if/else 41 (61 pts), boolean chains 13, loops 4 (5 pts), ternaries 2 (5 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_PipelineMixin._build_mm_chunks_from_sidecars (cognitive 83) lightrag/pipeline.py:7956— _PipelineMixin._build_mm_chunks_from_sidecars has cognitive complexity 83 (threshold 15). Drivers by points: if/else 25 (63 pts), boolean chains 8, loops 3 (7 pts), ternaries 1 (3 pts), error handling 1 (2 pts) (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow.anchor_outline_levels (cognitive 82) lightrag/parser/docx/smart_heading/heading_flow.py:1678— heading_flow.anchor_outline_levels has cognitive complexity 82 (threshold 15). Drivers by points: if/else 19 (46 pts), loops 9 (19 pts), ternaries 4 (10 pts), boolean chains 7 (nesting depth added 43). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
lightrag_server.create_app (cognitive 78) lightrag/api/lightrag_server.py:1436— lightrag_server.create_app has cognitive complexity 78 (threshold 15). Drivers by points: if/else 33 (54 pts), boolean chains 12, error handling 4 (6 pts), ternaries 6 (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.
PGKVStorage.get_by_id (cognitive 78) REDACTED:3292— PGKVStorage.get_by_id has cognitive complexity 78 (threshold 15). Drivers by points: if/else 19 (31 pts), error handling 9 (27 pts), ternaries 7 (13 pts), boolean chains 7 (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.
ui_customization.load_ui_customization_snapshot (cognitive 77) lightrag/api/ui_customization.py:647— ui_customization.load_ui_customization_snapshot has cognitive complexity 77 (threshold 15). Drivers by points: if/else 30 (51 pts), error handling 5 (9 pts), loops 6 (9 pts), boolean chains 5, 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.
operate._rebuild_single_relationship (cognitive 77) lightrag/operate.py:2027— operate._rebuild_single_relationship has cognitive complexity 77 (threshold 15). Drivers by points: if/else 28 (48 pts), ternaries 11 (13 pts), boolean chains 7, loops 5 (7 pts), error handling 2 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PGVectorStorage.setup_table (cognitive 74) REDACTED:4243— PGVectorStorage.setup_table has cognitive complexity 74 (threshold 15). Drivers by points: if/else 18 (39 pts), ternaries 6 (14 pts), error handling 4 (12 pts), boolean chains 9 (nesting depth added 37). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
QdrantVectorDBStorage.setup_collection (cognitive 74) lightrag/kg/qdrant_impl.py:192— QdrantVectorDBStorage.setup_collection has cognitive complexity 74 (threshold 15). Drivers by points: if/else 22 (54 pts), boolean chains 8, loops 3 (8 pts), error handling 2 (4 pts) (nesting depth added 39). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
MinerUIRBuilder._normalize_content_list (cognitive 72) lightrag/parser/external/mineru/ir_builder.py:182— MinerUIRBuilder._normalize_content_list has cognitive complexity 72 (threshold 15). Drivers by points: if/else 25 (58 pts), boolean chains 7, ternaries 2 (6 pts), loops 1 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
guardrails._detect_plain_numbered_toc (cognitive 71) lightrag/parser/docx/smart_heading/guardrails.py:611— guardrails._detect_plain_numbered_toc has cognitive complexity 71 (threshold 15). Drivers by points: if/else 14 (50 pts), ternaries 2 (9 pts), loops 4 (7 pts), boolean chains 5 (nesting depth added 46). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
guardrails.verify_content_preservation (cognitive 70) lightrag/parser/docx/smart_heading/guardrails.py:878— guardrails.verify_content_preservation has cognitive complexity 70 (threshold 15). Drivers by points: if/else 12 (34 pts), loops 13 (29 pts), boolean chains 7 (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.
paragraph_semantic._split_table_text (cognitive 68) lightrag/chunker/paragraph_semantic.py:664— paragraph_semantic._split_table_text has cognitive complexity 68 (threshold 15). Drivers by points: if/else 22 (40 pts), boolean chains 15, ternaries 5 (8 pts), loops 2 (3 pts), error handling 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.
MigrationTool.stream_default_caches_redis (cognitive 65) lightrag/tools/migrate_llm_cache.py:736— MigrationTool.stream_default_caches_redis has cognitive complexity 65 (threshold 15). Drivers by points: if/else 6 (26 pts), loops 5 (16 pts), ternaries 2 (13 pts), error handling 2 (10 pts) (nesting depth added 50). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EditablePropertyRow.EditablePropertyRow::handleSave (cognitive 64) lightrag_webui/src/components/graph/EditablePropertyRow.tsx:96— EditablePropertyRow.EditablePropertyRow::handleSave has cognitive complexity 64 (threshold 15). Drivers by points: if/else 20 (39 pts), ternaries 4 (10 pts), boolean chains 8, error handling 3 (7 pts) (nesting depth added 29). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
PGGraphStorage._record_to_dict (cognitive 63) REDACTED:7597— PGGraphStorage._record_to_dict has cognitive complexity 63 (threshold 15). Drivers by points: if/else 15 (41 pts), ternaries 2 (10 pts), loops 3 (8 pts), boolean chains 4 (nesting depth added 39). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
OMMLParser.parse_func (cognitive 62) REDACTED:435— OMMLParser.parse_func has cognitive complexity 62 (threshold 15). Drivers by points: if/else 10 (40 pts), loops 5 (21 pts), boolean chains 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.
_StorageMigrationMixin._migrate_chunk_tracking_storage (cognitive 62) lightrag/storage_migrations.py:226— _StorageMigrationMixin._migrate_chunk_tracking_storage has cognitive complexity 62 (threshold 15). Drivers by points: if/else 14 (38 pts), loops 4 (10 pts), boolean chains 8, error handling 4 (6 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.
operate.rebuild_knowledge_from_chunks (cognitive 61) lightrag/operate.py:1102— operate.rebuild_knowledge_from_chunks has cognitive complexity 61 (threshold 15). Drivers by points: if/else 18 (35 pts), loops 8 (13 pts), boolean chains 11, error handling 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.
MilvusVectorDBStorage._migrate_collection_schema_attempt (cognitive 60) lightrag/kg/milvus_impl.py:1829— MilvusVectorDBStorage._migrate_collection_schema_attempt has cognitive complexity 60 (threshold 15). Drivers by points: if/else 20 (30 pts), error handling 11 (22 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OMMLParser.parse_d (cognitive 60) REDACTED:303— OMMLParser.parse_d has cognitive complexity 60 (threshold 15). Drivers by points: if/else 19 (44 pts), loops 5 (10 pts), boolean chains 6 (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.
heading_flow.demote_strong_body_headings (cognitive 59) lightrag/parser/docx/smart_heading/heading_flow.py:2083— heading_flow.demote_strong_body_headings has cognitive complexity 59 (threshold 15). Drivers by points: if/else 19 (47 pts), boolean chains 6, loops 5 (6 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.
paragraph_semantic.chunking_by_paragraph_semantic (cognitive 58) lightrag/chunker/paragraph_semantic.py:2057— paragraph_semantic.chunking_by_paragraph_semantic has cognitive complexity 58 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 18, ternaries 6 (11 pts), loops 5 (7 pts), error handling 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.
_PipelineMixin.apipeline_process_enqueue_documents (cognitive 58) lightrag/pipeline.py:1724— _PipelineMixin.apipeline_process_enqueue_documents has cognitive complexity 58 (threshold 15). Drivers by points: if/else 25 (52 pts), boolean chains 5, loops 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
paragraph_semantic._split_long_block (cognitive 57) lightrag/chunker/paragraph_semantic.py:1252— paragraph_semantic._split_long_block has cognitive complexity 57 (threshold 15). Drivers by points: if/else 15 (30 pts), loops 7 (10 pts), boolean chains 9, ternaries 3 (8 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.
token_size.chunking_by_token_size (cognitive 56) lightrag/chunker/token_size.py:133— token_size.chunking_by_token_size has cognitive complexity 56 (threshold 15). Drivers by points: if/else 11 (30 pts), loops 6 (17 pts), ternaries 2 (9 pts) (nesting depth added 37). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
MigrationTool.get_default_caches_redis (cognitive 56) lightrag/tools/migrate_llm_cache.py:339— MigrationTool.get_default_caches_redis has cognitive complexity 56 (threshold 15). Drivers by points: if/else 4 (17 pts), loops 5 (16 pts), ternaries 2 (13 pts), error handling 2 (10 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.
document_routes.background_delete_documents (cognitive 55) lightrag/api/routers/document_routes.py:4150— document_routes.background_delete_documents has cognitive complexity 55 (threshold 15). Drivers by points: if/else 13 (30 pts), error handling 6 (14 pts), loops 2 (5 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 29). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
graph.useGraphStoreBase (cognitive 55) lightrag_webui/src/stores/graph.ts:192— graph.useGraphStoreBase has cognitive complexity 55 (threshold 15). Drivers by points: if/else 18 (34 pts), ternaries 5 (8 pts), boolean chains 7, error handling 4 (6 pts) (nesting depth added 21). None of this is in the body itself: all 55 points belong to 7 function literals inside it that branch (lines 327, 441, 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.
FaissVectorDBStorage._flush_pending_locked (cognitive 54) REDACTED:907— FaissVectorDBStorage._flush_pending_locked has cognitive complexity 54 (threshold 15). Drivers by points: if/else 18 (34 pts), loops 9 (15 pts), boolean chains 3, error handling 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.
writer.write_sidecar (cognitive 54) REDACTED:60— writer.write_sidecar has cognitive complexity 54 (threshold 15). Drivers by points: if/else 18 (31 pts), loops 7 (13 pts), boolean chains 8, error handling 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.
NanoVectorDBStorage._flush_pending_locked (cognitive 53) REDACTED:531— NanoVectorDBStorage._flush_pending_locked has cognitive complexity 53 (threshold 15). Drivers by points: if/else 18 (39 pts), loops 6 (10 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MongoGraphStorage._dedupe_legacy_edges (cognitive 52) lightrag/kg/mongo_impl.py:1997— MongoGraphStorage._dedupe_legacy_edges has cognitive complexity 52 (threshold 15). Drivers by points: if/else 15 (36 pts), ternaries 3 (9 pts), loops 3 (5 pts), boolean chains 2 (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.
RedisDocStatusStorage.get_docs_paginated (cognitive 52) lightrag/kg/redis_impl.py:1680— RedisDocStatusStorage.get_docs_paginated has cognitive complexity 52 (threshold 15). Drivers by points: if/else 13 (38 pts), loops 3 (7 pts), error handling 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.
operate._rebuild_single_entity (cognitive 52) lightrag/operate.py:1755— operate._rebuild_single_entity has cognitive complexity 52 (threshold 15). Drivers by points: if/else 25 (43 pts), boolean chains 5, loops 3 (4 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
operate._find_related_text_unit_from_relations (cognitive 52) lightrag/operate.py:6621— operate._find_related_text_unit_from_relations has cognitive complexity 52 (threshold 15). Drivers by points: if/else 21 (39 pts), loops 6 (8 pts), error handling 1 (3 pts), boolean chains 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NumberingResolver.get_label (cognitive 52) lightrag/parser/docx/numbering_resolver.py:402— NumberingResolver.get_label has cognitive complexity 52 (threshold 15). Drivers by points: if/else 26 (43 pts), boolean chains 6, loops 2, error handling 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.
extract.extract_markdown (cognitive 52) lightrag/parser/markdown/extract.py:359— extract.extract_markdown has cognitive complexity 52 (threshold 15). Drivers by points: if/else 14 (40 pts), loops 3 (8 pts), boolean chains 4 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document_routes.run_scanning_process (cognitive 50) lightrag/api/routers/document_routes.py:3674— document_routes.run_scanning_process has cognitive complexity 50 (threshold 15). Drivers by points: if/else 18 (29 pts), error handling 6 (11 pts), boolean chains 6, loops 2, ternaries 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.
heading_flow.assign_levels_by_size (cognitive 50) lightrag/parser/docx/smart_heading/heading_flow.py:1265— heading_flow.assign_levels_by_size has cognitive complexity 50 (threshold 15). Drivers by points: if/else 15 (26 pts), loops 6 (11 pts), ternaries 3 (7 pts), boolean chains 6 (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.
_StorageMigrationMixin._migrate_entity_relation_data (cognitive 50) lightrag/storage_migrations.py:109— _StorageMigrationMixin._migrate_entity_relation_data has cognitive complexity 50 (threshold 15). Drivers by points: if/else 10 (30 pts), loops 8 (15 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
config.parse_args (cognitive 49) REDACTED:346— config.parse_args has cognitive complexity 49 (threshold 15). Drivers by points: if/else 21 (35 pts), boolean chains 8, error handling 2 (4 pts), loops 1, ternaries 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.
_PipelineMixin._resolve_source_file_for_parser (cognitive 49) lightrag/pipeline.py:6721— _PipelineMixin._resolve_source_file_for_parser has cognitive complexity 49 (threshold 15). Drivers by points: if/else 14 (32 pts), loops 5 (12 pts), boolean chains 5 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.enforce_chunk_token_limit_before_embedding (cognitive 49) REDACTED:4265— utils.enforce_chunk_token_limit_before_embedding has cognitive complexity 49 (threshold 15). Drivers by points: if/else 14 (36 pts), boolean chains 6, loops 3 (4 pts), error handling 1 (3 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.
title_block.judge_title_block (cognitive 48) lightrag/parser/docx/smart_heading/title_block.py:1481— title_block.judge_title_block has cognitive complexity 48 (threshold 15). Drivers by points: if/else 21 (35 pts), ternaries 3 (8 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.
Neo4JStorage._robust_fallback (cognitive 47) lightrag/kg/neo4j_impl.py:1531— Neo4JStorage._robust_fallback has cognitive complexity 47 (threshold 15). Drivers by points: if/else 14 (41 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 28). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
PostgreSQLDB.configure_age_extension (cognitive 46) REDACTED:1004— PostgreSQLDB.configure_age_extension has cognitive complexity 46 (threshold 15). Drivers by points: if/else 18 (33 pts), boolean chains 5, error handling 3 (4 pts), ternaries 2 (4 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
anthropic.anthropic_complete_if_cache (cognitive 46) lightrag/llm/anthropic.py:53— anthropic.anthropic_complete_if_cache has cognitive complexity 46 (threshold 15). Drivers by points: if/else 15 (20 pts), error handling 11 (17 pts), boolean chains 4, ternaries 2 (3 pts), loops 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow.backfill_top_level (cognitive 46) lightrag/parser/docx/smart_heading/heading_flow.py:1381— heading_flow.backfill_top_level has cognitive complexity 46 (threshold 15). Drivers by points: if/else 20 (36 pts), boolean chains 6, loops 4 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow.merge_split_headings (cognitive 46) lightrag/parser/docx/smart_heading/heading_flow.py:1872— heading_flow.merge_split_headings has cognitive complexity 46 (threshold 15). Drivers by points: if/else 12 (34 pts), boolean chains 7, loops 2 (3 pts), ternaries 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.
rerank.generic_rerank_api (cognitive 46) lightrag/rerank.py:240— rerank.generic_rerank_api has cognitive complexity 46 (threshold 15). Drivers by points: if/else 27 (41 pts), boolean chains 4, 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.
utils_graph.aedit_entity (cognitive 46) lightrag/utils_graph.py:1550— utils_graph.aedit_entity has cognitive complexity 46 (threshold 15). Drivers by points: if/else 16 (25 pts), error handling 4 (11 pts), ternaries 4 (7 pts), boolean chains 3 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MessageList.MessageList (cognitive 46) lightrag_webui/src/features/retrieval/MessageList.tsx:39— MessageList.MessageList has cognitive complexity 46 (threshold 15). Drivers by points: if/else 20 (22 pts), boolean chains 12, ternaries 7 (11 pts), error handling 1 (nesting depth added 6). Most of this is not in the body itself: 2 of the 46 points are its own statements and the rest belongs to 11 function literals inside it that branch (lines 212, 133, 308, …). 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.
NanoVectorDBStorage.get_vectors_by_ids (cognitive 45) REDACTED:1383— NanoVectorDBStorage.get_vectors_by_ids has cognitive complexity 45 (threshold 15). Drivers by points: if/else 16 (36 pts), loops 4 (7 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.
bedrock.bedrock_complete_if_cache (cognitive 45) lightrag/llm/bedrock.py:187— bedrock.bedrock_complete_if_cache has cognitive complexity 45 (threshold 15). Drivers by points: if/else 21 (26 pts), boolean chains 10, loops 4 (5 pts), ternaries 1 (3 pts), error handling 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, 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.
MinerUIRBuilder._build_ir_table (cognitive 45) lightrag/parser/external/mineru/ir_builder.py:506— MinerUIRBuilder._build_ir_table has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (24 pts), boolean chains 15, error handling 1 (3 pts), ternaries 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.
UploadDocumentsDialog.UploadDocumentsDialog (cognitive 45) lightrag_webui/src/components/documents/UploadDocumentsDialog.tsx:38— UploadDocumentsDialog.UploadDocumentsDialog has cognitive complexity 45 (threshold 15). Drivers by points: if/else 19 (32 pts), boolean chains 8, error handling 2 (3 pts), loops 1, ternaries 1 (nesting depth added 14). Most of this is not in the body itself: 1 of the 45 points is its own statement and the rest belongs to 6 function literals inside it that branch (lines 100, 247, 56, …). 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.
GraphLabels.GraphLabels (cognitive 45) lightrag_webui/src/components/graph/GraphLabels.tsx:18— GraphLabels.GraphLabels has cognitive complexity 45 (threshold 15). Drivers by points: if/else 24 (26 pts), boolean chains 9, error handling 5 (8 pts), ternaries 2 (nesting depth added 5). Most of this is not in the body itself: 6 of the 45 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 156, 124, 285, …). 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.
PGGraphStorage.get_knowledge_graph (cognitive 44) REDACTED:9242— PGGraphStorage.get_knowledge_graph has cognitive complexity 44 (threshold 15). Drivers by points: if/else 12 (34 pts), boolean chains 5, loops 1 (3 pts), ternaries 1 (2 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.
LightRAG._prune_doc_recovery_anchors (cognitive 44) lightrag/lightrag.py:3692— LightRAG._prune_doc_recovery_anchors has cognitive complexity 44 (threshold 15). Drivers by points: if/else 8 (22 pts), boolean chains 8, ternaries 2 (8 pts), loops 2 (6 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.
title_block.detect_imprint_regions (cognitive 44) lightrag/parser/docx/smart_heading/title_block.py:402— title_block.detect_imprint_regions has cognitive complexity 44 (threshold 15). Drivers by points: if/else 11 (30 pts), loops 4 (8 pts), boolean chains 6 (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.
ChatMessage.ChatMessage (cognitive 44) lightrag_webui/src/components/retrieval/ChatMessage.tsx:57— ChatMessage.ChatMessage has cognitive complexity 44 (threshold 15). Drivers by points: boolean chains 29, ternaries 7 (9 pts), if/else 4 (5 pts), error handling 1 (nesting depth added 3). Of this number, 37 points are the body's own statements and 7 belong to 5 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.
recursive_character._split_text_with_regex_spans (cognitive 43) lightrag/chunker/recursive_character.py:61— recursive_character._split_text_with_regex_spans has cognitive complexity 43 (threshold 15). Drivers by points: if/else 14 (29 pts), loops 3 (8 pts), ternaries 2 (6 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.
ollama._ollama_model_if_cache (cognitive 43) lightrag/llm/ollama.py:209— ollama._ollama_model_if_cache has cognitive complexity 43 (threshold 15). Drivers by points: if/else 22 (33 pts), error handling 3 (5 pts), boolean chains 4, 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.
ir_builder._build_ir_drawing (cognitive 43) lightrag/parser/external/docling/ir_builder.py:857— ir_builder._build_ir_drawing has cognitive complexity 43 (threshold 15). Drivers by points: if/else 19 (26 pts), boolean chains 13, ternaries 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
chunk_tracking_repair._accumulate_cached_attribution (cognitive 43) lightrag/tools/chunk_tracking_repair.py:841— chunk_tracking_repair._accumulate_cached_attribution has cognitive complexity 43 (threshold 15). Drivers by points: if/else 7 (24 pts), loops 5 (14 pts), error handling 1 (4 pts), boolean chains 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
kg_integrity_repair.audit_kg_integrity (cognitive 43) lightrag/tools/kg_integrity_repair.py:70— kg_integrity_repair.audit_kg_integrity has cognitive complexity 43 (threshold 15). Drivers by points: if/else 11 (20 pts), loops 10 (14 pts), boolean chains 9 (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.
PGGraphStorage._bfs_subgraph (cognitive 42) REDACTED:9026— PGGraphStorage._bfs_subgraph has cognitive complexity 42 (threshold 15). Drivers by points: if/else 12 (31 pts), boolean chains 6, loops 3 (5 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.
RedisDocStatusStorage.get_doc_by_content_hash (cognitive 42) lightrag/kg/redis_impl.py:1972— RedisDocStatusStorage.get_doc_by_content_hash has cognitive complexity 42 (threshold 15). Drivers by points: if/else 9 (26 pts), loops 3 (7 pts), error handling 1 (4 pts), ternaries 1 (4 pts), boolean chains 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.
RedisDocStatusStorage._publish_rebuilt_index (cognitive 42) lightrag/kg/redis_impl.py:2714— RedisDocStatusStorage._publish_rebuilt_index has cognitive complexity 42 (threshold 15). Drivers by points: if/else 7 (26 pts), loops 5 (16 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.
operate._handle_entity_relation_summary (cognitive 42) lightrag/operate.py:372— operate._handle_entity_relation_summary has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (27 pts), loops 4 (7 pts), boolean chains 4, ternaries 1 (4 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DocumentManager.formatMetadata (cognitive 42) lightrag_webui/src/features/DocumentManager.tsx:115— DocumentManager.formatMetadata has cognitive complexity 42 (threshold 15). Drivers by points: if/else 22 (33 pts), boolean chains 9 (nesting depth added 11). Of this number, 24 points are the body's own statements and 18 belong to 4 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document_routes.delete_file_variants_by_file_path (cognitive 41) lightrag/api/routers/document_routes.py:2232— document_routes.delete_file_variants_by_file_path has cognitive complexity 41 (threshold 15). Drivers by points: if/else 8 (24 pts), error handling 4 (12 pts), loops 2 (3 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.
heading_flow.nest_numbered_under_parent (cognitive 41) lightrag/parser/docx/smart_heading/heading_flow.py:2537— heading_flow.nest_numbered_under_parent has cognitive complexity 41 (threshold 15). Drivers by points: if/else 11 (29 pts), boolean chains 7, loops 3 (5 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.is_gemini_retryable (cognitive 41) lightrag/parser/docx/utils.py:316— utils.is_gemini_retryable has cognitive complexity 41 (threshold 15). Drivers by points: if/else 21 (22 pts), boolean chains 19 (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.
useQuerySession.useQuerySession.submitQuery (cognitive 41) lightrag_webui/src/features/retrieval/useQuerySession.ts:248— useQuerySession.useQuerySession.submitQuery has cognitive complexity 41 (threshold 15). Drivers by points: if/else 28 (43 pts), boolean chains 13, error handling 3 (7 pts), loops 1, ternaries 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. This shape REPEATS in the file: one other method here (useQuerySession.useQuerySession.submitQuery::updateAssistantMessage) 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.
LightRAG.__post_init__ (cognitive 40) lightrag/lightrag.py:1638— LightRAG.__post_init__ has cognitive complexity 40 (threshold 15). Drivers by points: if/else 29 (35 pts), boolean chains 3, loops 2 (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.
NumberingResolver._parse_numbering_xml (cognitive 40) lightrag/parser/docx/numbering_resolver.py:186— NumberingResolver._parse_numbering_xml has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (22 pts), ternaries 3 (9 pts), loops 4 (6 pts), boolean chains 2, 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.
_PipelineMixin._validate_and_fix_document_consistency (cognitive 40) lightrag/pipeline.py:2913— _PipelineMixin._validate_and_fix_document_consistency has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (22 pts), loops 6 (10 pts), boolean chains 3, error handling 1 (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.
chunk_tracking_repair.run (cognitive 40) lightrag/tools/chunk_tracking_repair.py:1080— chunk_tracking_repair.run has cognitive complexity 40 (threshold 15). Drivers by points: if/else 16 (25 pts), ternaries 4 (9 pts), boolean chains 4, error handling 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
rebuild_vdb.check_vdb_consistency (cognitive 39) lightrag/tools/rebuild_vdb.py:518— rebuild_vdb.check_vdb_consistency has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 7 (10 pts), boolean chains 5 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.use_llm_func_with_cache (cognitive 39) REDACTED:5515— utils.use_llm_func_with_cache has cognitive complexity 39 (threshold 15). Drivers by points: if/else 19 (33 pts), boolean chains 2, loops 1 (2 pts), error handling 1, ternaries 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.
utils.normalize_extracted_info (cognitive 39) REDACTED:5838— utils.normalize_extracted_info has cognitive complexity 39 (threshold 15). Drivers by points: if/else 14 (29 pts), boolean chains 10 (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.
QueryComposer.QueryComposer (cognitive 39) lightrag_webui/src/features/retrieval/QueryComposer.tsx:24— QueryComposer.QueryComposer has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 13, ternaries 6 (10 pts) (nesting depth added 8). Most of this is not in the body itself: 11 of the 39 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 81, 60, 92, …). 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.
PostgreSQLDB.check_tables (cognitive 38) REDACTED:2437— PostgreSQLDB.check_tables has cognitive complexity 38 (threshold 15). Drivers by points: error handling 20 (27 pts), if/else 6 (9 pts), loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
shared_storage.finalize_share_data (cognitive 38) lightrag/kg/shared_storage.py:4001— shared_storage.finalize_share_data has cognitive complexity 38 (threshold 15). Drivers by points: if/else 8 (21 pts), error handling 3 (8 pts), loops 2 (8 pts), boolean chains 1 (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.
LightRAG._rollback_one_custom_chunk_patch (cognitive 38) lightrag/lightrag.py:3436— LightRAG._rollback_one_custom_chunk_patch has cognitive complexity 38 (threshold 15). Drivers by points: if/else 14 (20 pts), boolean chains 16, 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.
gemini.gemini_complete_if_cache (cognitive 38) lightrag/llm/gemini.py:312— gemini.gemini_complete_if_cache has cognitive complexity 38 (threshold 15). Drivers by points: if/else 21 (26 pts), boolean chains 10, ternaries 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, 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.
operate._find_related_text_unit_from_entities (cognitive 38) lightrag/operate.py:6350— operate._find_related_text_unit_from_entities has cognitive complexity 38 (threshold 15). Drivers by points: if/else 16 (27 pts), loops 5 (6 pts), error handling 1 (3 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MigrationTool.setup_storage (cognitive 38) lightrag/tools/migrate_llm_cache.py:1006— MigrationTool.setup_storage has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (17 pts), ternaries 7 (12 pts), loops 3 (6 pts), error handling 2, 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.
utils_graph.aedit_relation (cognitive 38) lightrag/utils_graph.py:1850— utils_graph.aedit_relation has cognitive complexity 38 (threshold 15). Drivers by points: if/else 14 (28 pts), boolean chains 4, error handling 3, ternaries 2 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
state.useBackendStateStoreBase (cognitive 38) lightrag_webui/src/stores/state.ts:75— state.useBackendStateStoreBase has cognitive complexity 38 (threshold 15). Drivers by points: if/else 13 (25 pts), ternaries 3 (8 pts), boolean chains 5 (nesting depth added 17). None of this is in the body itself: all 38 points belong to 5 function literals inside it that branch (lines 88, 163, 199, …). 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.
ui_customization._completes_svg_start_tag (cognitive 37) lightrag/api/ui_customization.py:353— ui_customization._completes_svg_start_tag has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (22 pts), loops 5 (9 pts), boolean chains 6 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FaissVectorDBStorage.get_vectors_by_ids (cognitive 37) REDACTED:1774— FaissVectorDBStorage.get_vectors_by_ids has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (31 pts), loops 3 (5 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.
ir_builder._precompute_consumed_refs (cognitive 37) lightrag/parser/external/docling/ir_builder.py:549— ir_builder._precompute_consumed_refs has cognitive complexity 37 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 9 (15 pts), boolean chains 4 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.safe_vdb_operation_with_exception (cognitive 37) REDACTED:156— utils.safe_vdb_operation_with_exception has cognitive complexity 37 (threshold 15). Drivers by points: if/else 9 (21 pts), boolean chains 8, error handling 2 (4 pts), ternaries 1 (3 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.
Neo4JStorage.initialize (cognitive 36) lightrag/kg/neo4j_impl.py:183— Neo4JStorage.initialize has cognitive complexity 36 (threshold 15). Drivers by points: if/else 5 (21 pts), error handling 5 (13 pts), boolean chains 1, loops 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Neo4JStorage.get_knowledge_graph (cognitive 36) lightrag/kg/neo4j_impl.py:1301— Neo4JStorage.get_knowledge_graph has cognitive complexity 36 (threshold 15). Drivers by points: if/else 17 (30 pts), loops 2 (4 pts), boolean chains 1, 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.
OpenSearchGraphStorage._bfs_subgraph_ppl (cognitive 36) lightrag/kg/opensearch_impl.py:5558— OpenSearchGraphStorage._bfs_subgraph_ppl has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (22 pts), loops 5 (8 pts), ternaries 2 (3 pts), error handling 2, 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.
PGVectorStorage._flush_pending_vector_ops (cognitive 36) REDACTED:4781— PGVectorStorage._flush_pending_vector_ops has cognitive complexity 36 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 7, loops 4 (5 pts), error handling 2 (3 pts), ternaries 2 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
PGGraphStorage.get_edges_batch (cognitive 36) REDACTED:8807— PGGraphStorage.get_edges_batch has cognitive complexity 36 (threshold 15). Drivers by points: if/else 6 (17 pts), error handling 2 (10 pts), loops 4 (6 pts), boolean chains 3 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
features.parse_styles_attributes (cognitive 36) REDACTED:188— features.parse_styles_attributes has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (26 pts), ternaries 2 (5 pts), error handling 2, loops 2, boolean chains 1 (nesting depth added 17). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
RebuildTool.run (cognitive 36) lightrag/tools/rebuild_vdb.py:1094— RebuildTool.run has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (23 pts), error handling 4 (6 pts), ternaries 2 (4 pts), loops 2, 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.
LoginPage.LoginPage (cognitive 36) lightrag_webui/src/features/LoginPage.tsx:45— LoginPage.LoginPage has cognitive complexity 36 (threshold 15). Drivers by points: boolean chains 18, if/else 12 (14 pts), error handling 2, ternaries 2 (nesting depth added 2). Most of this is not in the body itself: 10 of the 36 points are its own statements and the rest belongs to 2 function items inside it that branch (a function literal at line 99, handleSubmit). 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.
NanoVectorDBStorage.get_by_ids (cognitive 35) REDACTED:1316— NanoVectorDBStorage.get_by_ids has cognitive complexity 35 (threshold 15). Drivers by points: if/else 13 (30 pts), loops 3 (5 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PGVectorStorage.get_vectors_by_ids (cognitive 35) REDACTED:5392— PGVectorStorage.get_vectors_by_ids has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (23 pts), error handling 3 (5 pts), loops 3 (4 pts), boolean chains 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LightRAG._purge_kg_contributions (cognitive 35) lightrag/lightrag.py:6015— LightRAG._purge_kg_contributions has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 7, ternaries 3 (7 pts), error handling 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.
drawing_image_extractor.extract_vml_image_placeholder_from_element (cognitive 35) REDACTED:533— drawing_image_extractor.extract_vml_image_placeholder_from_element has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (31 pts), boolean chains 2, ternaries 2 (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.
QdrantVectorDBStorage.get_vectors_by_ids (cognitive 34) lightrag/kg/qdrant_impl.py:1248— QdrantVectorDBStorage.get_vectors_by_ids has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (24 pts), loops 3 (4 pts), boolean chains 3, error handling 2 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
operate.kg_query (cognitive 34) lightrag/operate.py:4693— operate.kg_query has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (22 pts), boolean chains 6, ternaries 6 (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.
drawing_image_extractor.extract_drawing_placeholder_from_element (cognitive 34) REDACTED:491— drawing_image_extractor.extract_drawing_placeholder_from_element has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (30 pts), boolean chains 2, ternaries 2 (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.
param_schema.parse_chunk_params (cognitive 34) lightrag/parser/param_schema.py:196— param_schema.parse_chunk_params has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (31 pts), boolean chains 2, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
splitSettingsStorage.runSettingsStorageSplitMigration (cognitive 34) lightrag_webui/src/migrations/splitSettingsStorage.ts:554— splitSettingsStorage.runSettingsStorageSplitMigration has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (23 pts), error handling 3 (5 pts), boolean chains 4, ternaries 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.
recursive_character._merge_splits_with_spans (cognitive 33) lightrag/chunker/recursive_character.py:175— recursive_character._merge_splits_with_spans has cognitive complexity 33 (threshold 15). Drivers by points: if/else 5 (13 pts), ternaries 4 (13 pts), loops 2 (5 pts), boolean chains 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.
operate.extract_entities (cognitive 33) lightrag/operate.py:3942— operate.extract_entities has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 4, loops 3 (4 pts), ternaries 2 (4 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.
param_schema.parse_engine_params (cognitive 33) lightrag/parser/param_schema.py:500— param_schema.parse_engine_params has cognitive complexity 33 (threshold 15). Drivers by points: if/else 15 (29 pts), boolean chains 2, loops 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils_api.display_splash_screen (cognitive 32) lightrag/api/utils_api.py:618— utils_api.display_splash_screen has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (18 pts), ternaries 8 (10 pts), boolean chains 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.
MilvusVectorDBStorage._check_vector_dimension (cognitive 32) lightrag/kg/milvus_impl.py:1455— MilvusVectorDBStorage._check_vector_dimension has cognitive complexity 32 (threshold 15). Drivers by points: if/else 6 (17 pts), ternaries 2 (8 pts), error handling 1 (4 pts), boolean chains 2, loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenSearchGraphStorage._bfs_subgraph (cognitive 32) lightrag/kg/opensearch_impl.py:5726— OpenSearchGraphStorage._bfs_subgraph has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 5 (10 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.
PGKVStorage.upsert (cognitive 32) REDACTED:3642— PGKVStorage.upsert has cognitive complexity 32 (threshold 15). Drivers by points: loops 8 (16 pts), if/else 6 (9 pts), boolean chains 4, ternaries 1 (3 pts) (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
RedisDocStatusStorage._do_rebuild (cognitive 32) lightrag/kg/redis_impl.py:2614— RedisDocStatusStorage._do_rebuild has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 3 (7 pts), error handling 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.
bedrock.bedrock_embed (cognitive 32) lightrag/llm/bedrock.py:566— bedrock.bedrock_embed has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (18 pts), error handling 3 (6 pts), boolean chains 3, ternaries 1 (3 pts), loops 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.
check_initialization.check_lightrag_setup (cognitive 32) lightrag/tools/check_initialization.py:30— check_initialization.check_lightrag_setup has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 4 (9 pts), boolean chains 2, error handling 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.
CleanupTool.delete_query_caches_opensearch (cognitive 32) lightrag/tools/clean_llm_query_cache.py:703— CleanupTool.delete_query_caches_opensearch has cognitive complexity 32 (threshold 15). Drivers by points: if/else 5 (22 pts), loops 4 (7 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.process_chunks_unified (cognitive 32) REDACTED:7055— utils.process_chunks_unified has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (23 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
lightrag.queryTextStream (cognitive 32) lightrag_webui/src/api/lightrag.ts:879— lightrag.queryTextStream has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (26 pts), error handling 2 (5 pts), boolean chains 1 (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
AsyncSelect.AsyncSelect (cognitive 32) lightrag_webui/src/components/ui/AsyncSelect.tsx:74— AsyncSelect.AsyncSelect has cognitive complexity 32 (threshold 15). Drivers by points: boolean chains 15, ternaries 10 (13 pts), if/else 3, error handling 1 (nesting depth added 3). Most of this is not in the body itself: 14 of the 32 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 130, 107, 124, …). 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.
MongoGraphStorage.get_knowledge_subgraph_in_out_bound_bfs (cognitive 31) lightrag/kg/mongo_impl.py:3327— MongoGraphStorage.get_knowledge_subgraph_in_out_bound_bfs has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 7 (9 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.
operate._process_extraction_result (cognitive 31) lightrag/operate.py:1508— operate._process_extraction_result has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 4 (7 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OMMLParser.parse_group_chr (cognitive 31) REDACTED:260— OMMLParser.parse_group_chr has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
parse_document._assemble_blocks_legacy (cognitive 31) REDACTED:944— parse_document._assemble_blocks_legacy has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (30 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.
_PipelineMixin._pipeline_feeder (cognitive 31) lightrag/pipeline.py:2507— _PipelineMixin._pipeline_feeder has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (23 pts), error handling 2 (4 pts), loops 2 (4 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.wait_tasks_with_drain (cognitive 31) REDACTED:4581— utils.wait_tasks_with_drain has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 4 (7 pts), error handling 2 (3 pts), boolean chains 1, 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.
PropertiesView.refineNodeProperties (cognitive 31) lightrag_webui/src/components/graph/PropertiesView.tsx:79— PropertiesView.refineNodeProperties has cognitive complexity 31 (threshold 15). Drivers by points: if/else 6 (17 pts), ternaries 2 (9 pts), error handling 1 (2 pts), loops 1 (2 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.
recursive_character._split_text_with_spans (cognitive 30) lightrag/chunker/recursive_character.py:321— recursive_character._split_text_with_spans has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (19 pts), ternaries 3 (6 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Neo4JStorage._create_fulltext_index (cognitive 30) lightrag/kg/neo4j_impl.py:335— Neo4JStorage._create_fulltext_index has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (16 pts), error handling 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.
OpenSearchGraphStorage._migrate_edges_to_canonical_id_if_needed (cognitive 30) lightrag/kg/opensearch_impl.py:3897— OpenSearchGraphStorage._migrate_edges_to_canonical_id_if_needed has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (16 pts), error handling 4 (6 pts), ternaries 2 (4 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
QdrantVectorDBStorage._flush_pending_vector_ops (cognitive 30) lightrag/kg/qdrant_impl.py:848— QdrantVectorDBStorage._flush_pending_vector_ops has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 5 (8 pts), error handling 2 (3 pts), boolean chains 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.
RedisDocStatusStorage.get_docs_by_statuses (cognitive 30) lightrag/kg/redis_impl.py:1276— RedisDocStatusStorage.get_docs_by_statuses has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (18 pts), loops 3 (7 pts), error handling 2 (5 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LightRAG._resolve_purge_recovery_proof (cognitive 30) lightrag/lightrag.py:5674— LightRAG._resolve_purge_recovery_proof has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 10, ternaries 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
multimodal_context._build_leading (cognitive 30) lightrag/multimodal_context.py:505— multimodal_context._build_leading has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (28 pts), boolean chains 1, 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. This shape REPEATS in the file: one other method here (multimodal_context._build_trailing) 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.
multimodal_context._build_trailing (cognitive 30) lightrag/multimodal_context.py:629— multimodal_context._build_trailing has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (28 pts), boolean chains 1, 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. This shape REPEATS in the file: one other method here (multimodal_context._build_leading) 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.
multimodal_context.enrich_sidecars_with_surrounding (cognitive 30) lightrag/multimodal_context.py:978— multimodal_context.enrich_sidecars_with_surrounding has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (22 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.
OMMLParser.parse_nary (cognitive 30) REDACTED:531— OMMLParser.parse_nary has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (19 pts), error handling 1 (6 pts), loops 3 (5 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
rerank.chunk_documents_for_rerank (cognitive 30) lightrag/rerank.py:36— rerank.chunk_documents_for_rerank has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 4 (10 pts), error handling 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.
paragraph_semantic._expand_block_with_table_splits (cognitive 29) lightrag/chunker/paragraph_semantic.py:969— paragraph_semantic._expand_block_with_table_splits has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemgraphStorage.get_knowledge_graph (cognitive 29) lightrag/kg/memgraph_impl.py:1051— MemgraphStorage.get_knowledge_graph has cognitive complexity 29 (threshold 15). Drivers by points: if/else 13 (23 pts), loops 2 (4 pts), boolean chains 1, 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.
MilvusVectorDBStorage._create_collection_if_not_exist (cognitive 29) lightrag/kg/milvus_impl.py:2262— MilvusVectorDBStorage._create_collection_if_not_exist has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (16 pts), error handling 4 (7 pts), boolean chains 4, 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.
PostgreSQLDB._create_ssl_context (cognitive 29) REDACTED:530— PostgreSQLDB._create_ssl_context has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (25 pts), boolean chains 2, 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.
QdrantVectorDBStorage.get_by_ids (cognitive 29) lightrag/kg/qdrant_impl.py:1176— QdrantVectorDBStorage.get_by_ids has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 3 (4 pts), ternaries 1 (3 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
operate._process_json_extraction_result (cognitive 29) lightrag/operate.py:907— operate._process_json_extraction_result has cognitive complexity 29 (threshold 15). Drivers by points: if/else 13 (22 pts), error handling 2 (4 pts), loops 2, boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
operate._merge_all_chunks (cognitive 29) lightrag/operate.py:5765— operate._merge_all_chunks has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 9, 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.
drawing_image_extractor.load_relationships (cognitive 29) REDACTED:381— drawing_image_extractor.load_relationships has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 3 (5 pts), boolean chains 3, 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.
MigrationTool.run (cognitive 29) lightrag/tools/migrate_llm_cache.py:1419— MigrationTool.run has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (15 pts), error handling 5 (7 pts), loops 2 (7 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils_graph._merge_attributes (cognitive 29) lightrag/utils_graph.py:3579— utils_graph._merge_attributes has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 4 (8 pts), error handling 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.
App.App (cognitive 29) lightrag_webui/src/App.tsx:31— App.App has cognitive complexity 29 (threshold 15). Drivers by points: boolean chains 13, if/else 11 (13 pts), error handling 2, ternaries 1 (nesting depth added 2). Most of this is not in the body itself: 7 of the 29 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 111, 66, 68, …). 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.
PipelineStatusDialog.PipelineStatusDialog (cognitive 29) lightrag_webui/src/components/documents/PipelineStatusDialog.tsx:25— PipelineStatusDialog.PipelineStatusDialog has cognitive complexity 29 (threshold 15). Drivers by points: boolean chains 11, if/else 10 (11 pts), ternaries 5, error handling 2 (nesting depth added 1). Of this number, 15 points are the body's own statements and 14 belong to 6 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.
FileUploader.FileUploader (cognitive 29) lightrag_webui/src/components/ui/FileUploader.tsx:151— FileUploader.FileUploader has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (17 pts), boolean chains 7, ternaries 4 (5 pts) (nesting depth added 4). Most of this is not in the body itself: 3 of the 29 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 185, a function literal at line 328, a function literal at line 294, …). 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.
UserPromptInputWithHistory.UserPromptInputWithHistory (cognitive 29) lightrag_webui/src/components/ui/UserPromptInputWithHistory.tsx:17— UserPromptInputWithHistory.UserPromptInputWithHistory has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 9, ternaries 4 (7 pts), match/switch 1 (nesting depth added 6). Most of this is not in the body itself: 7 of the 29 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 49, a function literal at line 117, a function literal at line 35, …). 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.
PGGraphStorage.get_nodes_batch (cognitive 28) REDACTED:8594— PGGraphStorage.get_nodes_batch has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (18 pts), error handling 1 (5 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LightRAG._discard_pending_index_ops (cognitive 28) lightrag/lightrag.py:3814— LightRAG._discard_pending_index_ops has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (11 pts), error handling 3 (7 pts), boolean chains 5, ternaries 2 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
operate.merge_nodes_and_edges (cognitive 28) lightrag/operate.py:3514— operate.merge_nodes_and_edges has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 7 (11 pts), boolean chains 3, error handling 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.
operate._apply_token_truncation (cognitive 28) lightrag/operate.py:5501— operate._apply_token_truncation has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (20 pts), loops 6 (8 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.
DrawingExtractionContext.export_embedded_image (cognitive 28) REDACTED:124— DrawingExtractionContext.export_embedded_image has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (16 pts), error handling 7 (8 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.
utils.apply_rerank_if_enabled (cognitive 28) REDACTED:6924— utils.apply_rerank_if_enabled has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 4, loops 2 (4 pts), ternaries 1 (3 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.
legacySettingsChain.migrateLegacySettingsState (cognitive 28) lightrag_webui/src/migrations/legacySettingsChain.ts:32— legacySettingsChain.migrateLegacySettingsState has cognitive complexity 28 (threshold 15). Drivers by points: if/else 24 (28 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.
MongoVectorDBStorage._flush_pending_vector_ops (cognitive 27) lightrag/kg/mongo_impl.py:4718— MongoVectorDBStorage._flush_pending_vector_ops has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 4 (7 pts), error handling 2 (3 pts), boolean chains 2, 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.
OpenSearchVectorDBStorage.get_vectors_by_ids (cognitive 27) lightrag/kg/opensearch_impl.py:7125— OpenSearchVectorDBStorage.get_vectors_by_ids has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (18 pts), error handling 3 (4 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PGVectorStorage._pg_migrate_workspace_data (cognitive 27) REDACTED:4123— PGVectorStorage._pg_migrate_workspace_data has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 2 (3 pts), ternaries 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.
AsyncioScanJobStore.update (cognitive 27) lightrag/kg/scan_job_store.py:430— AsyncioScanJobStore.update has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (22 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.
LightRAG._persist_custom_chunk_recovery_warning (cognitive 27) lightrag/lightrag.py:3568— LightRAG._persist_custom_chunk_recovery_warning has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 3, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow._try_cb1_graduated_demotion (cognitive 27) lightrag/parser/docx/smart_heading/heading_flow.py:965— heading_flow._try_cb1_graduated_demotion has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (11 pts), ternaries 4 (8 pts), loops 4 (6 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MilvusVectorDBStorage.get_vectors_by_ids (cognitive 26) lightrag/kg/milvus_impl.py:3391— MilvusVectorDBStorage.get_vectors_by_ids has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 3 (4 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.
OpenSearchKVStorage.get_by_ids (cognitive 26) lightrag/kg/opensearch_impl.py:1339— OpenSearchKVStorage.get_by_ids has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (15 pts), ternaries 2 (4 pts), loops 2 (3 pts), boolean chains 2, error handling 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.
RedisDocStatusStorage.get_status_counts (cognitive 26) lightrag/kg/redis_impl.py:1216— RedisDocStatusStorage.get_status_counts has cognitive complexity 26 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 3 (7 pts), error handling 2 (6 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (RedisDocStatusStorage.get_doc_by_file_path) 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.
RedisDocStatusStorage.get_doc_by_file_path (cognitive 26) lightrag/kg/redis_impl.py:1822— RedisDocStatusStorage.get_doc_by_file_path has cognitive complexity 26 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 3 (7 pts), error handling 2 (6 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (RedisDocStatusStorage.get_status_counts) 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.
LightRAG.ainsert_custom_kg (cognitive 26) lightrag/lightrag.py:4340— LightRAG.ainsert_custom_kg has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 7, ternaries 2 (3 pts), boolean chains 2, error handling 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.
openai.create_openai_async_client (cognitive 26) lightrag/llm/openai.py:177— openai.create_openai_async_client has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (25 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.
OMMLParser.parse_acc (cognitive 26) REDACTED:187— OMMLParser.parse_acc has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (15 pts), error handling 1 (6 pts), loops 3 (5 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
title_block._render_table_window (cognitive 26) lightrag/parser/docx/smart_heading/title_block.py:1298— title_block._render_table_window has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 3 (8 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
routing._extract_param_blocks (cognitive 26) lightrag/parser/routing.py:710— routing._extract_param_blocks has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 2, 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.
CleanupTool.delete_query_caches_json (cognitive 26) lightrag/tools/clean_llm_query_cache.py:450— CleanupTool.delete_query_caches_json has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (17 pts), loops 4 (6 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
rebuild_vdb.enumerate_kv_keys (cognitive 26) lightrag/tools/rebuild_vdb.py:408— rebuild_vdb.enumerate_kv_keys has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 4 (9 pts), ternaries 1 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatMessage.CodeHighlight (cognitive 26) lightrag_webui/src/components/retrieval/ChatMessage.tsx:456— ChatMessage.CodeHighlight has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 6 (10 pts), if/else 8 (9 pts), boolean chains 7 (nesting depth added 5). Most of this is not in the body itself: 11 of the 26 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 469, getInlineCodeStyles, a function literal at line 621, …). 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.
QuerySettings.QuerySettings (cognitive 26) lightrag_webui/src/components/retrieval/QuerySettings.tsx:43— QuerySettings.QuerySettings has cognitive complexity 26 (threshold 15). Drivers by points: boolean chains 14, if/else 7, ternaries 5. Most of this is not in the body itself: 4 of the 26 points are its own statements and the rest belongs to 12 function literals inside it that branch (lines 258, 262, 298, …). 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.
useLightragGraph.fetchGraph (cognitive 26) lightrag_webui/src/hooks/useLightragGraph.tsx:150— useLightragGraph.fetchGraph has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 4 (9 pts), boolean chains 2, error handling 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
document_routes.pipeline_enqueue_file (cognitive 25) lightrag/api/routers/document_routes.py:2359— document_routes.pipeline_enqueue_file has cognitive complexity 25 (threshold 15). Drivers by points: error handling 8 (13 pts), if/else 9, 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.
RAGEvaluator._calculate_benchmark_stats (cognitive 25) lightrag/evaluation/eval_rag_quality.py:789— RAGEvaluator._calculate_benchmark_stats has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (17 pts), ternaries 3 (5 pts), loops 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FaissVectorDBStorage.get_by_ids (cognitive 25) REDACTED:1712— FaissVectorDBStorage.get_by_ids has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
opensearch_impl._extract_bulk_failed_ids (cognitive 25) lightrag/kg/opensearch_impl.py:189— opensearch_impl._extract_bulk_failed_ids has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (16 pts), ternaries 1 (4 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PGVectorStorage.get_by_ids (cognitive 25) REDACTED:5324— PGVectorStorage.get_by_ids has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (4 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RedisDocStatusStorage.list_source_conflicts_page (cognitive 25) lightrag/kg/redis_impl.py:2364— RedisDocStatusStorage.list_source_conflicts_page has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 3 (7 pts), boolean chains 2, ternaries 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.
_common.response_error_detail (cognitive 25) lightrag/parser/external/_common.py:116— _common.response_error_detail has cognitive complexity 25 (threshold 15). Drivers by points: error handling 4 (10 pts), if/else 8 (10 pts), ternaries 2 (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.
parser._pin_socket (cognitive 25) lightrag/parser/markdown/parser.py:860— parser._pin_socket has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (19 pts), ternaries 3, loops 1 (2 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.
routing._validate_filename_hint_for_resolution (cognitive 25) lightrag/parser/routing.py:930— routing._validate_filename_hint_for_resolution has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (22 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.
Tokenizer.split_by_token_limit (cognitive 25) REDACTED:3707— Tokenizer.split_by_token_limit has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 1 (3 pts), loops 2 (3 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils_pipeline.build_chunks_dict_from_chunking_result (cognitive 25) REDACTED:144— utils_pipeline.build_chunks_dict_from_chunking_result has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (4 pts), boolean chains 3, ternaries 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.
GraphSearch.GraphSearchInput (cognitive 25) lightrag_webui/src/components/graph/GraphSearch.tsx:66— GraphSearch.GraphSearchInput has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (14 pts), ternaries 4 (6 pts), boolean chains 5 (nesting depth added 4). Most of this is not in the body itself: 2 of the 25 points are its own statements and the rest belongs to 6 function literals inside it that branch (lines 126, 215, 87, …). 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.
MemgraphStorage.upsert_nodes_batch (cognitive 24) lightrag/kg/memgraph_impl.py:718— MemgraphStorage.upsert_nodes_batch has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (5 pts), error handling 2 (4 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenSearchGraphStorage._collect_node_ids (cognitive 24) lightrag/kg/opensearch_impl.py:5183— OpenSearchGraphStorage._collect_node_ids has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 2 (3 pts), boolean chains 2, ternaries 1 (2 pts), error handling 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.
RedisDocStatusStorage.get_docs_by_track_id (cognitive 24) lightrag/kg/redis_impl.py:1343— RedisDocStatusStorage.get_docs_by_track_id has cognitive complexity 24 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (7 pts), error handling 2 (5 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.
_vision_utils._read_jpeg_dimensions (cognitive 24) lightrag/llm/_vision_utils.py:195— _vision_utils._read_jpeg_dimensions has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingOptions.add_args (cognitive 24) lightrag/llm/binding_options.py:174— BindingOptions.add_args has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (15 pts), error handling 2 (8 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
zhipu.zhipu_complete_if_cache (cognitive 24) lightrag/llm/zhipu.py:45— zhipu.zhipu_complete_if_cache has cognitive complexity 24 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 5, error handling 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
_RoleLLMMixin._apply_llm_role_config_update (cognitive 24) lightrag/llm_roles.py:309— _RoleLLMMixin._apply_llm_role_config_update has cognitive complexity 24 (threshold 15). Drivers by points: if/else 15 (19 pts), boolean chains 4, error handling 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.
operate.naive_query (cognitive 24) lightrag/operate.py:6852— operate.naive_query has cognitive complexity 24 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 4, ternaries 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.
NumberingResolver._parse_styles_xml (cognitive 24) lightrag/parser/docx/numbering_resolver.py:273— NumberingResolver._parse_styles_xml has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (17 pts), ternaries 1 (5 pts), error handling 1, loops 1 (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
title_block._render_window (cognitive 24) lightrag/parser/docx/smart_heading/title_block.py:1182— title_block._render_window has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 2, loops 1, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cache.is_bundle_valid (cognitive 24) lightrag/parser/external/docling/cache.py:146— cache.is_bundle_valid has cognitive complexity 24 (threshold 15). Drivers by points: if/else 13 (16 pts), error handling 3 (4 pts), boolean chains 3, 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.
extractors._extract_xlsx (cognitive 24) lightrag/parser/legacy/extractors.py:105— extractors._extract_xlsx has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (6 pts), boolean chains 4 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TiktokenTokenizer.split_by_token_limit (cognitive 24) REDACTED:3917— TiktokenTokenizer.split_by_token_limit has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (15 pts), error handling 2 (4 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.
lightrag._readNdjsonStream (cognitive 24) lightrag_webui/src/api/lightrag.ts:695— lightrag._readNdjsonStream has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 3 (6 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 7). Of this number, 17 points are the body's own statements and 7 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
registry.resolve_chunker (cognitive 23) lightrag/chunker/registry.py:242— registry.resolve_chunker has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11, error handling 4 (6 pts), boolean chains 5, loops 1 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MongoVectorDBStorage.get_vectors_by_ids (cognitive 23) lightrag/kg/mongo_impl.py:5026— MongoVectorDBStorage.get_vectors_by_ids has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 3 (4 pts), error handling 2 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenSearchDocStatusStorage._search_all_docs (cognitive 23) lightrag/kg/opensearch_impl.py:2467— OpenSearchDocStatusStorage._search_all_docs has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (15 pts), error handling 3 (5 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.
OpenSearchDocStatusStorage.get_docs_paginated (cognitive 23) lightrag/kg/opensearch_impl.py:2558— OpenSearchDocStatusStorage.get_docs_paginated has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (15 pts), error handling 3 (4 pts), loops 2, 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.
OpenSearchVectorDBStorage._flush_pending_vector_ops (cognitive 23) lightrag/kg/opensearch_impl.py:6685— OpenSearchVectorDBStorage._flush_pending_vector_ops has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 3 (4 pts), error handling 2 (3 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.
PGGraphStorage.get_nodes_edges_batch (cognitive 23) REDACTED:8909— PGGraphStorage.get_nodes_edges_batch has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 5 (7 pts), boolean chains 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RedisDocStatusStorage.get_docs_by_statuses_page (cognitive 23) lightrag/kg/redis_impl.py:2104— RedisDocStatusStorage.get_docs_by_statuses_page has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 4 (5 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
openai.openai_embed (cognitive 23) lightrag/llm/openai.py:1054— openai.openai_embed has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 5, ternaries 3, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow.gate_with_cb1 (cognitive 23) lightrag/parser/docx/smart_heading/heading_flow.py:1065— heading_flow.gate_with_cb1 has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 6, ternaries 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.
cache.is_bundle_valid (cognitive 23) lightrag/parser/external/mineru/cache.py:333— cache.is_bundle_valid has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (15 pts), error handling 3 (4 pts), boolean chains 3, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
routing.validate_parser_routing_config (cognitive 23) lightrag/parser/routing.py:1152— routing.validate_parser_routing_config has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 1, loops 1, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CleanupTool.run (cognitive 23) lightrag/tools/clean_llm_query_cache.py:1055— CleanupTool.run has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (13 pts), error handling 7 (8 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.
Tokenizer._bounded_prefix_span (cognitive 23) REDACTED:3610— Tokenizer._bounded_prefix_span has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 3 (5 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AsyncSearch.AsyncSearch (cognitive 23) lightrag_webui/src/components/ui/AsyncSearch.tsx:62— AsyncSearch.AsyncSearch has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 11, if/else 6, ternaries 3 (5 pts), error handling 1 (nesting depth added 2). Most of this is not in the body itself: 9 of the 23 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 105, 89, 135, …). 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.
PaginationControls.PaginationControls (cognitive 23) lightrag_webui/src/components/ui/PaginationControls.tsx:36— PaginationControls.PaginationControls has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12, boolean chains 11. Most of this is not in the body itself: 9 of the 23 points are its own statements and the rest belongs to 7 function literals inside it that branch (lines 64, 98, 104, …). 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.
recursive_character.chunking_by_recursive_character (cognitive 22) lightrag/chunker/recursive_character.py:436— recursive_character.chunking_by_recursive_character has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (10 pts), loops 3 (5 pts), boolean chains 4, 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.
MongoDocStatusStorage.create_and_migrate_indexes_if_not_exists (cognitive 22) lightrag/kg/mongo_impl.py:917— MongoDocStatusStorage.create_and_migrate_indexes_if_not_exists has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (11 pts), error handling 3 (7 pts), loops 2, 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.
opensearch_impl._merge_edge_payloads (cognitive 22) lightrag/kg/opensearch_impl.py:652— opensearch_impl._merge_edge_payloads has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (14 pts), ternaries 3 (6 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
parse_document.parse_styles_outline_levels (cognitive 22) REDACTED:296— parse_document.parse_styles_outline_levels has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (18 pts), error handling 2, loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow._collect_series_group (cognitive 22) lightrag/parser/docx/smart_heading/heading_flow.py:1553— heading_flow._collect_series_group has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 5, error handling 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.
heading_flow.align_numbering_series (cognitive 22) lightrag/parser/docx/smart_heading/heading_flow.py:1610— heading_flow.align_numbering_series has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (5 pts), boolean chains 3, 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.
Manifest.from_dict (cognitive 22) lightrag/parser/external/_manifest.py:83— Manifest.from_dict has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 19, ternaries 2, if/else 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.
lightrag_server.create_optimized_embedding_function (cognitive 21) lightrag/api/lightrag_server.py:651— lightrag_server.create_optimized_embedding_function has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 8, ternaries 2, error handling 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.
MemgraphStorage.upsert_node (cognitive 21) lightrag/kg/memgraph_impl.py:529— MemgraphStorage.upsert_node has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 2 (4 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (MemgraphStorage.upsert_edges_batch) 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.
MemgraphStorage.upsert_edges_batch (cognitive 21) lightrag/kg/memgraph_impl.py:832— MemgraphStorage.upsert_edges_batch has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 2 (4 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (MemgraphStorage.upsert_node) 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.
MilvusVectorDBStorage._create_indexes_after_collection (cognitive 21) lightrag/kg/milvus_impl.py:1192— MilvusVectorDBStorage._create_indexes_after_collection has cognitive complexity 21 (threshold 15). Drivers by points: error handling 5 (13 pts), if/else 6 (8 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.
OpenSearchGraphStorage.get_nodes_edges_batch (cognitive 21) lightrag/kg/opensearch_impl.py:4602— OpenSearchGraphStorage.get_nodes_edges_batch has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (3 pts), error handling 2, boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenSearchVectorDBStorage.get_by_ids (cognitive 21) lightrag/kg/opensearch_impl.py:7066— OpenSearchVectorDBStorage.get_by_ids has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (13 pts), error handling 2 (3 pts), loops 2 (3 pts), boolean chains 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.
RedisKVStorage._migrate_legacy_cache_structure (cognitive 21) lightrag/kg/redis_impl.py:857— RedisKVStorage._migrate_legacy_cache_structure has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 3 (4 pts), boolean chains 3, 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.
shared_storage._reap_gate_state (cognitive 21) lightrag/kg/shared_storage.py:4265— shared_storage._reap_gate_state has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 2, 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.
LightRAG._upsert_custom_chunk_status (cognitive 21) lightrag/lightrag.py:3139— LightRAG._upsert_custom_chunk_status has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 11, if/else 7 (8 pts), loops 1, 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.
BindingOptions.args_env_name_type_value (cognitive 21) lightrag/llm/binding_options.py:289— BindingOptions.args_env_name_type_value has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 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.
style_key._extract_unit_and_ordinal (cognitive 21) lightrag/parser/docx/smart_heading/style_key.py:308— style_key._extract_unit_and_ordinal has cognitive complexity 21 (threshold 15). Drivers by points: if/else 14 (19 pts), ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Manifest.from_dict (cognitive 21) lightrag/parser/external/mineru/manifest.py:81— Manifest.from_dict has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 18, ternaries 2, if/else 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.
_PipelineMixin._refetch_for_decision (cognitive 21) lightrag/pipeline.py:3924— _PipelineMixin._refetch_for_decision has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (11 pts), error handling 4 (8 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.
migrate_graph_storage._unrepresentable_paths (cognitive 21) lightrag/tools/migrate_graph_storage.py:209— migrate_graph_storage._unrepresentable_paths has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 6, loops 2 (4 pts), ternaries 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utils.merge_source_ids (cognitive 21) REDACTED:7183— utils.merge_source_ids has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 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.
utils_pipeline.extract_content_list_from_payload (cognitive 21) REDACTED:1385— utils_pipeline.extract_content_list_from_payload has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 2, 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.
StatusCard.formatMinerU (cognitive 21) lightrag_webui/src/components/status/StatusCard.tsx:59— StatusCard.formatMinerU has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 4 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AuthHandler.__init__ (cognitive 20) REDACTED:51— AuthHandler.__init__ has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (13 pts), error handling 1 (3 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemgraphStorage.upsert_edge (cognitive 20) lightrag/kg/memgraph_impl.py:616— MemgraphStorage.upsert_edge has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (10 pts), error handling 2 (4 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PostgreSQLDB._migrate_field_lengths (cognitive 20) REDACTED:2294— PostgreSQLDB._migrate_field_lengths has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 3, error handling 2 (3 pts), 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.
zip_budget.enforce_docx_decompression_budget (cognitive 20) lightrag/parser/docx/zip_budget.py:82— zip_budget.enforce_docx_decompression_budget has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 6, error handling 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.
NativeParserBase.parse (cognitive 20) lightrag/parser/native_base.py:226— NativeParserBase.parse has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 6, error handling 1, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
_PipelineMixin._confirm_auto_drained (cognitive 20) lightrag/pipeline.py:3742— _PipelineMixin._confirm_auto_drained has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (17 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.
CleanupTool.delete_query_caches_redis (cognitive 20) lightrag/tools/clean_llm_query_cache.py:530— CleanupTool.delete_query_caches_redis has cognitive complexity 20 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 4 (8 pts), error handling 1 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EmbeddingFunc.__call__ (cognitive 20) REDACTED:775— EmbeddingFunc.__call__ has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 5, 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.
utils._bounded_submit_impl (cognitive 20) REDACTED:3038— utils._bounded_submit_impl has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, loops 1 (2 pts), error handling 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.
utils._scan_dollar_spans (cognitive 20) REDACTED:6216— utils._scan_dollar_spans has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 3, 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.
utils_graph._sanitize_graph_fields (cognitive 20) lightrag/utils_graph.py:58— utils_graph._sanitize_graph_fields has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), error handling 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.
ui_customization._has_svg_root (cognitive 19) lightrag/api/ui_customization.py:428— ui_customization._has_svg_root has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (14 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.
semantic_vector._semantic_groups_with_spans (cognitive 19) lightrag/chunker/semantic_vector.py:389— semantic_vector._semantic_groups_with_spans has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 2, ternaries 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PostgreSQLDB._migrate_timestamp_columns (cognitive 19) REDACTED:1584— PostgreSQLDB._migrate_timestamp_columns has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 2 (4 pts), loops 3 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PGGraphStorage.node_degrees_batch (cognitive 19) REDACTED:8674— PGGraphStorage.node_degrees_batch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 4 (5 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LightRAG.finalize_storages (cognitive 19) lightrag/lightrag.py:2163— LightRAG.finalize_storages has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), error handling 1 (4 pts), loops 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.
LightRAG._flush_storages (cognitive 19) lightrag/lightrag.py:4075— LightRAG._flush_storages has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 2 (4 pts), boolean chains 3, 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.
operate._truncate_section_context (cognitive 19) lightrag/operate.py:249— operate._truncate_section_context has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NumberingResolver._format_label (cognitive 19) lightrag/parser/docx/numbering_resolver.py:563— NumberingResolver._format_label has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), boolean chains 4, error handling 1, loops 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.
parse_document.get_heading_level (cognitive 19) REDACTED:381— parse_document.get_heading_level has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (18 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.
guardrails.numbering_homophone_reason (cognitive 19) lightrag/parser/docx/smart_heading/guardrails.py:291— guardrails.numbering_homophone_reason has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 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.
heading_flow._nesting_evidence (cognitive 19) lightrag/parser/docx/smart_heading/heading_flow.py:2276— heading_flow._nesting_evidence has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 3 (4 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
style_key.classify_numbering (cognitive 19) lightrag/parser/docx/smart_heading/style_key.py:392— style_key.classify_numbering has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 3, error handling 1 (3 pts), loops 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.
MinerURawClient._poll_official_batch (cognitive 19) lightrag/parser/external/mineru/client.py:316— MinerURawClient._poll_official_batch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 3, 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.
CleanupTool.setup_storage (cognitive 19) lightrag/tools/clean_llm_query_cache.py:947— CleanupTool.setup_storage has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 2 (4 pts), ternaries 2, boolean chains 1, 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.
utils.merge_truncation_metadata (cognitive 19) REDACTED:5359— utils.merge_truncation_metadata has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 9, if/else 7, ternaries 1 (2 pts), loops 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.
Step_0.extract_unique_contexts (cognitive 19) reproduce/Step_0.py:7— Step_0.extract_unique_contexts has cognitive complexity 19 (threshold 15). Drivers by points: error handling 4 (9 pts), if/else 2 (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.
lightrag.axiosInstance.interceptors.response.use() (cognitive 19) lightrag_webui/src/api/lightrag.ts:536— lightrag.axiosInstance.interceptors.response.use() has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), error handling 1 (4 pts), boolean chains 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Settings.LabeledNumberInput (cognitive 19) lightrag_webui/src/components/graph/Settings.tsx:56— Settings.LabeledNumberInput has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 7, ternaries 1 (nesting depth added 2). Most of this is not in the body itself: 3 of the 19 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 105, 96, 125, …). 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.
useLightragGraph.createSigmaGraph (cognitive 19) lightrag_webui/src/hooks/useLightragGraph.tsx:248— useLightragGraph.createSigmaGraph has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 5, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ui_customization.normalize_locale (cognitive 18) lightrag/api/ui_customization.py:110— ui_customization.normalize_locale has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 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.
chunk_schema.normalize_chunk_sidecar (cognitive 18) lightrag/chunk_schema.py:201— chunk_schema.normalize_chunk_sidecar has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 6, 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.
paragraph_semantic._split_html_rows_by_tokens (cognitive 18) lightrag/chunker/paragraph_semantic.py:468— paragraph_semantic._split_html_rows_by_tokens has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 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. This shape REPEATS in the file: one other method here (paragraph_semantic._split_rows_by_tokens) 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.
paragraph_semantic._split_rows_by_tokens (cognitive 18) lightrag/chunker/paragraph_semantic.py:582— paragraph_semantic._split_rows_by_tokens has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 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. This shape REPEATS in the file: one other method here (paragraph_semantic._split_html_rows_by_tokens) 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.
FaissVectorDBStorage.delete_entity_relation (cognitive 18) REDACTED:639— FaissVectorDBStorage.delete_entity_relation has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (9 pts), loops 4 (6 pts), boolean chains 3 (nesting depth added 4). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
JsonKVStorage._migrate_legacy_cache_structure (cognitive 18) lightrag/kg/json_kv_impl.py:469— JsonKVStorage._migrate_legacy_cache_structure has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 2 (4 pts), boolean chains 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.
MilvusVectorDBStorage._is_retryable_connection_error (cognitive 18) lightrag/kg/milvus_impl.py:843— MilvusVectorDBStorage._is_retryable_connection_error has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (11 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MilvusVectorDBStorage.__post_init__ (cognitive 18) lightrag/kg/milvus_impl.py:2430— MilvusVectorDBStorage.__post_init__ has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 3 (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.
MilvusVectorDBStorage.get_by_ids (cognitive 18) lightrag/kg/milvus_impl.py:3343— MilvusVectorDBStorage.get_by_ids has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (3 pts), error handling 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.
NetworkXStorage.index_done_callback (cognitive 18) lightrag/kg/networkx_impl.py:1481— NetworkXStorage.index_done_callback has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (15 pts), error handling 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.
OpenSearchDocStatusStorage.get_docs_by_statuses_page (cognitive 18) lightrag/kg/opensearch_impl.py:3000— OpenSearchDocStatusStorage.get_docs_by_statuses_page has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 1, error handling 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.
OpenSearchDocStatusStorage.list_source_conflicts_page (cognitive 18) lightrag/kg/opensearch_impl.py:3409— OpenSearchDocStatusStorage.list_source_conflicts_page has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 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.
OpenSearchGraphStorage._collect_isolated_labels (cognitive 18) lightrag/kg/opensearch_impl.py:6002— OpenSearchGraphStorage._collect_isolated_labels has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 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.
PostgreSQLDB.initdb (cognitive 18) REDACTED:600— PostgreSQLDB.initdb has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 2 (3 pts), loops 2 (3 pts), ternaries 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.
shared_storage._dead_pipeline_reservation_updates (cognitive 18) lightrag/kg/shared_storage.py:2366— shared_storage._dead_pipeline_reservation_updates has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 5, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
shared_storage.aggregate_queue_stats (cognitive 18) lightrag/kg/shared_storage.py:4616— shared_storage.aggregate_queue_stats 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.
operate._get_cached_extraction_results (cognitive 18) lightrag/operate.py:1415— operate._get_cached_extraction_results has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4, 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.
OMMLParser.parse_bar (cognitive 18) REDACTED:231— OMMLParser.parse_bar has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 3 (5 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
heading_flow._demote_confirmed_imprint_regions (cognitive 18) lightrag/parser/docx/smart_heading/heading_flow.py:2855— heading_flow._demote_confirmed_imprint_regions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 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.
ir_builder._rows_from_table_cells (cognitive 18) lightrag/parser/external/docling/ir_builder.py:772— ir_builder._rows_from_table_cells has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 9, loops 3 (6 pts), if/else 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.
MinerUIRBuilder._build_ir_drawing (cognitive 18) lightrag/parser/external/mineru/ir_builder.py:608— MinerUIRBuilder._build_ir_drawing has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 8, if/else 5 (6 pts), ternaries 2 (4 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NativeMarkdownIRBuilder.normalize (cognitive 18) lightrag/parser/markdown/ir_builder.py:64— NativeMarkdownIRBuilder.normalize has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 12, if/else 2 (3 pts), ternaries 1 (2 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.
_PipelineMixin._analyze_worker (cognitive 18) lightrag/pipeline.py:4805— _PipelineMixin._analyze_worker has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), error handling 3 (7 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.
backfill.backfill_chunk_sidecars (cognitive 18) lightrag/sidecar/backfill.py:185— backfill.backfill_chunk_sidecars has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, 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.
table_markup.split_html_rows (cognitive 18) lightrag/table_markup.py:133— table_markup.split_html_rows has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (16 pts), boolean chains 1, loops 1 (nesting depth added 10). 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.
download_cache.download_tiktoken_cache (cognitive 18) lightrag/tools/download_cache.py:110— download_cache.download_tiktoken_cache has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (10 pts), error handling 3 (5 pts), loops 2 (3 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
utils.pick_by_vector_similarity (cognitive 18) REDACTED:6724— utils.pick_by_vector_similarity has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), error handling 2 (4 pts), boolean chains 1, 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, 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.
useQuerySession.useQuerySession.submitQuery::updateAssistantMessage (cognitive 18) lightrag_webui/src/features/retrieval/useQuerySession.ts:333— useQuerySession.useQuerySession.submitQuery::updateAssistantMessage has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 7, 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. This shape REPEATS in the file: one other method here (useQuerySession.useQuerySession.submitQuery) 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.
config.resolve_asymmetric_embedding_opt_in (cognitive 17) REDACTED:96— config.resolve_asymmetric_embedding_opt_in has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 3, 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.
chunk_schema.normalize_chunk_heading (cognitive 17) lightrag/chunk_schema.py:41— chunk_schema.normalize_chunk_heading has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 7, if/else 5 (7 pts), loops 1 (2 pts), error handling 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.
recursive_character._join_span_pieces (cognitive 17) lightrag/chunker/recursive_character.py:138— recursive_character._join_span_pieces has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 5 (6 pts), boolean chains 3 (nesting depth added 5). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
JsonDocStatusStorage.get_docs_paginated (cognitive 17) lightrag/kg/json_doc_status_impl.py:428— JsonDocStatusStorage.get_docs_paginated has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, loops 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
JsonDocStatusStorage.list_source_conflicts_page (cognitive 17) lightrag/kg/json_doc_status_impl.py:1090— JsonDocStatusStorage.list_source_conflicts_page has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 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, 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.
MilvusVectorDBStorage._flush_pending_vector_ops (cognitive 17) lightrag/kg/milvus_impl.py:2893— MilvusVectorDBStorage._flush_pending_vector_ops has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), error handling 1 (2 pts), loops 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.
MongoGraphStorage.get_knowledge_graph_all_by_degree (cognitive 17) lightrag/kg/mongo_impl.py:3116— MongoGraphStorage.get_knowledge_graph_all_by_degree has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 4 (8 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OpenSearchDocStatusStorage.get_full_docs_by_ids (cognitive 17) lightrag/kg/opensearch_impl.py:3239— OpenSearchDocStatusStorage.get_full_docs_by_ids has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 2 (3 pts), ternaries 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.
OpenSearchDocStatusStorage._primary_candidate_ids_sorted (cognitive 17) lightrag/kg/opensearch_impl.py:3357— OpenSearchDocStatusStorage._primary_candidate_ids_sorted has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (12 pts), 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.
PGDocStatusStorage.get_docs_paginated (cognitive 17) REDACTED:6794— PGDocStatusStorage.get_docs_paginated has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (11 pts), error handling 1 (3 pts), ternaries 2, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
RedisDocStatusStorage.get_docs_by_ids (cognitive 17) lightrag/kg/redis_impl.py:2245— RedisDocStatusStorage.get_docs_by_ids has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), error handling 1 (2 pts), loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LightRAG._apply_chunk_size_overlay (cognitive 17) lightrag/lightrag.py:1430— LightRAG._apply_chunk_size_overlay has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (15 pts), 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.
multimodal_context.load_content_rows_by_blockid (cognitive 17) lightrag/multimodal_context.py:769— multimodal_context.load_content_rows_by_blockid has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), error handling 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
operate._build_context_str (cognitive 17) lightrag/operate.py:5873— operate._build_context_str has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 4, loops 1 (2 pts), 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.
NativeDocxIRBuilder.normalize (cognitive 17) lightrag/parser/docx/ir_builder.py:250— NativeDocxIRBuilder.normalize has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 11, if/else 3 (4 pts), loops 1, 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.
NumberingResolver._get_numbering_from_style (cognitive 17) lightrag/parser/docx/numbering_resolver.py:322— NumberingResolver._get_numbering_from_style has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 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.
guardrails.detect_toc_records (cognitive 17) lightrag/parser/docx/smart_heading/guardrails.py:727— guardrails.detect_toc_records has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (12 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.
ir_builder._build_ir_table (cognitive 17) lightrag/parser/external/docling/ir_builder.py:688— ir_builder._build_ir_table has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 5 (7 pts), boolean chains 6, if/else 4 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
extractors._extract_docx (cognitive 17) lightrag/parser/legacy/extractors.py:41— extractors._extract_docx has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 2 (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.
SyncLLMBridge.__call__ (cognitive 17) lightrag/parser/llm_bridge.py:71— SyncLLMBridge.__call__ has cognitive complexity 17 (threshold 15). Drivers by points: error handling 3 (8 pts), if/else 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.
NativeImageRawCache.flush (cognitive 17) lightrag/parser/markdown/raw_cache.py:173— NativeImageRawCache.flush has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 2 (5 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
download_cache.download_spacy_models (cognitive 17) lightrag/tools/download_cache.py:32— download_cache.download_spacy_models has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (7 pts), loops 2 (3 pts), ternaries 1 (3 pts), boolean chains 2, error handling 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.
utils.pick_by_weighted_polling (cognitive 17) REDACTED:6642— utils.pick_by_weighted_polling has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 4 (5 pts), ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GraphViewer.GraphViewer (cognitive 17) lightrag_webui/src/features/GraphViewer.tsx:145— GraphViewer.GraphViewer has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 8, if/else 6, error handling 1 (2 pts), ternaries 1 (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 5 function literals inside it that branch (lines 213, 190, 234, …). 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.
QueryRequest.conversation_history_role_check (cognitive 16) lightrag/api/routers/query_routes.py:189— QueryRequest.conversation_history_role_check has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 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.
paragraph_semantic._inject_header_into_table_slice (cognitive 16) lightrag/chunker/paragraph_semantic.py:400— paragraph_semantic._inject_header_into_table_slice has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 3, error handling 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.
RAGEvaluator.generate_rag_response (cognitive 16) lightrag/evaluation/eval_rag_quality.py:301— RAGEvaluator.generate_rag_response has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 4, 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.
MongoGraphStorage._bidirectional_bfs_nodes (cognitive 16) lightrag/kg/mongo_impl.py:3214— MongoGraphStorage._bidirectional_bfs_nodes has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 3, boolean chains 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MongoVectorDBStorage.get_by_ids (cognitive 16) lightrag/kg/mongo_impl.py:4983— MongoVectorDBStorage.get_by_ids has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (3 pts), error handling 1 (2 pts), boolean chains 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.
Neo4JStorage.get_node_edges (cognitive 16) lightrag/kg/neo4j_impl.py:924— Neo4JStorage.get_node_edges has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (6 pts), ternaries 3 (5 pts), boolean chains 2, error handling 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.
PGDocStatusStorage.get_docs_by_statuses_page (cognitive 16) REDACTED:6196— PGDocStatusStorage.get_docs_by_statuses_page has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 2, loops 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
QdrantVectorDBStorage.delete_entity_relation (cognitive 16) lightrag/kg/qdrant_impl.py:1036— QdrantVectorDBStorage.delete_entity_relation 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). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RedisDocStatusStorage.delete (cognitive 16) lightrag/kg/redis_impl.py:1632— RedisDocStatusStorage.delete has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), 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.
shared_storage.acquire_enqueue_reservation (cognitive 16) lightrag/kg/shared_storage.py:2864— shared_storage.acquire_enqueue_reservation has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 3, 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.
gemini._get_gemini_client (cognitive 16) lightrag/llm/gemini.py:106— gemini._get_gemini_client has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), error handling 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.
multimodal_context._split_text_segment (cognitive 16) lightrag/multimodal_context.py:191— multimodal_context._split_text_segment has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OMMLParser.parse_f (cognitive 16) REDACTED:400— OMMLParser.parse_f has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_MarkdownImageResolver._resolve_remote (cognitive 16) lightrag/parser/markdown/parser.py:1361— _MarkdownImageResolver._resolve_remote has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), error handling 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.
routing.normalize_chunker_r_separators (cognitive 16) lightrag/parser/routing.py:422— routing.normalize_chunker_r_separators has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 3 (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.
routing._filename_hint_match (cognitive 16) lightrag/parser/routing.py:858— routing._filename_hint_match has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 5 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
_PipelineMixin._run_pipeline_batch (cognitive 16) lightrag/pipeline.py:2619— _PipelineMixin._run_pipeline_batch has cognitive complexity 16 (threshold 15). Drivers by points: loops 6 (7 pts), if/else 3, boolean chains 2, error handling 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
writer._materialize_assets (cognitive 16) REDACTED:397— writer._materialize_assets has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 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.
RebuildTool.setup_storages (cognitive 16) lightrag/tools/rebuild_vdb.py:731— RebuildTool.setup_storages has cognitive complexity 16 (threshold 15). Drivers by points: loops 5 (7 pts), if/else 3 (5 pts), error handling 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.
utils.generate_reference_list_from_chunks (cognitive 16) REDACTED:7735— utils.generate_reference_list_from_chunks has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 5, boolean chains 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.
utils_graph.amerge_entities (cognitive 16) lightrag/utils_graph.py:3440— utils_graph.amerge_entities has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 2, error handling 1, loops 1, ternaries 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
lightrag.axiosInstance.interceptors.response.use() (cognitive 16) lightrag_webui/src/api/lightrag.ts:492— lightrag.axiosInstance.interceptors.response.use() has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 2 (5 pts), error handling 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.
FocusOnNode.FocusOnNode (cognitive 16) lightrag_webui/src/components/graph/FocusOnNode.tsx:8— FocusOnNode.FocusOnNode has cognitive complexity 16 (threshold 15). Drivers by points: error handling 3 (7 pts), if/else 5 (6 pts), boolean chains 3 (nesting depth added 5). None of this is in the body itself: all 16 points belong to 2 function literals inside it that branch (lines 15, 40). 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.
splitSettingsStorage.writeShrunkLegacyEnvelope (cognitive 16) lightrag_webui/src/migrations/splitSettingsStorage.ts:381— splitSettingsStorage.writeShrunkLegacyEnvelope has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), error handling 3 (5 pts), boolean chains 2, 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.
ClassTooLong: DocumentManager lightrag_webui/src/features/DocumentManager.tsx:1— ClassTooLong — 904 significant lines (blank, comment-only and punctuation-only lines excluded), 9 methods. The bar is 400 significant lines; this is 504 over it, 2.26× 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.
D30 · Dependency Vulnerabilities· Medium vulnerability · ×1
Change coupling: AppSettings.tsx ↔ i18n.ts lightrag_webui/src/components/AppSettings.tsx:1— `lightrag_webui/src/components/AppSettings.tsx` and `lightrag_webui/src/i18n.ts` change together 58% of the time (7 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `96e74c44` feat(webui): add Indonesian localization; `3733f42e` fix(webui): five workspace interaction-contract fixes; `1bd3465d` Add Vietnamese language support and update language options — run `git show` on any of them.
Near-duplicate member pair (136 shared lines) lightrag/operate.py:2444— lightrag/operate.py:2444-2779 | lightrag/operate.py:2801-3474 — These two members are variants of one another: 136 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 (115 shared lines) lightrag/operate.py:6360— lightrag/operate.py:6360-6526 | lightrag/operate.py:6631-6823 — These two members are variants of one another: 115 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 (99 shared lines) lightrag/kg/memgraph_impl.py:1057— lightrag/kg/memgraph_impl.py:1057-1231 | lightrag/kg/neo4j_impl.py:1307-1529 — These two members are variants of one another: 99 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 (92 shared lines) REDACTED:3293— REDACTED:3293-3434 | REDACTED:3448-3617 — These two members are variants of one another: 92 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 (81 shared lines) lightrag/parser/external/docling/ir_builder.py:128— lightrag/parser/external/docling/ir_builder.py:128-497 | lightrag/parser/external/mineru/ir_builder.py:189-500 — These two members are variants of one another: 81 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (43 shared lines) lightrag/tools/migrate_llm_cache.py:342— lightrag/tools/migrate_llm_cache.py:342-417 | lightrag/tools/migrate_llm_cache.py:737-808 — These two members are variants of one another: 43 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 (34 corresponding lines) · ×1
Edited copy of a member (34 corresponding lines) REDACTED:5895— REDACTED:5895-5964 | REDACTED:5969-6042 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (35 corresponding lines) · ×1
Edited copy of a member (35 corresponding lines) REDACTED:640— REDACTED:640-732 | REDACTED:1038-1125 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (29 corresponding lines) · ×1
Edited copy of a member (29 corresponding lines) lightrag/kg/opensearch_impl.py:5455— lightrag/kg/opensearch_impl.py:5455-5556 | lightrag/kg/opensearch_impl.py:6063-6119 — These two members are one piece of code written twice and then edited apart: 29 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 (12 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (12 members, 50+ identical tokens) REDACTED:908— REDACTED:908-1168 | lightrag/kg/milvus_impl.py:2894-3066 | lightrag/kg/milvus_impl.py:3392-3472 | lightrag/kg/mongo_impl.py:4719-4866 | lightrag/kg/mongo_impl.py:5027-5108 | REDACTED:532-725 | lightrag/kg/opensearch_impl.py:6686-6887 | lightrag/kg/opensearch_impl.py:7126-7206 | REDACTED:4782-5044 | REDACTED:5393-5510 | lightrag/kg/qdrant_impl.py:849-1010 | lightrag/kg/qdrant_impl.py:1249-1350 — These 12 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 12 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 12 times.
D4 · Code Duplication· Members sharing a duplicated core (8 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (8 members, 50+ identical tokens) lightrag/kg/milvus_impl.py:2431— lightrag/kg/milvus_impl.py:2431-2609 | lightrag/kg/mongo_impl.py:421-459 | lightrag/kg/mongo_impl.py:701-733 | lightrag/kg/mongo_impl.py:1777-1821 | lightrag/kg/mongo_impl.py:4238-4307 | lightrag/kg/qdrant_impl.py:518-618 | lightrag/kg/redis_impl.py:394-448 | lightrag/kg/redis_impl.py:1010-1066 — These 8 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 8 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 8 times.
D4 · Code Duplication· Members sharing a duplicated core (7 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (7 members, 50+ identical tokens) lightrag/kg/redis_impl.py:1217— lightrag/kg/redis_impl.py:1217-1250 | lightrag/kg/redis_impl.py:1279-1341 | lightrag/kg/redis_impl.py:1346-1401 | lightrag/kg/redis_impl.py:1689-1806 | lightrag/kg/redis_impl.py:1823-1866 | lightrag/kg/redis_impl.py:1975-2049 | lightrag/kg/redis_impl.py:2615-2701 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
Duplicated block (110–132 lines × 2) lightrag/api/routers/ollama_api.py:480— lightrag/api/routers/ollama_api.py:480-589 | lightrag/api/routers/ollama_api.py:720-851 — both copies are in the same file, so extract the 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 `lightrag/api/routers/ollama_api.py:480` 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 (88 lines × 2) lightrag/kg/json_doc_status_impl.py:279— lightrag/kg/json_doc_status_impl.py:279-366 | lightrag/kg/json_kv_impl.py:176-263 — before extracting anything, compare `lightrag/kg/json_doc_status_impl.py` and `lightrag/kg/json_kv_impl.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 200 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/json_doc_status_impl.py:279` 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 (54–59 lines × 2) REDACTED:423— REDACTED:423-481 | REDACTED:456-509 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (40–56 lines × 2) REDACTED:2032— REDACTED:2032-2087 | REDACTED:2253-2292 — both copies are in the same file, so extract the 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 (54 lines × 2) REDACTED:3907— REDACTED:3907-3960 | REDACTED:7047-7100 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (52–53 lines × 2) REDACTED:1919— REDACTED:1919-1971 | REDACTED:1976-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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1919` 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 (46–50 lines × 2) REDACTED:2372— REDACTED:2372-2417 | REDACTED:2530-2579 — both copies are in the same file, so extract the 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 (46–49 lines × 2) REDACTED:329— REDACTED:329-377 | REDACTED:357-402 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:329` 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 (45–49 lines × 2) lightrag/operate.py:4907— lightrag/operate.py:4907-4955 | lightrag/operate.py:7066-7110 — both copies are in the same file, so extract the 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 `lightrag/operate.py:4907` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/operate.py:4906` calls `progress_callback` and `lightrag/operate.py:7065` 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 (39–46 lines × 4) lightrag/kg/memgraph_impl.py:569— lightrag/kg/memgraph_impl.py:569-614 | lightrag/kg/memgraph_impl.py:671-716 | lightrag/kg/memgraph_impl.py:757-795 | lightrag/kg/memgraph_impl.py:874-912 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (46 lines × 2) lightrag/lightrag.py:6405— lightrag/lightrag.py:6405-6450 | lightrag/lightrag.py:6475-6520 — both copies are in the same file, so extract the 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 (26–45 lines × 3) lightrag/kg/milvus_impl.py:3079— lightrag/kg/milvus_impl.py:3079-3123 | lightrag/kg/mongo_impl.py:4893-4918 | lightrag/kg/opensearch_impl.py:7236-7269 — 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 (40–45 lines × 2) lightrag/kg/milvus_impl.py:3475— lightrag/kg/milvus_impl.py:3475-3519 | lightrag/kg/qdrant_impl.py:1353-1392 — 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 `lightrag/kg/milvus_impl.py:3475` 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 (28–45 lines × 2) lightrag/kg/opensearch_impl.py:5465— lightrag/kg/opensearch_impl.py:5465-5509 | lightrag/kg/opensearch_impl.py:6075-6102 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:6075` 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 (34–44 lines × 3) lightrag/kg/milvus_impl.py:3392— lightrag/kg/milvus_impl.py:3392-3425 | lightrag/kg/mongo_impl.py:5027-5070 | lightrag/kg/qdrant_impl.py:1249-1292 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/milvus_impl.py:3392` 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 (39–40 lines × 2) lightrag/kg/memgraph_impl.py:1099— lightrag/kg/memgraph_impl.py:1099-1137 | lightrag/kg/neo4j_impl.py:1352-1391 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/memgraph_impl.py:1099` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (38–40 lines × 2) lightrag/kg/mongo_impl.py:2107— lightrag/kg/mongo_impl.py:2107-2146 | lightrag/kg/opensearch_impl.py:695-732 — 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 (35–40 lines × 2) lightrag/operate.py:6404— lightrag/operate.py:6404-6443 | lightrag/operate.py:6702-6736 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (35–39 lines × 2) lightrag/api/routers/ollama_api.py:608— lightrag/api/routers/ollama_api.py:608-642 | lightrag/api/routers/ollama_api.py:890-928 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/api/routers/ollama_api.py:608` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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 (39 lines × 2) lightrag/kg/memgraph_impl.py:1186— lightrag/kg/memgraph_impl.py:1186-1224 | lightrag/kg/neo4j_impl.py:1477-1515 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/memgraph_impl.py:1186` 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 (33–38 lines × 2) lightrag/lightrag.py:3100— lightrag/lightrag.py:3100-3137 | lightrag/lightrag.py:7437-7469 — both copies are in the same file, so extract the block into 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–38 lines × 2) REDACTED:7467— REDACTED:7467-7500 | REDACTED:7516-7553 — both copies are in the same file, so extract the 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:7467` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (32–37 lines × 3) lightrag/parser/docx/utils.py:545— lightrag/parser/docx/utils.py:545-576 | lightrag/parser/docx/utils.py:621-652 | lightrag/parser/docx/utils.py:712-748 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (34–36 lines × 2) REDACTED:3300— REDACTED:3300-3335 | REDACTED:3479-3512 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (31–35 lines × 2) REDACTED:2015— REDACTED:2015-2049 | REDACTED:1581-1611 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:2015` 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 (33–35 lines × 2) lightrag/kg/json_doc_status_impl.py:1203— lightrag/kg/json_doc_status_impl.py:1203-1235 | lightrag/kg/json_kv_impl.py:431-465 — before extracting anything, compare `lightrag/kg/json_doc_status_impl.py` and `lightrag/kg/json_kv_impl.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 200 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (32–35 lines × 2) lightrag/parser/external/docling/ir_builder.py:177— lightrag/parser/external/docling/ir_builder.py:177-208 | lightrag/parser/external/mineru/ir_builder.py:256-290 — 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 `lightrag/parser/external/docling/ir_builder.py:177` 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 (32–34 lines × 2) REDACTED:3823— REDACTED:3823-3856 | REDACTED:7207-7238 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:7239` calls `transaction` and `REDACTED:3857` 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 (33–34 lines × 2) REDACTED:5743— REDACTED:5743-5775 | REDACTED:5850-5883 — both copies are in the same file, so extract the 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:5743` 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 (29–34 lines × 2) lightrag/llm/jina.py:23— lightrag/llm/jina.py:23-56 | lightrag/rerank.py:348-376 — 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 (30–34 lines × 2) REDACTED:1607— REDACTED:1607-1640 | REDACTED:1861-1890 — both copies are in the same file, so extract the 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:1607` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:1892` calls `set` and `REDACTED:1642` 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 (32–33 lines × 2) lightrag/kg/memgraph_impl.py:244— lightrag/kg/memgraph_impl.py:244-275 | lightrag/kg/neo4j_impl.py:581-613 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/memgraph_impl.py:243` calls `_get_workspace_label` and `lightrag/kg/neo4j_impl.py:580` 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 (24–33 lines × 2) lightrag/kg/pgtable_impl.py:1556— lightrag/kg/pgtable_impl.py:1556-1579 | lightrag/kg/pgtable_impl.py:1616-1648 — both copies are in the same file, so extract the 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 `lightrag/kg/pgtable_impl.py:1556` 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–32 lines × 2) lightrag/kg/opensearch_impl.py:1082— lightrag/kg/opensearch_impl.py:1082-1113 | lightrag/kg/opensearch_impl.py:2063-2078 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:2063` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24–32 lines × 2) lightrag/parser/external/docling/ir_builder.py:132— lightrag/parser/external/docling/ir_builder.py:132-155 | lightrag/parser/external/mineru/ir_builder.py:191-222 — 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, `lightrag/parser/external/docling/ir_builder.py:129` calls `_build_ref_index`, `_precompute_consumed_refs` and `lightrag/parser/external/mineru/ir_builder.py:189` 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 (31–32 lines × 2) lightrag/tools/clean_llm_query_cache.py:464— lightrag/tools/clean_llm_query_cache.py:464-495 | lightrag/tools/clean_llm_query_cache.py:712-742 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (29–31 lines × 2) lightrag/kg/memgraph_impl.py:1304— lightrag/kg/memgraph_impl.py:1304-1334 | lightrag/kg/neo4j_impl.py:1921-1949 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/memgraph_impl.py:1304` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24–30 lines × 2) lightrag/kg/json_doc_status_impl.py:126— lightrag/kg/json_doc_status_impl.py:126-149 | lightrag/kg/json_kv_impl.py:91-120 — before extracting anything, compare `lightrag/kg/json_doc_status_impl.py` and `lightrag/kg/json_kv_impl.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 200 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (29–30 lines × 2) lightrag/operate.py:6469— lightrag/operate.py:6469-6498 | lightrag/operate.py:6763-6791 — both copies are in the same file, so extract the 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 `lightrag/operate.py:6469` 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, `lightrag/operate.py:6793` calls `debug` and `lightrag/operate.py:6500` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (28–30 lines × 2) lightrag/tools/clean_llm_query_cache.py:1022— lightrag/tools/clean_llm_query_cache.py:1022-1051 | lightrag/tools/migrate_llm_cache.py:1133-1160 — 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. 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 (25–29 lines × 2) lightrag/kg/milvus_impl.py:1233— lightrag/kg/milvus_impl.py:1233-1261 | lightrag/kg/milvus_impl.py:1269-1293 — both copies are in the same file, so extract the 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 `lightrag/kg/milvus_impl.py:1233` 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–29 lines × 2) REDACTED:8597— REDACTED:8597-8623 | REDACTED:8677-8705 — both copies are in the same file, so extract the 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 `batch_size` to `int = 1000` in one and `int = 500` 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 (26–28 lines × 4) REDACTED:1860— REDACTED:1860-1885 | REDACTED:1891-1916 | REDACTED:1946-1973 | REDACTED:2003-2029 — 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 (26–28 lines × 2) lightrag/parser/external/_base.py:163— lightrag/parser/external/_base.py:163-188 | lightrag/parser/native_base.py:475-502 — 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 `lightrag/parser/external/_base.py:163` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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–27 lines × 3) lightrag/kg/mongo_impl.py:3770— lightrag/kg/mongo_impl.py:3770-3792 | lightrag/kg/mongo_impl.py:3797-3823 | lightrag/kg/mongo_impl.py:3866-3877 — 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 `lightrag/kg/mongo_impl.py:3866` 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 (24–27 lines × 2) lightrag/kg/memgraph_impl.py:300— lightrag/kg/memgraph_impl.py:300-323 | lightrag/kg/neo4j_impl.py:673-699 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/memgraph_impl.py:299` calls `_get_workspace_label` and `lightrag/kg/neo4j_impl.py:672` 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 (27 lines × 2) REDACTED:5169— REDACTED:5169-5195 | REDACTED:5247-5273 — both copies are in the same file, so extract the 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:5167` calls `discard` and `REDACTED:5245` 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 (26 lines × 3) lightrag/kg/json_doc_status_impl.py:1158— lightrag/kg/json_doc_status_impl.py:1158-1183 | lightrag/kg/opensearch_impl.py:3536-3561 | lightrag/kg/redis_impl.py:2464-2489 — 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 (26 lines × 2) REDACTED:1673— REDACTED:1673-1698 | REDACTED:1278-1303 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13–26 lines × 2) lightrag/kg/opensearch_impl.py:2783— lightrag/kg/opensearch_impl.py:2783-2795 | lightrag/kg/opensearch_impl.py:3446-3471 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:2783` 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 (22–26 lines × 2) lightrag/kg/opensearch_impl.py:5219— lightrag/kg/opensearch_impl.py:5219-5244 | lightrag/kg/opensearch_impl.py:6026-6047 — both copies are in the same file, so extract the 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 (25–26 lines × 2) REDACTED:533— REDACTED:533-557 | lightrag/parser/docx/table_extractor.py:132-157 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:533` 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 (24–25 lines × 2) lightrag/kg/milvus_impl.py:2988— lightrag/kg/milvus_impl.py:2988-3011 | lightrag/kg/mongo_impl.py:4806-4830 — 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 `lightrag/kg/milvus_impl.py:2988` 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–25 lines × 2) lightrag/tools/clean_llm_query_cache.py:504— lightrag/tools/clean_llm_query_cache.py:504-528 | lightrag/tools/clean_llm_query_cache.py:744-763 — both copies are in the same file, so extract the 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 `lightrag/tools/clean_llm_query_cache.py:504` 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–24 lines × 2) lightrag/operate.py:1220— lightrag/operate.py:1220-1243 | lightrag/operate.py:1247-1266 — both copies are in the same file, so extract the 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 `lightrag/operate.py:1220` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (23 lines × 2) lightrag/kg/shared_storage.py:1241— lightrag/kg/shared_storage.py:1241-1263 | lightrag/kg/shared_storage.py:1320-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. 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–23 lines × 2) lightrag/storage_migrations.py:255— lightrag/storage_migrations.py:255-277 | lightrag/storage_migrations.py:312-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. 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 (21–22 lines × 4) lightrag/kg/mongo_impl.py:430— lightrag/kg/mongo_impl.py:430-451 | lightrag/kg/mongo_impl.py:710-730 | lightrag/kg/mongo_impl.py:1792-1812 | lightrag/kg/mongo_impl.py:4249-4269 — 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 `lightrag/kg/mongo_impl.py:430` 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 (15–22 lines × 2) REDACTED:558— REDACTED:558-579 | REDACTED:589-603 — both copies are in the same file, so extract the 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:558` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:582` calls `add_args` and `REDACTED:605` 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 (21–22 lines × 2) lightrag/kg/opensearch_impl.py:5095— lightrag/kg/opensearch_impl.py:5095-5116 | lightrag/kg/opensearch_impl.py:5858-5878 — both copies are in the same file, so extract the 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) REDACTED:3620— REDACTED:3620-3639 | REDACTED:5719-5740 — both copies are in the same file, so extract the 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–22 lines × 2) lightrag/kg/redis_impl.py:1293— lightrag/kg/redis_impl.py:1293-1311 | lightrag/kg/redis_impl.py:1347-1368 — both copies are in the same file, so extract the 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 × 4) lightrag/kg/json_doc_status_impl.py:784— lightrag/kg/json_doc_status_impl.py:784-804 | lightrag/kg/mongo_impl.py:1334-1353 | lightrag/kg/opensearch_impl.py:2979-2998 | lightrag/kg/redis_impl.py:2083-2102 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/json_doc_status_impl.py:784` 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–21 lines × 4) lightrag/kg/milvus_impl.py:2852— lightrag/kg/milvus_impl.py:2852-2872 | lightrag/kg/mongo_impl.py:243-258 | REDACTED:268-283 | lightrag/kg/qdrant_impl.py:688-705 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/milvus_impl.py:2852` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (19–21 lines × 2) REDACTED:4667— REDACTED:4667-4685 | REDACTED:4696-4716 — both copies are in the same file, so extract the 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:4667` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18–21 lines × 2) lightrag/lightrag.py:6997— lightrag/lightrag.py:6997-7014 | lightrag/lightrag.py:7175-7195 — both copies are in the same file, so extract the block into 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–21 lines × 2) lightrag/multimodal_context.py:300— lightrag/multimodal_context.py:300-320 | lightrag/multimodal_context.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 `lightrag/multimodal_context.py:300` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–20 lines × 6) REDACTED:1087— REDACTED:1087-1103 | lightrag/kg/milvus_impl.py:2927-2943 | lightrag/kg/mongo_impl.py:4752-4768 | REDACTED:670-686 | lightrag/kg/opensearch_impl.py:6745-6764 | lightrag/kg/qdrant_impl.py:883-899 — 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 6 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1087` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19–20 lines × 4) lightrag/kg/opensearch_impl.py:4417— lightrag/kg/opensearch_impl.py:4417-4436 | lightrag/kg/opensearch_impl.py:4625-4644 | lightrag/kg/opensearch_impl.py:5910-5928 | lightrag/kg/opensearch_impl.py:5959-5977 — 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 (18–20 lines × 2) REDACTED:1733— REDACTED:1733-1750 | REDACTED:1334-1353 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 389 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (4–20 lines × 3) lightrag/kg/milvus_impl.py:2952— lightrag/kg/milvus_impl.py:2952-2971 | lightrag/kg/mongo_impl.py:4777-4789 | lightrag/kg/qdrant_impl.py:908-911 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/milvus_impl.py:2952` 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 (17–20 lines × 2) lightrag/kg/opensearch_impl.py:4421— lightrag/kg/opensearch_impl.py:4421-4440 | lightrag/kg/opensearch_impl.py:5105-5121 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:4421` 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 (13–19 lines × 2) lightrag/parser/external/docling/ir_builder.py:356— lightrag/parser/external/docling/ir_builder.py:356-368 | lightrag/parser/external/mineru/ir_builder.py:321-339 — 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, `lightrag/parser/external/docling/ir_builder.py:369` calls `_visit_children` and `lightrag/parser/external/mineru/ir_builder.py:340` 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–19 lines × 2) lightrag/tools/migrate_llm_cache.py:356— lightrag/tools/migrate_llm_cache.py:356-374 | lightrag/tools/migrate_llm_cache.py:748-763 — both copies are in the same file, so extract the 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 first that the copies are not typed on the same thing: the declarations holding them bind `batch_size` to `int = 1000` in one and `int` 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 (15–18 lines × 10) lightrag/kg/milvus_impl.py:2935— lightrag/kg/milvus_impl.py:2935-2950 | lightrag/kg/milvus_impl.py:3425-3439 | lightrag/kg/mongo_impl.py:4760-4775 | lightrag/kg/mongo_impl.py:5070-5084 | REDACTED:678-694 | lightrag/kg/opensearch_impl.py:6756-6773 | lightrag/kg/opensearch_impl.py:7162-7177 | REDACTED:5440-5454 | lightrag/kg/qdrant_impl.py:891-906 | lightrag/kg/qdrant_impl.py:1292-1306 — there are 10 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 10 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/milvus_impl.py:2935` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 6) lightrag/kg/opensearch_impl.py:2488— lightrag/kg/opensearch_impl.py:2488-2505 | lightrag/kg/opensearch_impl.py:4419-4439 | lightrag/kg/opensearch_impl.py:4627-4647 | lightrag/kg/opensearch_impl.py:5103-5121 | lightrag/kg/opensearch_impl.py:5866-5883 | lightrag/kg/opensearch_impl.py:5912-5931 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/opensearch_impl.py:2488` 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 (18 lines × 4) lightrag/pipeline.py:1935— lightrag/pipeline.py:1935-1952 | lightrag/pipeline.py:2015-2032 | lightrag/pipeline.py:2066-2083 | lightrag/pipeline.py:2140-2157 — 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 (17–18 lines × 3) lightrag/kg/opensearch_impl.py:5101— lightrag/kg/opensearch_impl.py:5101-5118 | lightrag/kg/opensearch_impl.py:5147-5164 | lightrag/kg/opensearch_impl.py:5864-5880 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (16–18 lines × 2) lightrag/kg/memgraph_impl.py:1366— lightrag/kg/memgraph_impl.py:1366-1383 | lightrag/kg/neo4j_impl.py:1976-1991 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (17 lines × 9) lightrag/kg/opensearch_impl.py:1195— lightrag/kg/opensearch_impl.py:1195-1212 | lightrag/kg/opensearch_impl.py:2488-2504 | lightrag/kg/opensearch_impl.py:4419-4438 | lightrag/kg/opensearch_impl.py:4627-4646 | lightrag/kg/opensearch_impl.py:5103-5120 | lightrag/kg/opensearch_impl.py:5149-5166 | lightrag/kg/opensearch_impl.py:5866-5882 | lightrag/kg/opensearch_impl.py:5912-5930 | lightrag/kg/opensearch_impl.py:5961-5979 — all 9 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 `lightrag/kg/opensearch_impl.py:1195` 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 first that the copies are not typed on the same thing: the declarations holding them bind `batch_size` to `int = 1000` in one and `int` 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/opensearch_impl.py:5146` calls `_refresh_graph_indices_if_dirty` and `lightrag/kg/opensearch_impl.py:1192` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12–17 lines × 5) lightrag/kg/milvus_impl.py:3185— lightrag/kg/milvus_impl.py:3185-3196 | lightrag/kg/mongo_impl.py:4869-4880 | lightrag/kg/opensearch_impl.py:7209-7225 | REDACTED:5103-5119 | lightrag/kg/qdrant_impl.py:1013-1024 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. 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 `ids` to `list[str]` in one and `List[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 (17 lines × 4) REDACTED:3734— REDACTED:3734-3750 | REDACTED:3752-3768 | REDACTED:3770-3786 | REDACTED:3788-3804 — 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 (14–17 lines × 2) lightrag/api/routers/query_routes.py:625— lightrag/api/routers/query_routes.py:625-641 | lightrag/api/routers/query_routes.py:687-700 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15–17 lines × 2) lightrag/multimodal_context.py:537— lightrag/multimodal_context.py:537-553 | lightrag/multimodal_context.py:654-668 — both copies are in the same file, so extract the 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 × 6) lightrag/kg/mongo_impl.py:427— lightrag/kg/mongo_impl.py:427-442 | lightrag/kg/mongo_impl.py:707-722 | lightrag/kg/mongo_impl.py:1789-1804 | lightrag/kg/mongo_impl.py:4246-4261 | lightrag/kg/redis_impl.py:400-415 | lightrag/kg/redis_impl.py:1016-1031 — there are 6 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/mongo_impl.py:4239` calls `_validate_embedding_func` and `lightrag/kg/mongo_impl.py:421` 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–16 lines × 2) lightrag/kg/memgraph_impl.py:365— lightrag/kg/memgraph_impl.py:365-377 | lightrag/kg/memgraph_impl.py:1300-1315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/memgraph_impl.py:365` 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 (14–16 lines × 2) lightrag/operate.py:4889— lightrag/operate.py:4889-4904 | lightrag/operate.py:7052-7065 — both copies are in the same file, so extract the 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 `lightrag/operate.py:4889` 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, `lightrag/operate.py:4906` calls `progress_callback` and `lightrag/operate.py:7066` 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 (14–15 lines × 4) lightrag/kg/milvus_impl.py:3509— lightrag/kg/milvus_impl.py:3509-3523 | lightrag/kg/mongo_impl.py:4438-4452 | REDACTED:4616-4629 | lightrag/kg/qdrant_impl.py:1382-1396 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
Duplicated block (13–15 lines × 3) REDACTED:5802— REDACTED:5802-5816 | REDACTED:5935-5947 | REDACTED:6013-6025 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12–15 lines × 2) lightrag/parser/external/_manifest.py:124— lightrag/parser/external/_manifest.py:124-138 | lightrag/parser/external/mineru/manifest.py:121-132 — before extracting anything, compare `lightrag/parser/external/_manifest.py` and `lightrag/parser/external/mineru/manifest.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. 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 × 8) lightrag/kg/milvus_impl.py:2472— lightrag/kg/milvus_impl.py:2472-2485 | lightrag/kg/mongo_impl.py:424-437 | lightrag/kg/mongo_impl.py:704-717 | lightrag/kg/mongo_impl.py:1786-1799 | lightrag/kg/mongo_impl.py:4243-4256 | lightrag/kg/qdrant_impl.py:522-535 | lightrag/kg/redis_impl.py:397-410 | lightrag/kg/redis_impl.py:1013-1026 — there are 8 copies across 4 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 8 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/mongo_impl.py:418` calls `__post_init__` and `lightrag/kg/mongo_impl.py:1782` 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–14 lines × 4) REDACTED:5800— REDACTED:5800-5813 | REDACTED:5933-5945 | REDACTED:6011-6023 | REDACTED:6693-6705 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12–14 lines × 3) lightrag/kg/milvus_impl.py:3031— lightrag/kg/milvus_impl.py:3031-3044 | lightrag/kg/mongo_impl.py:4853-4866 | lightrag/kg/qdrant_impl.py:999-1010 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/milvus_impl.py:3031` 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–14 lines × 2) lightrag/kg/milvus_impl.py:3349— lightrag/kg/milvus_impl.py:3349-3361 | lightrag/kg/opensearch_impl.py:7082-7095 — 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–14 lines × 2) lightrag/lightrag.py:6593— lightrag/lightrag.py:6593-6606 | lightrag/lightrag.py:6659-6670 — both copies are in the same file, so extract the 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 `lightrag/lightrag.py:6593` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/lightrag.py:6657` calls `list` and `lightrag/lightrag.py:6592` 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 × 12) REDACTED:1093— REDACTED:1093-1105 | lightrag/kg/milvus_impl.py:2933-2945 | lightrag/kg/milvus_impl.py:3423-3435 | lightrag/kg/mongo_impl.py:4758-4770 | lightrag/kg/mongo_impl.py:5068-5080 | REDACTED:676-688 | lightrag/kg/opensearch_impl.py:6754-6766 | lightrag/kg/opensearch_impl.py:7160-7172 | REDACTED:4860-4872 | REDACTED:5438-5450 | lightrag/kg/qdrant_impl.py:889-901 | lightrag/kg/qdrant_impl.py:1290-1302 — there are 12 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 12 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:4859` calls `perf_counter` and `REDACTED:1092` 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 (11–13 lines × 5) lightrag/kg/redis_impl.py:1219— lightrag/kg/redis_impl.py:1219-1231 | lightrag/kg/redis_impl.py:1294-1304 | lightrag/kg/redis_impl.py:1348-1360 | lightrag/kg/redis_impl.py:1724-1736 | lightrag/kg/redis_impl.py:1832-1844 — 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 (13 lines × 3) lightrag/kg/milvus_impl.py:2913— lightrag/kg/milvus_impl.py:2913-2925 | lightrag/kg/mongo_impl.py:4738-4750 | lightrag/kg/qdrant_impl.py:869-881 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/milvus_impl.py:2913` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lightrag/kg/milvus_impl.py:2911` calls `run_in_milvus_executor` and `lightrag/kg/mongo_impl.py:4736` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12–13 lines × 3) lightrag/kg/opensearch_impl.py:4445— lightrag/kg/opensearch_impl.py:4445-4457 | lightrag/kg/opensearch_impl.py:5887-5898 | lightrag/kg/opensearch_impl.py:5936-5947 — 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 `lightrag/kg/opensearch_impl.py:4445` 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–13 lines × 3) lightrag/kg/redis_impl.py:1299— lightrag/kg/redis_impl.py:1299-1309 | lightrag/kg/redis_impl.py:1354-1366 | lightrag/kg/redis_impl.py:2009-2019 — 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 `lightrag/kg/redis_impl.py:1299` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lightrag/kg/redis_impl.py:2020` calls `split` and `lightrag/kg/redis_impl.py:1310` 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 (9–12 lines × 7) REDACTED:1084— REDACTED:1084-1092 | lightrag/kg/milvus_impl.py:2924-2932 | lightrag/kg/mongo_impl.py:4749-4757 | REDACTED:667-675 | lightrag/kg/opensearch_impl.py:6742-6753 | REDACTED:4849-4858 | lightrag/kg/qdrant_impl.py:880-888 — 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 7 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:4849` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:4859` calls `perf_counter` and `REDACTED:1093` 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 (10–12 lines × 4) lightrag/kg/redis_impl.py:1298— lightrag/kg/redis_impl.py:1298-1307 | lightrag/kg/redis_impl.py:1353-1364 | lightrag/kg/redis_impl.py:1729-1740 | lightrag/kg/redis_impl.py:2008-2017 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9–12 lines × 3) lightrag/kg/opensearch_impl.py:1372— lightrag/kg/opensearch_impl.py:1372-1383 | lightrag/kg/opensearch_impl.py:3225-3233 | lightrag/kg/opensearch_impl.py:3284-3292 — 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 (4–12 lines × 4) REDACTED:5001— REDACTED:5001-5004 | REDACTED:5013-5024 | REDACTED:5036-5047 | REDACTED:5048-5062 — 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:5013` 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 after the matched lines, `REDACTED:5025` calls `max`, `str` and `REDACTED:5004` 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 lines × 8) REDACTED:3375— REDACTED:3375-3385 | REDACTED:3390-3400 | REDACTED:3405-3415 | REDACTED:3422-3432 | REDACTED:3557-3567 | REDACTED:3573-3583 | REDACTED:3589-3599 | REDACTED:3605-3615 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10–11 lines × 7) lightrag/kg/redis_impl.py:1222— lightrag/kg/redis_impl.py:1222-1232 | lightrag/kg/redis_impl.py:1296-1305 | lightrag/kg/redis_impl.py:1351-1361 | lightrag/kg/redis_impl.py:1727-1737 | lightrag/kg/redis_impl.py:1835-1845 | lightrag/kg/redis_impl.py:2006-2015 | lightrag/kg/redis_impl.py:2657-2666 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lightrag/kg/redis_impl.py:2667` calls `pipeline` and `lightrag/kg/redis_impl.py:1307` 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 (11 lines × 4) lightrag/kg/milvus_impl.py:3344— lightrag/kg/milvus_impl.py:3344-3354 | lightrag/kg/mongo_impl.py:4984-4994 | REDACTED:5325-5344 | lightrag/kg/qdrant_impl.py:1177-1187 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. 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) lightrag/kg/milvus_impl.py:2994— lightrag/kg/milvus_impl.py:2994-3004 | lightrag/kg/mongo_impl.py:4813-4823 | lightrag/kg/qdrant_impl.py:949-960 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/milvus_impl.py:2994` 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) lightrag/api/routers/document_routes.py:2979— lightrag/api/routers/document_routes.py:2979-2988 | lightrag/api/routers/document_routes.py:3017-3027 — both copies are in the same file, so extract the 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 `lightrag/api/routers/document_routes.py:2979` 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, `lightrag/api/routers/document_routes.py:3014` calls `get`, `monotonic` and `lightrag/api/routers/document_routes.py:2977` 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–11 lines × 2) lightrag/kg/opensearch_impl.py:1364— lightrag/kg/opensearch_impl.py:1364-1374 | lightrag/kg/opensearch_impl.py:2324-2330 — both copies are in the same file, so extract the 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 `lightrag/kg/opensearch_impl.py:1364` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–11 lines × 2) lightrag/lightrag.py:4400— lightrag/lightrag.py:4400-4408 | lightrag/lightrag.py:4411-4421 — both copies are in the same file, so extract the block into 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 × 6) examples/lightrag_ollama_demo.py:19— examples/lightrag_ollama_demo.py:19-28 | examples/lightrag_openai_compatible_demo.py:20-30 | examples/lightrag_openai_demo.py:13-22 | examples/unofficial-sample/lightrag_cloudflare_demo.py:132-142 | examples/unofficial-sample/lightrag_embedding_prefixes.py:20-30 | lightrag/api/lightrag_server.py:3310-3319 — before extracting anything, compare `examples/lightrag_ollama_demo.py` and `examples/lightrag_openai_compatible_demo.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/lightrag_openai_compatible_demo.py:20` 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 (10 lines × 5) REDACTED:3661— REDACTED:3661-3671 | REDACTED:3734-3743 | REDACTED:3752-3761 | REDACTED:3770-3779 | REDACTED:3788-3797 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:3661` 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–10 lines × 3) lightrag/kg/opensearch_impl.py:1434— lightrag/kg/opensearch_impl.py:1434-1443 | lightrag/kg/opensearch_impl.py:2328-2332 | lightrag/kg/opensearch_impl.py:2365-2373 — 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 `lightrag/kg/opensearch_impl.py:1434` 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 × 3) lightrag/kg/opensearch_impl.py:1894— lightrag/kg/opensearch_impl.py:1894-1901 | lightrag/kg/opensearch_impl.py:3665-3674 | lightrag/kg/opensearch_impl.py:7343-7352 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8–10 lines × 2) REDACTED:1106— REDACTED:1106-1115 | REDACTED:1838-1845 — both copies are in the same file, so extract the block into 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–9 lines × 6) lightrag/kg/opensearch_impl.py:1368— lightrag/kg/opensearch_impl.py:1368-1376 | lightrag/kg/opensearch_impl.py:1432-1438 | lightrag/kg/opensearch_impl.py:2326-2332 | lightrag/kg/opensearch_impl.py:2363-2369 | lightrag/kg/opensearch_impl.py:3223-3229 | lightrag/kg/opensearch_impl.py:3282-3288 — 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.
Duplicated block (9 lines × 5) lightrag/kg/milvus_impl.py:3348— lightrag/kg/milvus_impl.py:3348-3356 | lightrag/kg/mongo_impl.py:4988-4996 | lightrag/kg/opensearch_impl.py:7081-7089 | REDACTED:5338-5346 | lightrag/kg/qdrant_impl.py:1181-1189 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. 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, `lightrag/kg/mongo_impl.py:4998` calls `setdefault` and `lightrag/kg/milvus_impl.py:3358` 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 × 4) lightrag/kg/memgraph_impl.py:936— lightrag/kg/memgraph_impl.py:936-943 | lightrag/kg/memgraph_impl.py:984-992 | lightrag/kg/neo4j_impl.py:1783-1790 | lightrag/kg/neo4j_impl.py:1850-1858 — before extracting anything, compare `lightrag/kg/memgraph_impl.py` and `lightrag/kg/neo4j_impl.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 468 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/memgraph_impl.py:984` 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–8 lines × 2) lightrag/llm/anthropic.py:149— lightrag/llm/anthropic.py:149-155 | lightrag/llm/openai.py:472-479 — 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 `lightrag/llm/openai.py:472` 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, `lightrag/llm/openai.py:480` calls `debug` and `lightrag/llm/anthropic.py:156` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 2) lightrag/kg/neo4j_impl.py:1150— lightrag/kg/neo4j_impl.py:1150-1156 | lightrag/kg/neo4j_impl.py:1232-1238 — both copies are in the same file, so extract the block into 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) lightrag/kg/opensearch_impl.py:4753— lightrag/kg/opensearch_impl.py:4753-4759 | lightrag/kg/opensearch_impl.py:4929-4934 — both copies are in the same file, so extract the block into 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 × 5) lightrag/kg/json_doc_status_impl.py:1233— lightrag/kg/json_doc_status_impl.py:1233-1237 | lightrag/kg/json_kv_impl.py:463-467 | lightrag/kg/milvus_impl.py:3639-3645 | lightrag/kg/qdrant_impl.py:1528-1534 | lightrag/kg/redis_impl.py:2854-2860 — before extracting anything, compare `lightrag/kg/json_doc_status_impl.py` and `lightrag/kg/json_kv_impl.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 200 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `lightrag/kg/json_doc_status_impl.py:1233` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 5) lightrag/kg/json_doc_status_impl.py:1060— lightrag/kg/json_doc_status_impl.py:1060-1065 | lightrag/kg/mongo_impl.py:1550-1555 | lightrag/kg/opensearch_impl.py:3313-3318 | REDACTED:6492-6497 | lightrag/kg/redis_impl.py:2337-2342 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once. 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 × 5) lightrag/kg/mongo_impl.py:412— lightrag/kg/mongo_impl.py:412-418 | lightrag/kg/mongo_impl.py:692-698 | lightrag/kg/opensearch_impl.py:1008-1014 | lightrag/kg/opensearch_impl.py:1961-1967 | lightrag/kg/opensearch_impl.py:3699-3705 — there are 5 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 5 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 2) reproduce/Step_3.py:19— reproduce/Step_3.py:19-23 | reproduce/Step_3_openai_compatible.py:50-54 — before extracting anything, compare `reproduce/Step_3.py` and `reproduce/Step_3_openai_compatible.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. 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 (38–40 lines × 5) examples/lightrag_ollama_demo.py:121— examples/lightrag_ollama_demo.py:121-158 | examples/lightrag_openai_compatible_demo.py:132-169 | examples/lightrag_openai_demo.py:101-138 | examples/unofficial-sample/lightrag_cloudflare_demo.py:233-272 | examples/unofficial-sample/lightrag_embedding_prefixes.py:138-175 — before extracting anything, compare `examples/lightrag_ollama_demo.py` and `examples/lightrag_openai_compatible_demo.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (32 lines × 3) examples/lightrag_openai_mongodb_graph_demo.py:73— examples/lightrag_openai_mongodb_graph_demo.py:73-104 | examples/unofficial-sample/lightrag_hf_demo.py:44-75 | examples/unofficial-sample/lightrag_openai_neo4j_milvus_redis_demo.py:74-105 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (31 lines × 4) examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:102— examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:102-132 | examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py:104-134 | examples/unofficial-sample/lightrag_llamaindex_litellm_opik_demo.py:115-145 | examples/unofficial-sample/lightrag_lmdeploy_demo.py:70-100 — before extracting anything, compare `examples/unofficial-sample/lightrag_llamaindex_direct_demo.py` and `examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:102` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–19 lines × 5) examples/lightrag_ollama_demo.py:23— examples/lightrag_ollama_demo.py:23-39 | examples/lightrag_openai_compatible_demo.py:24-42 | examples/lightrag_openai_demo.py:17-33 | examples/unofficial-sample/lightrag_cloudflare_demo.py:136-154 | examples/unofficial-sample/lightrag_embedding_prefixes.py:24-42 — before extracting anything, compare `examples/lightrag_ollama_demo.py` and `examples/lightrag_openai_compatible_demo.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/lightrag_ollama_demo.py:23` 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 (19 lines × 3) examples/lightrag_ollama_demo.py:192— examples/lightrag_ollama_demo.py:192-210 | examples/lightrag_openai_compatible_demo.py:203-221 | examples/unofficial-sample/lightrag_embedding_prefixes.py:209-227 — before extracting anything, compare `examples/lightrag_ollama_demo.py` and `examples/lightrag_openai_compatible_demo.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 102 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/lightrag_ollama_demo.py:211` calls `index_done_callback` and `examples/lightrag_openai_compatible_demo.py:222` 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 (5 lines × 3) examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:76— examples/unofficial-sample/lightrag_llamaindex_direct_demo.py:76-80 | examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py:78-82 | examples/unofficial-sample/lightrag_llamaindex_litellm_opik_demo.py:89-93 — before extracting anything, compare `examples/unofficial-sample/lightrag_llamaindex_direct_demo.py` and `examples/unofficial-sample/lightrag_llamaindex_litellm_demo.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. 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.
Low cohesion: _RoleLLMMixin (LCOM4 5) lightrag/llm_roles.py:93— _RoleLLMMixin's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Coverage not measured — JavaScript/TypeScript suite — Coverage NOT MEASURED: the JavaScript/TypeScript half could not be measured — the bun:test suite in lightrag_webui/ ran and not one test passed (src/features/documentRefreshErrors.test.ts:), so the coverage report describes the failed run, not the code. Coverage is excluded from the score rather than counted as a near-zero. The named suite step is one the repository's maintainers can perform; once it passes, the real number is measured on the next scan. Alternatively, commit the lcov/Cobertura report your CI produces and it is read without a re-run.
Sync-over-async blocking examples/unofficial-sample/lightrag_cloudflare_demo.py:53— `_send_request` is async and calls requests.post — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
R10 · Code Duplication· Duplicated block with local edits (111 matched lines × 2 locations) · ×1
Duplicated block with local edits (111 matched lines × 2 locations) lightrag_webui/src/components/documents/ClearDocumentsDialog.tsx:22— lightrag_webui/src/components/documents/ClearDocumentsDialog.tsx:22 · lightrag_webui/src/components/documents/DeleteDocumentsDialog.tsx:21 — the two spans are one implementation copied and then locally edited — 607 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 (70 matched lines × 2 locations) · ×1
Duplicated block with local edits (70 matched lines × 2 locations) lightrag_webui/src/components/ui/AsyncSearch.tsx:132— lightrag_webui/src/components/ui/AsyncSearch.tsx:132 · lightrag_webui/src/components/ui/AsyncSelect.tsx:103 — the two spans are one implementation copied and then locally edited — 336 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 (60 matched lines × 2 locations) · ×1
Duplicated block with local edits (60 matched lines × 2 locations) lightrag_webui/src/components/ui/AsyncSearch.tsx:15— lightrag_webui/src/components/ui/AsyncSearch.tsx:15 · lightrag_webui/src/components/ui/AsyncSelect.tsx:17 — the two spans are one implementation copied and then locally edited — 318 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 (43 matched lines × 2 locations) · ×1
Duplicated block with local edits (43 matched lines × 2 locations) lightrag_webui/src/components/graph/PropertiesView.tsx:272— lightrag_webui/src/components/graph/PropertiesView.tsx:272 · lightrag_webui/src/components/graph/PropertiesView.tsx:369 — the two spans are one implementation copied and then locally edited — 260 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 (35 lines × 5 locations) lightrag_webui/src/components/retrieval/QuerySettings.tsx:246— lightrag_webui/src/components/retrieval/QuerySettings.tsx:246 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:286 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:326 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:366 · +1 more site(s) not listed — 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 (25 lines × 2 locations) lightrag_webui/src/components/retrieval/QuerySettings.tsx:470— lightrag_webui/src/components/retrieval/QuerySettings.tsx:470 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:496 — both copies are in the same file, so extract the block into 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) lightrag_webui/src/features/RetrievalView.tsx:37— lightrag_webui/src/features/RetrievalView.tsx:37 · lightrag_webui/src/features/workspace/WorkspaceQueryView.tsx:46 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication· Duplicated block with local edits (19 matched lines × 2 locations) · ×1
Duplicated block with local edits (19 matched lines × 2 locations) lightrag_webui/src/stores/state.ts:384— lightrag_webui/src/stores/state.ts:384 · lightrag_webui/src/stores/state.ts:448 — the two spans are one implementation copied and then locally edited — 94 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 (17 lines × 2 locations) lightrag_webui/src/components/retrieval/ChatMessage.tsx:300— lightrag_webui/src/components/retrieval/ChatMessage.tsx:300 · lightrag_webui/src/components/retrieval/ChatMessage.tsx:410 — 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 (17 matched lines × 2 locations) · ×1
Duplicated block with local edits (17 matched lines × 2 locations) lightrag_webui/src/features/workspace/WorkspaceEmptyState.tsx:19— lightrag_webui/src/features/workspace/WorkspaceEmptyState.tsx:19 · lightrag_webui/src/features/workspace/WorkspaceWelcome.tsx:130 — the two spans are one implementation copied and then locally edited — 65 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 (16 lines × 2 locations) lightrag_webui/src/components/graph/GraphLabels.tsx:93— lightrag_webui/src/components/graph/GraphLabels.tsx:93 · lightrag_webui/src/components/graph/GraphLabels.tsx:194 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 5 locations) lightrag_webui/src/components/retrieval/QuerySettings.tsx:183— lightrag_webui/src/components/retrieval/QuerySettings.tsx:183 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:275 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:315 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:355 · +1 more site(s) not listed — 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.
R10 · Code Duplication· Duplicated block with local edits (13 matched lines × 2 locations) · ×1
Duplicated block with local edits (13 matched lines × 2 locations) lightrag_webui/src/features/retrieval/MessageList.tsx:314— lightrag_webui/src/features/retrieval/MessageList.tsx:314 · lightrag_webui/src/features/retrieval/MessageList.tsx:342 — the two spans are one implementation copied and then locally edited — 58 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 (12 lines × 12 locations) lightrag_webui/src/components/retrieval/QuerySettings.tsx:133— lightrag_webui/src/components/retrieval/QuerySettings.tsx:133 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:160 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:190 · lightrag_webui/src/components/retrieval/QuerySettings.tsx:242 · +8 more site(s) not listed — all 12 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.
R10 · Code Duplication· Duplicated block with local edits (11 matched lines × 2 locations) · ×1
Duplicated block with local edits (11 matched lines × 2 locations) lightrag_webui/src/features/retrieval/QueryComposer.tsx:80— lightrag_webui/src/features/retrieval/QueryComposer.tsx:80 · lightrag_webui/src/features/retrieval/QueryComposer.tsx:111 — the two spans are one implementation copied and then locally edited — 88 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 (11 lines × 2 locations) lightrag_webui/src/utils/clipboard.ts:66— lightrag_webui/src/utils/clipboard.ts:66 · lightrag_webui/src/utils/clipboard.ts:111 — 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 (10 lines × 2 locations) lightrag_webui/src/components/graph/ZoomControl.tsx:74— lightrag_webui/src/components/graph/ZoomControl.tsx:74 · lightrag_webui/src/components/graph/ZoomControl.tsx:90 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 5 locations) lightrag_webui/src/components/ui/Alert.tsx:26— lightrag_webui/src/components/ui/Alert.tsx:26 · lightrag_webui/src/components/ui/Card.tsx:5 · lightrag_webui/src/components/ui/Card.tsx:23 · lightrag_webui/src/components/ui/Card.tsx:41 · +1 more site(s) not listed — the 5 copies are spread across 3 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (8 lines × 4 locations) lightrag_webui/src/components/ui/Card.tsx:6— lightrag_webui/src/components/ui/Card.tsx:6 · lightrag_webui/src/components/ui/Card.tsx:24 · lightrag_webui/src/components/ui/Card.tsx:42 · lightrag_webui/src/components/ui/Table.tsx:33 — the 4 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 (8 lines × 6 locations) lightrag_webui/src/components/ui/ScrollArea.tsx:19— lightrag_webui/src/components/ui/ScrollArea.tsx:19 · lightrag_webui/src/components/ui/Select.tsx:28 · lightrag_webui/src/components/ui/Select.tsx:42 · lightrag_webui/src/components/ui/Select.tsx:56 · +2 more site(s) not listed — the 6 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication· Duplicated block with local edits (8 matched lines × 2 locations) · ×1
Duplicated block with local edits (8 matched lines × 2 locations) lightrag_webui/src/features/retrieval/useQuerySession.ts:312— lightrag_webui/src/features/retrieval/useQuerySession.ts:312 · lightrag_webui/src/features/retrieval/useQuerySession.ts:517 — the two spans are one implementation copied and then locally edited — 60 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.
R10 · Code Duplication· Duplicated block with local edits (7 matched lines × 2 locations) · ×1
Duplicated block with local edits (7 matched lines × 2 locations) lightrag_webui/src/components/graph/GraphControl.tsx:332— lightrag_webui/src/components/graph/GraphControl.tsx:332 · lightrag_webui/src/hooks/useLightragGraph.tsx:776 — the two spans are one implementation copied and then locally edited — 51 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 (7 lines × 2 locations) lightrag_webui/src/components/graph/PropertiesView.tsx:389— lightrag_webui/src/components/graph/PropertiesView.tsx:389 · lightrag_webui/src/components/graph/PropertiesView.tsx:396 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 4 locations) lightrag_webui/src/components/ui/Progress.tsx:6— lightrag_webui/src/components/ui/Progress.tsx:6 · lightrag_webui/src/components/ui/ScrollArea.tsx:6 · lightrag_webui/src/components/ui/Select.tsx:13 · lightrag_webui/src/components/ui/Select.tsx:105 — the 4 copies are spread across 3 files, 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 (6 lines × 9 locations) lightrag_webui/src/components/graph/GraphControl.tsx:28— lightrag_webui/src/components/graph/GraphControl.tsx:28 · lightrag_webui/src/components/graph/GraphControl.tsx:34 · lightrag_webui/src/components/graph/PropertiesView.tsx:15 · lightrag_webui/src/components/graph/Settings.tsx:183 · +5 more site(s) not listed — the 6 copies are spread across 3 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 (6 lines × 3 locations) lightrag_webui/src/components/retrieval/ChatMessage.tsx:503— lightrag_webui/src/components/retrieval/ChatMessage.tsx:503 · lightrag_webui/src/components/retrieval/ChatMessage.tsx:594 · lightrag_webui/src/components/retrieval/ChatMessage.tsx:607 — 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 (6 lines × 2 locations) lightrag_webui/src/hooks/useLightragGraph.tsx:838— lightrag_webui/src/hooks/useLightragGraph.tsx:838 · lightrag_webui/src/hooks/useLightragGraph.tsx: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.
Boundary violation [package:third-party-deep-import] lightrag_webui/src/components/retrieval/ChatMessage.tsx:17— lightrag_webui/src/components/retrieval/ChatMessage.tsx:17 imports react-syntax-highlighter/dist/cjs/styles/prism, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Complex function DocumentManager (cyclomatic 54, cognitive 53) lightrag_webui/src/features/DocumentManager.tsx:381— DocumentManager has cyclomatic complexity 54 and cognitive complexity 53; 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 handleNodeExpand (cyclomatic 52, cognitive 68) lightrag_webui/src/hooks/useLightragGraph.tsx:681— handleNodeExpand has cyclomatic complexity 52 and cognitive complexity 68; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function ChatMessage (cyclomatic 44, cognitive 38) lightrag_webui/src/components/retrieval/ChatMessage.tsx:57— ChatMessage has cyclomatic complexity 44 and cognitive complexity 38; 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 handleSave (cyclomatic 38, cognitive 65) lightrag_webui/src/components/graph/EditablePropertyRow.tsx:96— handleSave has cyclomatic complexity 38 and cognitive complexity 65; 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 27, cognitive 42) lightrag_webui/src/features/retrieval/useQuerySession.ts:248— (anonymous) has cyclomatic complexity 27 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 migrateLegacySettingsState (cyclomatic 26, cognitive 29) lightrag_webui/src/migrations/legacySettingsChain.ts:32— migrateLegacySettingsState has cyclomatic complexity 26 and cognitive complexity 29; 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 24, cognitive 44) lightrag_webui/src/features/DocumentManager.tsx:771— (anonymous) has cyclomatic complexity 24 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 (anonymous) (cyclomatic 23, cognitive 39) lightrag_webui/src/components/documents/UploadDocumentsDialog.tsx:100— (anonymous) has cyclomatic complexity 23 and cognitive complexity 39; 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 22, cognitive 21) lightrag_webui/src/components/retrieval/ChatMessage.tsx:480— (anonymous) has cyclomatic complexity 22 and cognitive complexity 21; 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 runSettingsStorageSplitMigration (cyclomatic 21, cognitive 33) lightrag_webui/src/migrations/splitSettingsStorage.ts:554— runSettingsStorageSplitMigration has cyclomatic complexity 21 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 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 check (cyclomatic 20, cognitive 36) lightrag_webui/src/stores/state.ts:88— check has cyclomatic complexity 20 and cognitive complexity 36; 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 updateAssistantMessage (cyclomatic 20, cognitive 18) lightrag_webui/src/features/retrieval/useQuerySession.ts:333— updateAssistantMessage has cyclomatic complexity 20 and cognitive complexity 18; 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 19, cognitive 24) lightrag_webui/src/features/DocumentManager.tsx:115— (anonymous) has cyclomatic complexity 19 and cognitive complexity 24; 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 AsyncSelect (cyclomatic 18, cognitive 13) lightrag_webui/src/components/ui/AsyncSelect.tsx:74— AsyncSelect has cyclomatic complexity 18 and cognitive complexity 13; 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 17, cognitive 21) lightrag_webui/src/components/status/StatusCard.tsx:59— (anonymous) has cyclomatic complexity 17 and cognitive complexity 21; 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 PipelineStatusDialog (cyclomatic 17, cognitive 16) lightrag_webui/src/components/documents/PipelineStatusDialog.tsx:25— PipelineStatusDialog has cyclomatic complexity 17 and cognitive complexity 16; 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 17, cognitive 15) lightrag_webui/src/components/graph/GraphControl.tsx:374— (anonymous) has cyclomatic complexity 17 and cognitive complexity 15; 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 _classifyStreamError (cyclomatic 17, cognitive 14) lightrag_webui/src/api/lightrag.ts:802— _classifyStreamError has cyclomatic complexity 17 and cognitive complexity 14; 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 generateBundle (cyclomatic 16, cognitive 28) lightrag_webui/vite.config.ts:100— generateBundle has cyclomatic complexity 16 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 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 16, cognitive 19) lightrag_webui/src/hooks/useLightragGraph.tsx:248— (anonymous) has cyclomatic complexity 16 and cognitive complexity 19; 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· lightrag_webui/src/features/DocumentManager.tsx · ×1
lightrag_webui/src/features/DocumentManager.tsx: 1693 lines of code lightrag_webui/src/features/DocumentManager.tsx:1— lightrag_webui/src/features/DocumentManager.tsx has 1693 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· lightrag_webui/src/api/lightrag.ts · ×1
lightrag_webui/src/api/lightrag.ts: 1272 lines of code lightrag_webui/src/api/lightrag.ts:1— lightrag_webui/src/api/lightrag.ts has 1272 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· lightrag_webui/src/hooks/useLightragGraph.tsx · ×1
lightrag_webui/src/hooks/useLightragGraph.tsx: 1040 lines of code lightrag_webui/src/hooks/useLightragGraph.tsx:1— lightrag_webui/src/hooks/useLightragGraph.tsx has 1040 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· lightrag_webui/src/components/retrieval/ChatMessage.tsx · ×1
lightrag_webui/src/components/retrieval/ChatMessage.tsx: 656 lines of code lightrag_webui/src/components/retrieval/ChatMessage.tsx:1— lightrag_webui/src/components/retrieval/ChatMessage.tsx has 656 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· lightrag_webui/src/migrations/splitSettingsStorage.ts · ×1
lightrag_webui/src/migrations/splitSettingsStorage.ts: 639 lines of code lightrag_webui/src/migrations/splitSettingsStorage.ts:1— lightrag_webui/src/migrations/splitSettingsStorage.ts has 639 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· lightrag_webui/src/features/retrieval/useQuerySession.ts · ×1
lightrag_webui/src/features/retrieval/useQuerySession.ts: 628 lines of code lightrag_webui/src/features/retrieval/useQuerySession.ts:1— lightrag_webui/src/features/retrieval/useQuerySession.ts has 628 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· lightrag_webui/src/components/retrieval/QuerySettings.tsx · ×1
lightrag_webui/src/components/retrieval/QuerySettings.tsx: 521 lines of code lightrag_webui/src/components/retrieval/QuerySettings.tsx:1— lightrag_webui/src/components/retrieval/QuerySettings.tsx has 521 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· lightrag_webui/src/components/graph/GraphControl.tsx · ×1
lightrag_webui/src/components/graph/GraphControl.tsx: 461 lines of code lightrag_webui/src/components/graph/GraphControl.tsx:1— lightrag_webui/src/components/graph/GraphControl.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· lightrag_webui/src/stores/state.ts · ×1
lightrag_webui/src/stores/state.ts: 456 lines of code lightrag_webui/src/stores/state.ts:1— lightrag_webui/src/stores/state.ts has 456 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· lightrag_webui/src/components/ui/FileUploader.tsx · ×1
lightrag_webui/src/components/ui/FileUploader.tsx: 427 lines of code lightrag_webui/src/components/ui/FileUploader.tsx:1— lightrag_webui/src/components/ui/FileUploader.tsx has 427 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· lightrag_webui/src/components/graph/Settings.tsx · ×1
lightrag_webui/src/components/graph/Settings.tsx: 410 lines of code lightrag_webui/src/components/graph/Settings.tsx:1— lightrag_webui/src/components/graph/Settings.tsx has 410 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 (~133 LoC) lightrag_webui/src/components/ui/NumberInput.tsx— no import path from any entry point (10 application, 6 tooling, 76 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 (~49 LoC) lightrag_webui/src/components/LanguageToggle.tsx— no import path from any entry point (10 application, 6 tooling, 76 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 (~41 LoC) lightrag_webui/src/components/ThemeToggle.tsx— no import path from any entry point (10 application, 6 tooling, 76 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 (~37 LoC) lightrag_webui/src/components/ui/TabContent.tsx— no import path from any entry point (10 application, 6 tooling, 76 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 (~33 LoC) lightrag_webui/src/components/ui/Badge.tsx— no import path from any entry point (10 application, 6 tooling, 76 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 (~23 LoC) lightrag_webui/src/components/ui/Progress.tsx— no import path from any entry point (10 application, 6 tooling, 76 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 (~17 LoC) lightrag_webui/src/contexts/useTabVisibility.ts— no import path from any entry point (10 application, 6 tooling, 76 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (lightrag_webui/src/components/ui/TabContent.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~9 LoC) lightrag_webui/src/components/Root.tsx— no import path from any entry point (10 application, 6 tooling, 76 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
Unlisted import 'mdast' lightrag_webui/src/utils/remarkFootnotes.ts:3— Imported only as a TYPE and declared in no reachable REDACTED. The import is erased at compile time, so nothing is installed and no runtime resolution depends on it — but type-checking a clean clone will fail. Declare the typings it resolves through (or the package itself) in the owning REDACTED.
Unlisted import 'unified' lightrag_webui/src/utils/remarkFootnotes.ts:2— Imported only as a TYPE and declared in no reachable REDACTED. The import is erased at compile time, so nothing is installed and no runtime resolution depends on it — but type-checking a clean clone will fail. Declare the typings it resolves through (or the package itself) in the owning REDACTED.
Unused dependency '@react-sigma/layout-force' — Declared in REDACTED 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.
Unused dependency '@react-sigma/layout-forceatlas2' — Declared in REDACTED 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.
Unused dependency '@react-sigma/layout-noverlap' — Declared in REDACTED 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.
X25 · Inert configuration knob· Setting lookup falls back to a different setting than its key · ×1
Setting lookup falls back to a different setting than its key lightrag/api/routers/graph_routes.py:845— `this module` looks up `"entity_name"` and falls back to `entity_to_change_into` when the caller supplies none — but line 499 of this same type looks up `"entity_name"` and falls back to `entity_name`, which is the member that key names. The two cannot both be right: every caller who configures `entity_name` and passes no `"entity_name"` override silently gets `entity_to_change_into` instead, and nothing reports that the value was ignored. Fall back to `entity_name` here as line 499 does — or, if `entity_to_change_into` genuinely is the intended source, look it up under its own key so the two sites stop disagreeing.
Interpolated log message defeats structured logging lightrag/file_atomic.py:83— `warning` at line 83 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 lightrag/file_atomic.py:118— `info` at line 118 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 lightrag/file_atomic.py:122— `warning` at line 122 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 lightrag/file_atomic.py:151— `warning` at line 151 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 lightrag/file_atomic.py:156— `debug` at line 156 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging lightrag/file_atomic.py:188— `warning` at line 188 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 lightrag/operate.py:451— `warning` at line 451 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 lightrag/operate.py:487— `warning` at line 487 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 lightrag/operate.py:504— `info` at line 504 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 lightrag/operate.py:624— `warning` at line 624 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 lightrag/operate.py:646— `warning` at line 646 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 lightrag/operate.py:680— `warning` at line 680 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 lightrag/operate.py:689— `warning` at line 689 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 lightrag/operate.py:694— `warning` at line 694 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 lightrag/operate.py:702— `warning` at line 702 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 lightrag/operate.py:718— `warning` at line 718 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 lightrag/operate.py:729— `info` at line 729 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 lightrag/operate.py:748— `warning` at line 748 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 lightrag/operate.py:763— `error` at line 763 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 lightrag/operate.py:768— `error` at line 768 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 lightrag/operate.py:784— `warning` at line 784 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 lightrag/operate.py:796— `info` at line 796 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 lightrag/operate.py:802— `info` at line 802 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 lightrag/operate.py:808— `debug` at line 808 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging lightrag/operate.py:822— `warning` at line 822 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.
Duplicated predicate lightrag_webui/src/App.tsx:134— `!status.auth_configured && status.access_token` appears character-identically in 4 files — lightrag_webui/src/App.tsx, lightrag_webui/src/features/LoginPage.tsx, lightrag_webui/src/features/workspace/WorkspaceWelcome.tsx, lightrag_webui/src/features/workspace/authBootstrap.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 lightrag_webui/src/components/ui/AsyncSearch.tsx:171— `disabled && 'cursor-not-allowed opacity-50'` appears character-identically in 2 files — lightrag_webui/src/components/ui/AsyncSearch.tsx, lightrag_webui/src/components/ui/AsyncSelect.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 lightrag_webui/src/components/ui/AsyncSearch.tsx:195— `loading && options.length === 0 && (loadingSkeleton || <DefaultLoadingSkeleton />)` appears character-identically in 2 files — lightrag_webui/src/components/ui/AsyncSearch.tsx, lightrag_webui/src/components/ui/AsyncSelect.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 lightrag_webui/src/components/ApiKeyAlert.tsx:45— `message.includes(InvalidApiKeyError) || message.includes(RequireApiKeError)` appears character-identically in 2 files — lightrag_webui/src/components/ApiKeyAlert.tsx, lightrag_webui/src/features/workspace/credentialProbe.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 lightrag_webui/src/App.tsx:146— `status.auth_mode === 'disabled' || useAuthStore.getState().isGuestMode` appears character-identically in 2 files — lightrag_webui/src/App.tsx, lightrag_webui/src/features/workspace/authBootstrap.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 lightrag/parser/docx/ir_builder.py:322— `Path(document_name).stem or document_name` appears character-identically in 5 files — lightrag/parser/docx/ir_builder.py, lightrag/parser/external/docling/ir_builder.py, lightrag/parser/external/mineru/ir_builder.py, lightrag/parser/markdown/ir_builder.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 lightrag/parser/external/docling/ir_builder.py:166— `cb_lines or cb_tables or cb_drawings or cb_equations` appears character-identically in 2 files — lightrag/parser/external/docling/ir_builder.py, lightrag/parser/external/mineru/ir_builder.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 lightrag/parser/external/docling/ir_builder.py:170— `cb_tables or cb_drawings or cb_equations` appears character-identically in 2 files — lightrag/parser/external/docling/ir_builder.py, lightrag/parser/external/mineru/ir_builder.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 lightrag/tools/clean_llm_query_cache.py:175— `config.has_option("mongodb", "uri") and config.has_option( "mongodb", "database" )` appears character-identically in 2 files — lightrag/tools/clean_llm_query_cache.py, lightrag/tools/migrate_llm_cache.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 lightrag/tools/clean_llm_query_cache.py:170— `config.has_option("postgres", "user") and config.has_option("postgres", "password") and config.has_option("postgres", "database")` appears character-identically in 2 files — lightrag/tools/clean_llm_query_cache.py, lightrag/tools/migrate_llm_cache.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 lightrag/llm/hf.py:334— `context == "document" and document_prefix` appears character-identically in 3 files — lightrag/llm/hf.py, lightrag/llm/ollama.py, lightrag/llm/openai.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 lightrag/kg/json_doc_status_impl.py:1176— `count != expected_candidate_count or fingerprint != expected_candidate_fingerprint` appears character-identically in 5 files — lightrag/kg/json_doc_status_impl.py, lightrag/kg/mongo_impl.py, lightrag/kg/opensearch_impl.py, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate lightrag/kg/memgraph_impl.py:1095— `count_record and count_record["total"] > max_nodes` appears character-identically in 2 files — lightrag/kg/memgraph_impl.py, lightrag/kg/neo4j_impl.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 lightrag/parser/external/docling/cache.py:190— `cur_endpoint and manifest.endpoint_signature and cur_endpoint != manifest.endpoint_signature` appears character-identically in 2 files — lightrag/parser/external/docling/cache.py, lightrag/parser/external/mineru/cache.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 lightrag/parser/external/docling/cache.py:178— `cur_engine_version and manifest.engine_version and cur_engine_version != manifest.engine_version` appears character-identically in 2 files — lightrag/parser/external/docling/cache.py, lightrag/parser/external/mineru/cache.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 lightrag/storage_migrations.py:331— `edge.get("source") or edge.get("src_id") or edge.get("src")` appears character-identically in 2 files — lightrag/storage_migrations.py, lightrag/tools/chunk_tracking_repair.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 lightrag/storage_migrations.py:332— `edge.get("target") or edge.get("tgt_id") or edge.get("tgt")` appears character-identically in 2 files — lightrag/storage_migrations.py, lightrag/tools/chunk_tracking_repair.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 lightrag/parser/external/_common.py:57— `entry.is_dir() and not entry.is_symlink()` appears character-identically in 2 files — lightrag/parser/external/_common.py, lightrag/parser/external/mineru/cache.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 lightrag/llm/jina.py:31— `error_text.strip().startswith("<!DOCTYPE html>") or "text/html" in content_type` appears character-identically in 2 files — lightrag/llm/jina.py, lightrag/rerank.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 lightrag/api/body_limit_middleware.py:161— `getattr(args, "max_request_body_bytes", 0) or 0` appears character-identically in 2 files — lightrag/api/body_limit_middleware.py, lightrag/api/utils_api.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 lightrag/lightrag.py:4172— `getattr(storage_inst, "final_namespace", None) or getattr( storage_inst, "namespace", "" )` appears character-identically in 2 files — lightrag/lightrag.py, lightrag/operate.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 lightrag/api/body_limit_middleware.py:169— `isinstance(max_upload_size, int) and max_upload_size > 0` appears character-identically in 2 files — lightrag/api/body_limit_middleware.py, lightrag/api/utils_api.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 lightrag/kg/json_doc_status_impl.py:797— `isinstance(metadata, dict) and isinstance(metadata.get(CUSTOM_CHUNK_PATCH_METADATA_KEY), dict)` appears character-identically in 4 files — lightrag/kg/json_doc_status_impl.py, lightrag/kg/mongo_impl.py, lightrag/kg/opensearch_impl.py, lightrag/kg/redis_impl.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 lightrag/kg/json_doc_status_impl.py:614— `isinstance(metadata, dict) and metadata.get("is_duplicate")` appears character-identically in 2 files — lightrag/kg/json_doc_status_impl.py, lightrag/kg/redis_impl.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 lightrag/api/routers/document_routes.py:6094— `isinstance(result, dict) and result.get("status") != "success"` appears character-identically in 2 files — lightrag/api/routers/document_routes.py, lightrag/lightrag.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.
Orphaned file lightrag_webui/src/components/ui/Select.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 lightrag_webui/src/components/ui/Command.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 lightrag_webui/src/components/ui/AlertDialog.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 lightrag_webui/src/components/ui/Dialog.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 lightrag_webui/src/components/ui/Table.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 lightrag_webui/src/components/ui/Button.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.
Hand-rolled JSON/XML parsing via regex lightrag/table_markup.py:29— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
Hand-rolled JSON/XML parsing via regex lightrag/table_markup.py:46— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
Hand-rolled JSON/XML parsing via regex lightrag/kg/redis_impl.py:84— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
Hand-rolled JSON/XML parsing via regex lightrag/api/static/swagger-ui/swagger-ui-bundle.js:2— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This JavaScript/TypeScript code already uses a real parser in the same package; use it here too.
Hand-rolled JSON/XML parsing via regex lightrag/api/routers/ollama_api.py:868— A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
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 lightrag/operate.py:5357— `debug` at line 5357 is called with an argument built by `"…".join(text_purposes)` (line 5360), 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 lightrag/parser/external/mineru/ir_builder.py:450— `debug` at line 450 is called with an argument built by `sorted(item)` (line 457), 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 lightrag/kg/milvus_impl.py:1219— `debug` at line 1219 is called with an argument built by `index_config.to_dict()` (line 1220), 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 lightrag/evaluation/eval_rag_quality.py:354— `debug` at line 354 is called with an argument built by `list(first_ref.keys())` (line 354), 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.
Silent fallback default on parse failure lightrag/chunker/paragraph_semantic.py:336— `_load_table_headers` returns `{}` when `(OSError, 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 lightrag/kg/opensearch_impl.py:5268— `_edge_depth` 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 lightrag/parser/_html_table.py:81— `_cell_span` returns `1` 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 in catch lightrag/parser/docx/numbering_resolver.py:559— `get_label` 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 lightrag/parser/docx/numbering_resolver.py:615— `_format_label` 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.
C2 · Access Controls· No named authorization policies · ×1
No named authorization policies — Authorization IS enforced here (by route guards, auth middleware or checks that refuse a caller) — this is NOT a claim that endpoints are unprotected. What's missing is a NAMED rule set: who may do what is encoded inline where it is checked, so the rules can't be listed, reviewed or tested apart from the code that applies them. Recommendation, not a defect.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 54 significant file(s) lose their only recent owner: lightrag/parser/docx/smart_heading/title_block.py, lightrag/parser/markdown/parser.py, lightrag/tools/migrate_llm_cache.py, lightrag/tools/chunk_tracking_repair.py, lightrag/parser/docx/smart_heading/guardrails.py, lightrag/tools/clean_llm_query_cache.py, lightrag/tools/source_conflict_repair.py, lightrag/parser/external/docling/ir_builder.py (+46 more). Pair on, review, or document these before any departure.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 2 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 (71 single-owned of 233 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 233 of the 340 production source files in this repository met that bar). They are anonymized user #2 (1 file(s)), anonymized user #3 (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: lightrag/tools/migrate_graph_storage.py, lightrag/evaluation/offline_retrieval_check.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 2 project(s) overshoot their size bounds, lowering Project Cohesion to 0.0/10. The most over is `(repository root)` (151888 LoC, 583 module-visible types across 25 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
REDACTED
D34 · Knowledge Freshness· Orphaned files with no living knowledge · ×1
Orphaned files with no living knowledge — 6 of 233 analysed file(s) have no living knowledge left — their last meaningful change has decayed away, so if one breaks, no one currently understands it (counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 233 of the 340 production source files in this repository met that bar). None is large enough to earn a read-through of its own, so this row stands in for the per-file rows rather than raising one each — most significant first: lightrag_webui/src/components/ui/Select.tsx, lightrag_webui/src/components/ui/Command.tsx, lightrag_webui/src/components/ui/AlertDialog.tsx, lightrag_webui/src/components/ui/Dialog.tsx, lightrag_webui/src/components/ui/Table.tsx, lightrag_webui/src/components/ui/Button.tsx. 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.
D40 · Network Egress Confinement· No network policy · ×1
No network policy — No Kubernetes NetworkPolicy (or Cilium policy) found. Without one, every pod can talk to every other pod and reach out to the internet by default. Add a default-deny policy and open only the flows you need.
No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
No src/ separation — Production code isn't grouped under a src/ folder — it's spread across several top-level directories, so there's no one place that says 'this is the product'.
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 29919 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.
No changelog — No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
R7 · Dead Code· Unused export 'isClipboardSupported' · ×1
Unused export 'isClipboardSupported' lightrag_webui/src/utils/clipboard.ts:178— Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code· Unused export 'getBestClipboardMethod' · ×1
Unused export 'getBestClipboardMethod' lightrag_webui/src/utils/clipboard.ts:188— Nothing imports this binding — it is safe to review for removal.
X2 · Cancellation propagation· Not all async functions that make a request accept an AbortSignal · ×1
Not all async functions that make a request accept an AbortSignal — Only 5/27 async functions that make a cancellable request (fetch, axios, ky, ofetch) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
Null assertions (`!`) reduce the strict null checking score — ~0.3 `!` null assertions per 1k TypeScript source lines — 8 assertion(s) across the 24620 source line(s) of the 153 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: lightrag_webui/src/components/ui/NumberInput.tsx (2), lightrag_webui/src/hooks/useLightragGraph.tsx (2), lightrag_webui/src/api/lightrag.ts (1). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce.
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 2 file(s) — `lightrag_webui/src/api/lightrag.ts`, `lightrag_webui/src/features/workspace/querySettingsSnapshot.ts` — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
runtime-hardening: not applicable — The repository ships application workloads but no cluster-governance resources (CRDs, admission webhooks, or a committed policy engine). Runtime threat-detection (Falco/Tetragon) and admission control (Kyverno/OPA-Gatekeeper/PodSecurity) are cluster-OPERATOR controls owned by the platform, not shipped by an application repo/chart — nothing for this repo to assess.
Run 01a17282-c5fa-7d46-b6e7-af938ce08140 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 148 · Warnings: 1367 · Recommendations: 109 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 25-10-2026 @ 10:02 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.