Public report — PaddleOCR, published 26 Sep 2026.
Concrete security findings (which rule fired, in which file, on which line; CVE IDs, secret matches,
dependency versions) are REDACTED in this version; ask the repo owner for the full report.
Public
Codebase surveyMeasured under the Code Assurance Index · rubric rubric-2026.09.15 (frozen) · verify this surveyFiledcd_19d61af89cab4496911acf7b59df2688
Filed 26 September 2026, 06:31 UTC
Public
Large · 129,228 LoC · rebuild ~1.2 person-years · weakest lens: Security (59%)
Findings by grade
427 critical947 serious39 minor42 could not be resolved — could be critical — see Limitations
This survey was produced by
Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
26 September 2026, 05:56 UTC
A measurement, not a certificate. The Code Assurance Index does not certify,
approve or guarantee this codebase; it records a reproducible number and the evidence it was computed from. The
standard is authored by Canine Development, who also build Watchdog — its only implementation today. That is said
here so the number is checked rather than believed.
Grounded in facts. Every number here is computed, not narrated — reproducible, tool-backed, and traceable to a line of code. How to trust this ▸
1401findings with an exact file:lineof 1413 — the remainder are repo-wide signals (a dimension-level measurement, not a single line); open any file:line and verify
44/127dimensions across the health lenses129228 LoC — wide & deep
⚠ A critical security finding caps this grade — resolve it before relying on the score below; see the Security lens.
The system holds a 68% health score, indicating a workable asset carrying significant risk. While the underlying architecture is robust, the overall standing is fragile due to security gaps and a hidden tax on development speed. This score reflects a large, valuable codebase that requires immediate attention to protect business continuity and control long-term costs.
The asset is substantial, comprising over 129,000 lines of production code with a rebuild cost of approximately €170,000. This represents a significant investment tied up in the current implementation. The value is concentrated in complex business logic rather than boilerplate, meaning changes are high-stakes. Any delay or defect in this area directly impacts revenue-generating capabilities, making stability and security critical for protecting this capital.
The most urgent theme is security exposure. With a security score of 59%, the system is vulnerable to supply chain attacks and unauthorized code execution. This is not merely a technical debt issue but a direct business risk. Unverified third-party scripts and unpatched infrastructure configurations create an attack surface that could lead to data breaches or service outages. Remediation here offers the highest protection per euro spent, shielding the brand and customer trust.
The second theme is a velocity tax on every change. Code quality signals suggest that modifications in weaker areas cost 5–12% more effort than in clean code. This inefficiency compounds annually, draining engineering resources that could otherwise drive new features. Over time, this drag reduces the team’s ability to respond to market changes, effectively increasing the cost of every release and slowing time-to-market for critical updates.
Strengths lie in the architecture’s stability and high code health, which provide a solid foundation for future improvements. The system is mature enough for new teams to navigate, though documentation gaps remain. The first action must be pinning third-party scripts and verifying their integrity. This single move breaks even quickly by reducing annual maintenance drag and significantly lowers security risk. It is the highest-leverage step to stabilize the platform and unlock faster, safer delivery.
How the score is built — each lens's share of the headlineWidth is the lens's weight in the worst-heaviest fold (the weakest area pulls hardest); colour is that lens's own band. A lens fixes the score in proportion to its width.
1327 finding(s) are new versus the previous scan (2026-08-07) — surfaced by this scheduled scan itself, no pull request required. Showing the first 100; the full set is in the report.
A full-fidelity diff against the previous run's complete recorded findings — line-move tolerant: a finding that only shifted line counts as unchanged, only genuinely new titles/files surface here.
0.9× (at 68% quality) — the last 20% of quality is most of the work
Size & shape
Large · effort split not classified (source measured from disk; the effort-tier breakdown is a C#-only syntax walk)
This codebase represents roughly ~1.2 person-years of build effort (about ~€170,000 to rebuild). Its weakest lens is Security at 59% — the part of that asset most exposed by the findings below.
How we model this: boilerplate at a scaffolding rate + logic × domain Standard (×1.0) — standard service × a 0.9× quality factor, at €60–95/h; indicative, ±~30% · size measured directly from source · effort from total production LoC as straight-line logic (the tier split is a C#-only syntax walk), a conservative lower bound. Indicative only — most sensitive to the hourly rate and the domain tier (both tunable in config).
Top priorities
The highest-leverage moves; the full ranked list is in the Roadmap below.
1
Pin third-party scripts and verify them: name an exact version in the URL and add an `integrity="sha384-…"` hash alongside `crossorigin="anonymous"` (both are required — an integrity hash on a cross-origin script without `crossorigin` is not evaluated, it blocks the script). Where the vendor ships a continuously-updated loader and publishes no stable hash (tag managers, analytics, chat widgets), Subresource Integrity is not available: constrain it instead with a `Content-Security-Policy` that names the exact origins allowed to execute, and drop the script from the pages that do not need it. Where the page is shipped inside a package that others host, prefer vendoring the asset and serving it from the app’s own origin, so no consumer inherits a third-party dependency they did not choose.
The top-ranked fix costs roughly 3–10 engineer-days once. Not doing it costs about 1.6–9.5 engineer-days every year, paid as drag on the ~11,911 lines this team changes annually — a bill that arrives whether or not anyone books it. On those figures the fix breaks even in roughly 4–76 months and is free after that. Method, stated so this is not read as a quotation: debt from the ranked task's effort band; interest = annual changed lines (measured, annualised from the 90-day window) ÷ an ASSUMED 150–400 lines per engineer-day × the 5–12% drag implied by the code-quality signals; breaking point = debt ÷ annual interest. A modelled planning range built from measured inputs and one named assumption — not a quotation, a valuation, or a certified figure.
Evidence: D15 churn: 2,937 line(s) changed over a 90-day window ⇒ ~11,911/year · D1/D2/D4 code quality: averaging 5.9/10 ⇒ a 5–12% drag on each change · top-ranked remediation: Medium effort ⇒ about 3–10 engineer-day(s)
→ Do the top-ranked fix now if this code will still be yours in 76 months.
Value concentrated against a weak lens · Medium · Value at risk
This is a Large asset (~1.2 person-years to rebuild), and its weakest lens is Security at 59%. The operational and business risk on an asset this size concentrates there — that's where remediation buys the most protection.
→ Direct remediation budget at Security first — highest risk-reduction per euro on an asset this size.
Highest-leverage move · Medium · Leverage
Of everything flagged, the best return on effort is: Pin third-party scripts and verify them: name an exact version in the URL and add an `integrity="sha384-…"` hash alongside `crossorigin="anonymous"` (both are required — an integrity hash on a cross-origin script without `crossorigin` is not evaluated, it blocks the script). Where the vendor ships a continuously-updated loader and publishes no stable hash (tag managers, analytics, chat widgets), Subresource Integrity is not available: constrain it instead with a `Content-Security-Policy` that names the exact origins allowed to execute, and drop the script from the pages that do not need it. Where the page is shipped inside a package that others host, prefer vendoring the asset and serving it from the app’s own origin, so no consumer inherits a third-party dependency they did not choose. The rest can wait behind it.
Evidence: priority ranking: top of 5 ranked by impact/effort
→ Pin third-party scripts and verify them: name an exact version in the URL and add an `integrity="sha384-…"` hash alongside `crossorigin="anonymous"` (both are required — an integrity hash on a cross-origin script without `crossorigin` is not evaluated, it blocks the script). Where the vendor ships a continuously-updated loader and publishes no stable hash (tag managers, analytics, chat widgets), Subresource Integrity is not available: constrain it instead with a `Content-Security-Policy` that names the exact origins allowed to execute, and drop the script from the pages that do not need it. Where the page is shipped inside a package that others host, prefer vendoring the asset and serving it from the app’s own origin, so no consumer inherits a third-party dependency they did not choose.
A velocity tax on every change · Medium · Economics
The code-quality signals (complexity, duplication, cohesion) average 5.9/10, which acts as a tax on every change in the weaker areas: modifications there plausibly cost on the order of 5–12% more than in clean code, and the tax compounds as the codebase grows. (A modelled estimate, not a measured fact.)
Evidence: D1/D2/D4 code quality: averaging 5.9/10 across the code-quality signals actually measured
→ Pay it down where churn is highest — the hotspots — not everywhere; that's where the tax is actually paid.
Architecture — module dependency matrix
Rows and columns are the same modules, ordered so that a module only depends on ones above it. A cell means the row depends on the column, and its number is how many type pairs create that dependency. Read one thing: is anything above the diagonal? A mark there is a dependency cycle. (A cycle is all this shows — an unusual but cycle-free dependency sits below the diagonal like any other.)
510 modules, 172 dependencies. 2 dependency cycles across 4 modules, marked above the diagonal.
Showing the 40 most-connected modules; 470 more are not drawn.
Module dependency matrix. The row depends on the column; the number is how many type pairs create the dependency. A cell above the diagonal is part of a dependency cycle.
api_sdk.typescript.src.internal.poller uses api_sdk.typescript.src.internal.http. Changing api_sdk.typescript.src.internal.http can break api_sdk.typescript.src.internal.poller, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
14→2 api_sdk.typescript.src.internal.poller depends on api_sdk.typescript.src.results✕
Type pairs
2 distinct (type in api_sdk.typescript.src.internal.poller → type in api_sdk.typescript.src.results) references.
api_sdk.typescript.src.internal.poller uses api_sdk.typescript.src.results. Changing api_sdk.typescript.src.results can break api_sdk.typescript.src.internal.poller, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
15→36 com.paddle.ocr.demo.OCRApplication depends on com.paddle.ocr.democycle✕
Type pairs
1 distinct (type in com.paddle.ocr.demo.OCRApplication → type in com.paddle.ocr.demo) reference.
com.paddle.ocr.demo.OCRApplication uses com.paddle.ocr.demo. Changing com.paddle.ocr.demo can break com.paddle.ocr.demo.OCRApplication, not the reverse.
Position
Above the diagonal — a cycle. Neither module can be changed, tested or deployed independently until one of these dependencies goes.
16→3 com.paddle.ocr.engine depends on com.paddle.ocr.model✕
Type pairs
1 distinct (type in com.paddle.ocr.engine → type in com.paddle.ocr.model) reference.
mcp_server.paddleocr_mcp.inference.base uses mcp_server.paddleocr_mcp.inference.shared.input_adapters. Changing mcp_server.paddleocr_mcp.inference.shared.input_adapters can break mcp_server.paddleocr_mcp.inference.base, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
17→5 mcp_server.paddleocr_mcp.inference.base depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.base → type in mcp_server.paddleocr_mcp.inference.types) reference.
mcp_server.paddleocr_mcp.inference.base uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.base, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
18→5 mcp_server.paddleocr_mcp.inference.shared depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
3 distinct (type in mcp_server.paddleocr_mcp.inference.shared → type in mcp_server.paddleocr_mcp.inference.types) references.
mcp_server.paddleocr_mcp.inference.shared uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.shared, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
19→6 paddleocr-js.packages.core.src.models.det depends on paddleocr-js.packages.core.src.runtime.ort✕
Type pairs
1 distinct (type in paddleocr-js.packages.core.src.models.det → type in paddleocr-js.packages.core.src.runtime.ort) reference.
paddleocr-js.packages.core.src.models.det uses paddleocr-js.packages.core.src.runtime.ort. Changing paddleocr-js.packages.core.src.runtime.ort can break paddleocr-js.packages.core.src.models.det, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
20→6 paddleocr-js.packages.core.src.models.rec depends on paddleocr-js.packages.core.src.runtime.ort✕
Type pairs
1 distinct (type in paddleocr-js.packages.core.src.models.rec → type in paddleocr-js.packages.core.src.runtime.ort) reference.
paddleocr-js.packages.core.src.models.rec uses paddleocr-js.packages.core.src.runtime.ort. Changing paddleocr-js.packages.core.src.runtime.ort can break paddleocr-js.packages.core.src.models.rec, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
21→11 paddleocr._models._image_classification depends on paddleocr._models.base✕
Type pairs
2 distinct (type in paddleocr._models._image_classification → type in paddleocr._models.base) references.
paddleocr._models._image_classification uses paddleocr._models.base. Changing paddleocr._models.base can break paddleocr._models._image_classification, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
22→1 api_sdk.typescript.src.client depends on api_sdk.typescript.src.internal.http✕
Type pairs
1 distinct (type in api_sdk.typescript.src.client → type in api_sdk.typescript.src.internal.http) reference.
api_sdk.typescript.src.client uses api_sdk.typescript.src.internal.http. Changing api_sdk.typescript.src.internal.http can break api_sdk.typescript.src.client, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
22→2 api_sdk.typescript.src.client depends on api_sdk.typescript.src.results✕
Type pairs
5 distinct (type in api_sdk.typescript.src.client → type in api_sdk.typescript.src.results) references.
api_sdk.typescript.src.client uses api_sdk.typescript.src.results. Changing api_sdk.typescript.src.results can break api_sdk.typescript.src.client, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
22→14 api_sdk.typescript.src.client depends on api_sdk.typescript.src.internal.poller✕
Type pairs
1 distinct (type in api_sdk.typescript.src.client → type in api_sdk.typescript.src.internal.poller) reference.
api_sdk.typescript.src.client uses api_sdk.typescript.src.internal.poller. Changing api_sdk.typescript.src.internal.poller can break api_sdk.typescript.src.client, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
23→3 com.paddle.ocr depends on com.paddle.ocr.model✕
Type pairs
1 distinct (type in com.paddle.ocr → type in com.paddle.ocr.model) reference.
com.paddle.ocr.demo.ui.viewmodel uses com.paddle.ocr.demo.OCRApplication. Changing com.paddle.ocr.demo.OCRApplication can break com.paddle.ocr.demo.ui.viewmodel, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
25→4 mcp_server.paddleocr_mcp.inference.ocr.aistudio depends on mcp_server.paddleocr_mcp.inference.shared.input_adapters✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.ocr.aistudio → type in mcp_server.paddleocr_mcp.inference.shared.input_adapters) reference.
mcp_server.paddleocr_mcp.inference.ocr.aistudio uses mcp_server.paddleocr_mcp.inference.shared.input_adapters. Changing mcp_server.paddleocr_mcp.inference.shared.input_adapters can break mcp_server.paddleocr_mcp.inference.ocr.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
25→5 mcp_server.paddleocr_mcp.inference.ocr.aistudio depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
2 distinct (type in mcp_server.paddleocr_mcp.inference.ocr.aistudio → type in mcp_server.paddleocr_mcp.inference.types) references.
mcp_server.paddleocr_mcp.inference.ocr.aistudio uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.ocr.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
25→17 mcp_server.paddleocr_mcp.inference.ocr.aistudio depends on mcp_server.paddleocr_mcp.inference.base✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.ocr.aistudio → type in mcp_server.paddleocr_mcp.inference.base) reference.
mcp_server.paddleocr_mcp.inference.ocr.aistudio uses mcp_server.paddleocr_mcp.inference.base. Changing mcp_server.paddleocr_mcp.inference.base can break mcp_server.paddleocr_mcp.inference.ocr.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
26→4 mcp_server.paddleocr_mcp.inference.ocr.local depends on mcp_server.paddleocr_mcp.inference.shared.input_adapters✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.ocr.local → type in mcp_server.paddleocr_mcp.inference.shared.input_adapters) reference.
mcp_server.paddleocr_mcp.inference.ocr.local uses mcp_server.paddleocr_mcp.inference.shared.input_adapters. Changing mcp_server.paddleocr_mcp.inference.shared.input_adapters can break mcp_server.paddleocr_mcp.inference.ocr.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
26→5 mcp_server.paddleocr_mcp.inference.ocr.local depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
2 distinct (type in mcp_server.paddleocr_mcp.inference.ocr.local → type in mcp_server.paddleocr_mcp.inference.types) references.
mcp_server.paddleocr_mcp.inference.ocr.local uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.ocr.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
26→17 mcp_server.paddleocr_mcp.inference.ocr.local depends on mcp_server.paddleocr_mcp.inference.base✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.ocr.local → type in mcp_server.paddleocr_mcp.inference.base) reference.
mcp_server.paddleocr_mcp.inference.ocr.local uses mcp_server.paddleocr_mcp.inference.base. Changing mcp_server.paddleocr_mcp.inference.base can break mcp_server.paddleocr_mcp.inference.ocr.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
27→4 mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio depends on mcp_server.paddleocr_mcp.inference.shared.input_adapters✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio → type in mcp_server.paddleocr_mcp.inference.shared.input_adapters) reference.
mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio uses mcp_server.paddleocr_mcp.inference.shared.input_adapters. Changing mcp_server.paddleocr_mcp.inference.shared.input_adapters can break mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
27→5 mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
2 distinct (type in mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio → type in mcp_server.paddleocr_mcp.inference.types) references.
mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
27→17 mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio depends on mcp_server.paddleocr_mcp.inference.base✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio → type in mcp_server.paddleocr_mcp.inference.base) reference.
mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio uses mcp_server.paddleocr_mcp.inference.base. Changing mcp_server.paddleocr_mcp.inference.base can break mcp_server.paddleocr_mcp.inference.paddleocr_vl.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
28→4 mcp_server.paddleocr_mcp.inference.paddleocr_vl.local depends on mcp_server.paddleocr_mcp.inference.shared.input_adapters✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.paddleocr_vl.local → type in mcp_server.paddleocr_mcp.inference.shared.input_adapters) reference.
mcp_server.paddleocr_mcp.inference.paddleocr_vl.local uses mcp_server.paddleocr_mcp.inference.shared.input_adapters. Changing mcp_server.paddleocr_mcp.inference.shared.input_adapters can break mcp_server.paddleocr_mcp.inference.paddleocr_vl.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
28→5 mcp_server.paddleocr_mcp.inference.paddleocr_vl.local depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
2 distinct (type in mcp_server.paddleocr_mcp.inference.paddleocr_vl.local → type in mcp_server.paddleocr_mcp.inference.types) references.
mcp_server.paddleocr_mcp.inference.paddleocr_vl.local uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.paddleocr_vl.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
28→17 mcp_server.paddleocr_mcp.inference.paddleocr_vl.local depends on mcp_server.paddleocr_mcp.inference.base✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.paddleocr_vl.local → type in mcp_server.paddleocr_mcp.inference.base) reference.
mcp_server.paddleocr_mcp.inference.paddleocr_vl.local uses mcp_server.paddleocr_mcp.inference.base. Changing mcp_server.paddleocr_mcp.inference.base can break mcp_server.paddleocr_mcp.inference.paddleocr_vl.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
29→4 mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio depends on mcp_server.paddleocr_mcp.inference.shared.input_adapters✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio → type in mcp_server.paddleocr_mcp.inference.shared.input_adapters) reference.
mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio uses mcp_server.paddleocr_mcp.inference.shared.input_adapters. Changing mcp_server.paddleocr_mcp.inference.shared.input_adapters can break mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
29→5 mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
2 distinct (type in mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio → type in mcp_server.paddleocr_mcp.inference.types) references.
mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
29→17 mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio depends on mcp_server.paddleocr_mcp.inference.base✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio → type in mcp_server.paddleocr_mcp.inference.base) reference.
mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio uses mcp_server.paddleocr_mcp.inference.base. Changing mcp_server.paddleocr_mcp.inference.base can break mcp_server.paddleocr_mcp.inference.pp_structurev3.aistudio, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
30→4 mcp_server.paddleocr_mcp.inference.pp_structurev3.local depends on mcp_server.paddleocr_mcp.inference.shared.input_adapters✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.pp_structurev3.local → type in mcp_server.paddleocr_mcp.inference.shared.input_adapters) reference.
mcp_server.paddleocr_mcp.inference.pp_structurev3.local uses mcp_server.paddleocr_mcp.inference.shared.input_adapters. Changing mcp_server.paddleocr_mcp.inference.shared.input_adapters can break mcp_server.paddleocr_mcp.inference.pp_structurev3.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
30→5 mcp_server.paddleocr_mcp.inference.pp_structurev3.local depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
2 distinct (type in mcp_server.paddleocr_mcp.inference.pp_structurev3.local → type in mcp_server.paddleocr_mcp.inference.types) references.
mcp_server.paddleocr_mcp.inference.pp_structurev3.local uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.pp_structurev3.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
30→17 mcp_server.paddleocr_mcp.inference.pp_structurev3.local depends on mcp_server.paddleocr_mcp.inference.base✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.pp_structurev3.local → type in mcp_server.paddleocr_mcp.inference.base) reference.
mcp_server.paddleocr_mcp.inference.pp_structurev3.local uses mcp_server.paddleocr_mcp.inference.base. Changing mcp_server.paddleocr_mcp.inference.base can break mcp_server.paddleocr_mcp.inference.pp_structurev3.local, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
31→4 mcp_server.paddleocr_mcp.inference.shared.http_base depends on mcp_server.paddleocr_mcp.inference.shared.input_adapters✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.shared.http_base → type in mcp_server.paddleocr_mcp.inference.shared.input_adapters) reference.
mcp_server.paddleocr_mcp.inference.shared.http_base uses mcp_server.paddleocr_mcp.inference.shared.input_adapters. Changing mcp_server.paddleocr_mcp.inference.shared.input_adapters can break mcp_server.paddleocr_mcp.inference.shared.http_base, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
31→5 mcp_server.paddleocr_mcp.inference.shared.http_base depends on mcp_server.paddleocr_mcp.inference.types✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.shared.http_base → type in mcp_server.paddleocr_mcp.inference.types) reference.
mcp_server.paddleocr_mcp.inference.shared.http_base uses mcp_server.paddleocr_mcp.inference.types. Changing mcp_server.paddleocr_mcp.inference.types can break mcp_server.paddleocr_mcp.inference.shared.http_base, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
31→17 mcp_server.paddleocr_mcp.inference.shared.http_base depends on mcp_server.paddleocr_mcp.inference.base✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.inference.shared.http_base → type in mcp_server.paddleocr_mcp.inference.base) reference.
mcp_server.paddleocr_mcp.inference.shared.http_base uses mcp_server.paddleocr_mcp.inference.base. Changing mcp_server.paddleocr_mcp.inference.base can break mcp_server.paddleocr_mcp.inference.shared.http_base, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
32→17 mcp_server.paddleocr_mcp.tasks.base depends on mcp_server.paddleocr_mcp.inference.base✕
Type pairs
1 distinct (type in mcp_server.paddleocr_mcp.tasks.base → type in mcp_server.paddleocr_mcp.inference.base) reference.
mcp_server.paddleocr_mcp.tasks.base uses mcp_server.paddleocr_mcp.inference.base. Changing mcp_server.paddleocr_mcp.inference.base can break mcp_server.paddleocr_mcp.tasks.base, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
33→6 paddleocr-js.packages.core.src.models depends on paddleocr-js.packages.core.src.runtime.ort✕
Type pairs
4 distinct (type in paddleocr-js.packages.core.src.models → type in paddleocr-js.packages.core.src.runtime.ort) references.
paddleocr-js.packages.core.src.models uses paddleocr-js.packages.core.src.runtime.ort. Changing paddleocr-js.packages.core.src.runtime.ort can break paddleocr-js.packages.core.src.models, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
33→19 paddleocr-js.packages.core.src.models depends on paddleocr-js.packages.core.src.models.det✕
Type pairs
9 distinct (type in paddleocr-js.packages.core.src.models → type in paddleocr-js.packages.core.src.models.det) references.
paddleocr-js.packages.core.src.models uses paddleocr-js.packages.core.src.models.det. Changing paddleocr-js.packages.core.src.models.det can break paddleocr-js.packages.core.src.models, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
33→20 paddleocr-js.packages.core.src.models depends on paddleocr-js.packages.core.src.models.rec✕
Type pairs
4 distinct (type in paddleocr-js.packages.core.src.models → type in paddleocr-js.packages.core.src.models.rec) references.
paddleocr-js.packages.core.src.models uses paddleocr-js.packages.core.src.models.rec. Changing paddleocr-js.packages.core.src.models.rec can break paddleocr-js.packages.core.src.models, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
34→19 paddleocr-js.packages.core.src.pipelines.ocr.config depends on paddleocr-js.packages.core.src.models.det✕
Type pairs
1 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr.config → type in paddleocr-js.packages.core.src.models.det) reference.
paddleocr-js.packages.core.src.pipelines.ocr.config uses paddleocr-js.packages.core.src.models.det. Changing paddleocr-js.packages.core.src.models.det can break paddleocr-js.packages.core.src.pipelines.ocr.config, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
35→19 paddleocr-js.packages.core.src.pipelines.ocr.runtime-params depends on paddleocr-js.packages.core.src.models.det✕
Type pairs
3 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr.runtime-params → type in paddleocr-js.packages.core.src.models.det) references.
paddleocr-js.packages.core.src.pipelines.ocr.runtime-params uses paddleocr-js.packages.core.src.models.det. Changing paddleocr-js.packages.core.src.models.det can break paddleocr-js.packages.core.src.pipelines.ocr.runtime-params, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
35→20 paddleocr-js.packages.core.src.pipelines.ocr.runtime-params depends on paddleocr-js.packages.core.src.models.rec✕
Type pairs
1 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr.runtime-params → type in paddleocr-js.packages.core.src.models.rec) reference.
paddleocr-js.packages.core.src.pipelines.ocr.runtime-params uses paddleocr-js.packages.core.src.models.rec. Changing paddleocr-js.packages.core.src.models.rec can break paddleocr-js.packages.core.src.pipelines.ocr.runtime-params, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
36→15 com.paddle.ocr.demo depends on com.paddle.ocr.demo.OCRApplication✕
Type pairs
1 distinct (type in com.paddle.ocr.demo → type in com.paddle.ocr.demo.OCRApplication) reference.
com.paddle.ocr.demo uses com.paddle.ocr.demo.OCRApplication. Changing com.paddle.ocr.demo.OCRApplication can break com.paddle.ocr.demo, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
36→23 com.paddle.ocr.demo depends on com.paddle.ocr✕
Type pairs
1 distinct (type in com.paddle.ocr.demo → type in com.paddle.ocr) reference.
paddleocr-js.packages.core.src.pipelines.ocr.core uses paddleocr-js.packages.core.src.runtime.ort. Changing paddleocr-js.packages.core.src.runtime.ort can break paddleocr-js.packages.core.src.pipelines.ocr.core, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
37→34 paddleocr-js.packages.core.src.pipelines.ocr.core depends on paddleocr-js.packages.core.src.pipelines.ocr.config✕
Type pairs
2 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr.core → type in paddleocr-js.packages.core.src.pipelines.ocr.config) references.
paddleocr-js.packages.core.src.pipelines.ocr.core uses paddleocr-js.packages.core.src.pipelines.ocr.config. Changing paddleocr-js.packages.core.src.pipelines.ocr.config can break paddleocr-js.packages.core.src.pipelines.ocr.core, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
37→35 paddleocr-js.packages.core.src.pipelines.ocr.core depends on paddleocr-js.packages.core.src.pipelines.ocr.runtime-params✕
Type pairs
2 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr.core → type in paddleocr-js.packages.core.src.pipelines.ocr.runtime-params) references.
paddleocr-js.packages.core.src.pipelines.ocr.core uses paddleocr-js.packages.core.src.pipelines.ocr.runtime-params. Changing paddleocr-js.packages.core.src.pipelines.ocr.runtime-params can break paddleocr-js.packages.core.src.pipelines.ocr.core, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
38→35 paddleocr-js.packages.core.src.pipelines.ocr.worker-backed depends on paddleocr-js.packages.core.src.pipelines.ocr.runtime-params✕
Type pairs
2 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr.worker-backed → type in paddleocr-js.packages.core.src.pipelines.ocr.runtime-params) references.
paddleocr-js.packages.core.src.pipelines.ocr.worker-backed uses paddleocr-js.packages.core.src.pipelines.ocr.runtime-params. Changing paddleocr-js.packages.core.src.pipelines.ocr.runtime-params can break paddleocr-js.packages.core.src.pipelines.ocr.worker-backed, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
38→37 paddleocr-js.packages.core.src.pipelines.ocr.worker-backed depends on paddleocr-js.packages.core.src.pipelines.ocr.core✕
Type pairs
2 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr.worker-backed → type in paddleocr-js.packages.core.src.pipelines.ocr.core) references.
paddleocr-js.packages.core.src.pipelines.ocr.worker-backed uses paddleocr-js.packages.core.src.pipelines.ocr.core. Changing paddleocr-js.packages.core.src.pipelines.ocr.core can break paddleocr-js.packages.core.src.pipelines.ocr.worker-backed, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
39→7 paddleocr-js.packages.core.src.viz.ocr depends on paddleocr-js.packages.core.src.viz.ocr.types✕
Type pairs
3 distinct (type in paddleocr-js.packages.core.src.viz.ocr → type in paddleocr-js.packages.core.src.viz.ocr.types) references.
paddleocr-js.packages.core.src.viz.ocr uses paddleocr-js.packages.core.src.viz.ocr.types. Changing paddleocr-js.packages.core.src.viz.ocr.types can break paddleocr-js.packages.core.src.viz.ocr, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
39→37 paddleocr-js.packages.core.src.viz.ocr depends on paddleocr-js.packages.core.src.pipelines.ocr.core✕
Type pairs
2 distinct (type in paddleocr-js.packages.core.src.viz.ocr → type in paddleocr-js.packages.core.src.pipelines.ocr.core) references.
paddleocr-js.packages.core.src.viz.ocr uses paddleocr-js.packages.core.src.pipelines.ocr.core. Changing paddleocr-js.packages.core.src.pipelines.ocr.core can break paddleocr-js.packages.core.src.viz.ocr, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→6 paddleocr-js.packages.core.src.pipelines.ocr depends on paddleocr-js.packages.core.src.runtime.ort✕
Type pairs
2 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr → type in paddleocr-js.packages.core.src.runtime.ort) references.
paddleocr-js.packages.core.src.pipelines.ocr uses paddleocr-js.packages.core.src.runtime.ort. Changing paddleocr-js.packages.core.src.runtime.ort can break paddleocr-js.packages.core.src.pipelines.ocr, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→19 paddleocr-js.packages.core.src.pipelines.ocr depends on paddleocr-js.packages.core.src.models.det✕
Type pairs
1 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr → type in paddleocr-js.packages.core.src.models.det) reference.
paddleocr-js.packages.core.src.pipelines.ocr uses paddleocr-js.packages.core.src.models.det. Changing paddleocr-js.packages.core.src.models.det can break paddleocr-js.packages.core.src.pipelines.ocr, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→34 paddleocr-js.packages.core.src.pipelines.ocr depends on paddleocr-js.packages.core.src.pipelines.ocr.config✕
Type pairs
5 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr → type in paddleocr-js.packages.core.src.pipelines.ocr.config) references.
paddleocr-js.packages.core.src.pipelines.ocr uses paddleocr-js.packages.core.src.pipelines.ocr.config. Changing paddleocr-js.packages.core.src.pipelines.ocr.config can break paddleocr-js.packages.core.src.pipelines.ocr, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→35 paddleocr-js.packages.core.src.pipelines.ocr depends on paddleocr-js.packages.core.src.pipelines.ocr.runtime-params✕
Type pairs
4 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr → type in paddleocr-js.packages.core.src.pipelines.ocr.runtime-params) references.
paddleocr-js.packages.core.src.pipelines.ocr uses paddleocr-js.packages.core.src.pipelines.ocr.runtime-params. Changing paddleocr-js.packages.core.src.pipelines.ocr.runtime-params can break paddleocr-js.packages.core.src.pipelines.ocr, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→37 paddleocr-js.packages.core.src.pipelines.ocr depends on paddleocr-js.packages.core.src.pipelines.ocr.core✕
Type pairs
3 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr → type in paddleocr-js.packages.core.src.pipelines.ocr.core) references.
paddleocr-js.packages.core.src.pipelines.ocr uses paddleocr-js.packages.core.src.pipelines.ocr.core. Changing paddleocr-js.packages.core.src.pipelines.ocr.core can break paddleocr-js.packages.core.src.pipelines.ocr, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→38 paddleocr-js.packages.core.src.pipelines.ocr depends on paddleocr-js.packages.core.src.pipelines.ocr.worker-backed✕
Type pairs
1 distinct (type in paddleocr-js.packages.core.src.pipelines.ocr → type in paddleocr-js.packages.core.src.pipelines.ocr.worker-backed) reference.
paddleocr-js.packages.core.src.pipelines.ocr uses paddleocr-js.packages.core.src.pipelines.ocr.worker-backed. Changing paddleocr-js.packages.core.src.pipelines.ocr.worker-backed can break paddleocr-js.packages.core.src.pipelines.ocr, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
At a glance — Code Health · 85% · Adequate · gated by D2 ·
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A03:2021 — Injection
407
High / Critical
A05:2021 — Security Misconfiguration
101
High / Critical
A06:2021 — Vulnerable & Outdated Components
36
High / Critical
Roadmap
First, harden the web security posture by pinning third-party scripts with integrity hashes and restricting dynamic loaders via Content Security Policy, while vendoring assets where possible. Next, resolve the 293 static analysis findings in shell scripts and the 66 medium-severity IaC issues in Dockerfiles to eliminate known vulnerabilities. Then, integrate a SAST step into the CI pipeline to automatically block security regressions before they are merged. Finally, maintain a changelog to ensure clear release hygiene and traceability.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Pin third-party scripts and verify them: name an exact version in the URL and add an `integrity="sha384-…"` hash alongside `crossorigin="anonymous"` (both are required — an integrity hash on a cross-origin script without `crossorigin` is not evaluated, it blocks the script). Where the vendor ships a continuously-updated loader and publishes no stable hash (tag managers, analytics, chat widgets), Subresource Integrity is not available: constrain it instead with a `Content-Security-Policy` that names the exact origins allowed to execute, and drop the script from the pages that do not need it. Where the page is shipped inside a package that others host, prefer vendoring the asset and serving it from the app’s own origin, so no consumer inherits a third-party dependency they did not choose.
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.
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 — 427
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 — 947
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 — 39
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 42
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. 41 of 44 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 3 documentation/naming judgement(s) are LLM-assisted and labelled advisory. Overall confidence is 0.9 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.
Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.
What we checked — 44 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, 1401 of 1413 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D8 Code Coverage — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: this repository's production source spans .py, and our analyzer cannot run the .py test suite(s) — so no coverage was collected for the repository as a whole. The JavaScript/TypeScript half did build and run, and its own line coverage came back at 90.7% — but that is a figure for one half of the product, and we do not publish a partial one as if it were complete. This is OUR limitation, not a defect in the repo — coverage is excluded from the score rather than counted as a near-zero. In the meantime, produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures and real coverage will be read. You can widen what we reach: optional: produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures — then both halves are read on the next scan.
D10 Test Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 219 test(s) behind this row are the ones the code-model census could read, and this repository also carries at least 53 test source file(s) (.py) that it cannot: it reads the test types the frontend declared, so a suite in any other language 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.
D12 Dependency Hygiene — 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. Dependency Hygiene ran out of its 5-minute budget before it had finished, so what it reports here is a floor rather than a complete count. The rows above are real and stand; what is not known is how many more there are. This is a limit of the analysis run, not a finding about this repository.
D14 License Compliance — evaluation did not complete — License Compliance not included (check did not complete) — excluded from the score.
D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22 identifies the intentionally-exposed surface from `IsPackable` and `.Contracts` project names, MSBuild conventions read off the loaded project set. This target exposed no such projects, so the probe never ran; this says nothing about whether the repository has a public API. This repository commits no C#/VB source at all, so there was never an MSBuild project set to read these conventions off. That is OUR side and it is a COLLECTOR gap, not an environment fault: it declares a published package (setup.py), but no published-package marker D22 reads admitted any project here, so this ecosystem's public API has no collector, and the remedy is to write one — no change to the scan image can close it.
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. `paddleocr-js/packages/core/src/runtime/ort.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.
AX3 Project dependency cycles — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over which project references which. That is a language-neutral question, but the project-reference graph is collected from MSBuild .csproj files only, and this repository commits none — so there was no graph to read, and re-running the same commit reads the same nothing. Its modules are declared as: npm/pnpm/yarn packages and workspaces (package.json, pnpm-workspace.yaml, lerna.json); Go modules (REDACTED, go.work); Gradle projects (settings.gradle, build.gradle); Python distributions (pyproject.toml, setup.py, setup.cfg); CMake targets (CMakeLists.txt). A reader for that graph is the collector this check is missing. That is a COLLECTOR gap in this analyzer — no change to the scan image closes it — and not a finding that the repository is free of what this check looks for.
AX4 Dependency direction — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over the direction each project reference points. That is a language-neutral question, but the project-reference graph is collected from MSBuild .csproj files only, and this repository commits none — so there was no graph to read, and re-running the same commit reads the same nothing. Its modules are declared as: npm/pnpm/yarn packages and workspaces (package.json, pnpm-workspace.yaml, lerna.json); Go modules (REDACTED, go.work); Gradle projects (settings.gradle, build.gradle); Python distributions (pyproject.toml, setup.py, setup.cfg); CMake targets (CMakeLists.txt). A reader for that graph is the collector this check is missing. That is a COLLECTOR gap in this analyzer — no change to the scan image closes it — and not a finding that the repository is free of what this check looks for.
AX6 Interface segregation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
AX8 Test isolation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over which projects are test projects, and what they reference. That is a language-neutral question, but the project-reference graph is collected from MSBuild .csproj files only, and this repository commits none — so there was no graph to read, and re-running the same commit reads the same nothing. Its modules are declared as: npm/pnpm/yarn packages and workspaces (package.json, pnpm-workspace.yaml, lerna.json); Go modules (REDACTED, go.work); Gradle projects (settings.gradle, build.gradle); Python distributions (pyproject.toml, setup.py, setup.cfg); CMake targets (CMakeLists.txt). A reader for that graph is the collector this check is missing. That is a COLLECTOR gap in this analyzer — no change to the scan image closes it — and not a finding that the repository is free of what this check looks for.
C1 Data Protection — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
C2 Access Controls — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These authorization controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks authorization controls.
C3 Audit Trail — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These audit controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks audit controls.
C4 Data Retention — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These retention controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks retention controls.
C5 Data-Subject Rights — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These data-subject rights controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks data-subject rights controls.
ED5 Idempotency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check finds retry-prone mutations by walking the repository's declared types, and NONE was loaded on this run, so it had nothing to look at. That is a limit of the analyzer's reach — it reads .NET projects — not a finding that this repository has no command handlers or message consumers.
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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X1 Async correctness — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X12 Unreachable branch — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X13 Undrained process stream — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X14 Bypassable address classification — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X15 Unvalidated length from an untrusted reader — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X16 Unfloored truncation loop — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X17 Uncapped recursion over a caller-supplied document — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X18 Disposal-pattern correctness — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X19 Unrestored process-global state — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X2 Cancellation propagation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X20 Mistyped argument guard — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X21 Side-effecting pattern guard — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X22 Contradicted release guard — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X23 Unguarded diagnostic materialisation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X24 Document value interpolated into markup unescaped — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X25 Inert configuration knob — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X26 Unsynchronised callback handoff — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X27 Collection changed while being enumerated — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X28 Index access outside its own emptiness guard — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X29 Per-element action decided by a fixed element — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X3 Exception handling — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X30 Support guard that admits what it rejects — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X32 Type resolved by simple name across every loaded assembly — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X4 Structured logging — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X5 Nullable reference types — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
Repo exclusion declarations: 5 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.
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.
D11 Test Reliability: Flakiness is inferred from history/markers — Watchdog runs the suite once (for coverage), not the repeated runs under varied conditions that reveal nondeterminism, so a flaky test never recorded as failing is invisible here.
D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D19 Documentation Quality: Documentation quality is judged by an LLM over a bounded sample of docs — it reads what is written, not whether the docs match the running system, and it is advisory, not a measurement. Its critique rows are drawn from a closed category vocabulary and each row means the same thing in every run, so two scans can be compared row by row; the SET that fires is still a sample, and does not repeat exactly. Measured on one frozen input, six scans at one engine SHA: 2-5 critique rows per scan, 8 distinct rows across the six, 3 of those 8 seen in only one scan. So a D19 row is evidence about the documentation, but a COUNT of D19 rows is not a quantity — never read a change in it as an improvement or a regression.
D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
D21 Naming Consistency: Naming quality is an LLM judgement over a bounded sample — it assesses clarity/consistency of the names it sees, not domain-correctness, and is advisory.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (REDACTED, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
The LLM boundary
LLM-set scores this run (3): D19, D21, M4 (model: Local LLM). For these, a model reads a bounded sample and sets the numeric score; each names its own sample and method on its card. They are sampled and advisory by design: they vary at the margins between runs and are never a deterministic measurement. Every other score in this report is tool-computed at confidence 1.0.
What it measures: How tangled the control flow is — methods with many branches are hard to test and change.
Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.
+ 69 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 program.train (cyclomatic 79) finding(s) in Cyclomatic Complexity — start with program.py. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 utility.create_predictor (cyclomatic 60) finding(s) in Cyclomatic Complexity — start with utility.py. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 CustomMBartDecoder.forward (cyclomatic 55) finding(s) in Cyclomatic Complexity — start with rec_unimernet_head.py. — One of this dimension's main actionable groups (1 warning-level).
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.
+ 166 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 2 DistillationKLDivLoss.forward (cognitive 31) finding(s) in Cognitive Complexity — start with distillation_loss.py (2). — One of this dimension's main actionable groups (2 warning-level).
Resolve the 2 DistillationDKDLoss.forward (cognitive 31) finding(s) in Cognitive Complexity — start with distillation_loss.py (2). — One of this dimension's main actionable groups (2 warning-level).
Resolve the 1 program.train (cognitive 173) finding(s) in Cognitive Complexity — start with program.py. — One of this dimension's main actionable groups (1 warning-level).
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.9 / 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 26 FileTooLong finding(s) in God Classes — start with rec_unimernet_head.py, REDACTED, docx.py. — One of this dimension's main actionable groups (26 warning-level).
Resolve the 2 TooManyFields finding(s) in God Classes — start with models.go (2). — One of this dimension's main actionable groups (2 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.
472 duplicated block group(s) detected. A further 49 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 52 of the 521 are in trees this repository does not ship — vendored, example/demo, 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.
+ 208 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 25 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with extract_textpoint_fast.py (2), collate_fn.py, abinet_aug.py. — One of this dimension's main actionable groups (25 warning-level).
Resolve the 21 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with pg_process.py (2), fce_aug.py (2), latex_ocr_aug.py. — One of this dimension's main actionable groups (21 warning-level).
Resolve the 19 Duplicated block (7 lines × 2) finding(s) in Code Duplication — start with pg_process.py (2), rec_ppformulanet_head.py (2), extract_textpoint_fast.py (2). — One of this dimension's main actionable groups (19 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?
D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.
Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.
370 test methods: 370 unit, 0 integration, 0 BDD, 0 e2e. The JavaScript/TypeScript suite contributes 219 `it`/`test` case(s) across 35 test file(s) declaring at least one beside 11 .NET test method(s); its tier split is read from package names and paths only. The Python suite contributes 135 test function(s) across 38 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only. The Go suite contributes 5 test case(s) across 1 `_test.go` file(s) declaring at least one — every `func Test…(t *testing.T)` that `go test` would collect, plus the suite methods a testify-style runner reaches; a table-driven case list counts once, so this is a floor. Its tier split is INFERRED from file names, paths and build constraints, not declared: 0 of those file(s) use Go's external test package (`package x_test`), which is a visibility boundary rather than a pyramid tier and was not read as one.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality9.9 / 10Stronggated by 1 serious finding✓ 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, 1 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 219 tests. Measured on the suite only — at least 53 test source file(s) (.py) went unread, so its test quality is unmeasured and is not in these counts.
No assertions: dispose() is safe to call multiple timespaddleocr-js/packages/core/test/viz-renderer.test.ts:44
What to do
Resolve the 1 No assertions finding(s) in Test Quality — start with viz-renderer.test.ts. — One of this dimension's main actionable groups (1 warning-level).
Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D11 · Test Reliability10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether the tests pass reliably, with no flakiness.
Method: Suite re-run N times within tiered wall-clock budgets (unit to e2e); tests failing non-deterministically across runs flagged; guarded tests retried when #if guards detected.
0 flaky across 2 measured tier(s). JavaScript/TypeScript (vitest via `npm ci --ignore-scripts` in api_sdk/typescript/ (41 tests); vitest via `npm ci --ignore-scripts` in paddleocr-js/ (185 tests)): measured (0 flaky); Python (2 distributions): measured (0 flaky).
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
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.
5 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is paddleocr/_doc2md/converters/docx.py. Counted over 433 of the 678 production source files in this repository: 243 are under the ~2,400-byte size floor this dimension measures over, and the remaining 2 have no attributable history left to measure.
Off-boarding risk: anonymized user #1
Further sole-owners (lower concentration)
✓ On the Gold path — maintain.
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.
Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.
33 deducted task-comment markers across 116925 LoC (0.0/KLoC) → score 9.9. 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.
Resolve the 27 TodoComment finding(s) in Explicit Debt — start with REDACTED (3), test_formula_recognition.py (3), collate_fn.py (2). — One of this dimension's main actionable groups (27 warning-level).
Resolve the 2 HackComment finding(s) in Explicit Debt — start with pp_doctranslation.py, utility.py. — One of this dimension's main actionable groups (2 warning-level).
Resolve the 2 FixmeComment finding(s) in Explicit Debt — start with pp_doctranslation.py, pp_chatocrv4_doc.py. — One of this dimension's main actionable groups (2 warning-level).
Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic doc sample (READMEs plus first 25 architecture docs), with two-pass stability filtering. Advisory, sampled.
This is a comprehensive PaddleOCR documentation set that covers both high-level project description (Global Leading OCR Toolkit & Document AI Engine) and detailed technical content across multiple documents: the README for each major component (e.g. TIPC training-inference pipeline, PP-Structure upgrade considerations, PaddleOCR.js SDK, MCP server, langchain-paddleocr), a dedicated deployment guide with multi-deployment options, benchmarking documentation, and an extensive Table Recognition section that includes a flowchart, performance table, and detailed usage steps for each model. The architecture/design docs are also present (e.g. PP-Structure upgrade considerations). The documentation is comprehensive and well-structured: the README files alone at 39+ architecture/Docs markdown files (total ~400) cover every section of a project that could be named, with an outline for each document. The layout-recovery module's README has a clear 'Layout Recovery' table of contents; PDF2Word covers installation, script run modes, QPT packaging, and licensing; the layout-analysis README is split into install, quick start, data prep, training, evaluation, export, and more; KIE includes an introduction, performance, visualization (SER/RE), usage with environment setup, model download, inference, and license; 2.x branch version notes and Android/PaddleCloud deployment are present. The prose is mostly descriptive rather than prescriptive but the outline covers all content present.
Documentation: no project overview · ×2README.md
✓ On the Gold path — maintain.
Detailed fixes: d19_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.
What it measures: Whether names — types, methods, variables — are clear and consistent.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic random symbol sample (fixed size, not exhaustive), with disclosed confidence band. Advisory, sampled.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
407 finding(s): 0 critical, 388 high, 15 medium, 4 low. 26 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 6 file(s) — `deploy/cpp_infer/src/pipelines/ocr/result.h` (line 26), `deploy/ios_demo/scripts/run_benchmark.sh` (line 787), `deploy/paddleocr_vl_docker/build_pipeline.sh` (line 206), `deploy/paddleocr_vl_docker/build_vlm.sh` (line 226), `REDACTED` (lines 1–4, line 8), … (+1 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 2 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
+ 6 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 293 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (282), REDACTED (4), REDACTED (3). — One of this dimension's main actionable groups (293 issue-level).
Resolve the 58 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (19), REDACTED (8), REDACTED (5). — One of this dimension's main actionable groups (58 issue-level).
No action in Static Analysis (SAST) — all 26 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 (26 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/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, Go, Java and Kotlin via Maven/Gradle, npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05.
+ 1 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 18 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (11), REDACTED (7). — One of this dimension's main actionable groups (18 issue-level).
Resolve the 3 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (2), REDACTED. — One of this dimension's main actionable groups (3 issue-level).
Resolve the 1 High vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
Resolve the 66 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (30), REDACTED (30), REDACTED (4). — One of this dimension's main actionable groups (66 warning-level).
Resolve the 17 High IaC finding(s) in IaC & Container Security — start with REDACTED (12), REDACTED (2), REDACTED. — One of this dimension's main actionable groups (17 issue-level).
Resolve the 18 Low IaC finding(s) in IaC & Container Security — start with REDACTED (9), REDACTED (8), REDACTED. — One of this dimension's main actionable groups (18 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.
318 of 435 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is REDACTED. Counted over 435 of the 678 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Most significant orphaned file · ×3REDACTED
Concentrated knowledge decay
What to do
Resolve the 3 Most significant orphaned file finding(s) in Knowledge Freshness — start with REDACTED, rec_ppformulanet_head.py, rec_donut_swin.py. — One of this dimension's main actionable groups (3 recommendation-level).
Resolve the 1 Concentrated knowledge decay finding(s) in Knowledge Freshness. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Resolve the 1 Change coupling clique finding(s) in Change Coupling — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 Change coupling finding(s) in Change Coupling — start with recovery_to_doc.py. — 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.
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 41 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, 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.
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 read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.
Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.
Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.
Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.
Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.
What to do
Add a 'Testing' section to the root README — how to run the test suite.
Add a README to the 4 of 12 project(s) that lack one — worth up to 0.7 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 significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree, with each file named `NNNN-title` in whatever markup those docs already use, is the most discoverable form).
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 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 18780 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`, `gomod`, `pip`, `gradle` — add those `package-ecosystem` entries 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.
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.
Do you agree with this assessment?
R1 · Type Safety9.9 / 10Exemplary✓ Tool-verified
React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.
Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.
What to do
Migrate the remaining .js/.jsx files to TypeScript.
React / JS · Code Health — Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm over JS/TS tokens, D-386): a block is reported only where its copies still agree on most of their own identifiers and literals, or were renamed as they were pasted but kept most of their constants, and where the copies carry enough code to stand on their own or the copied extent reaches 30 lines — so a re-implementation sharing neither names nor values, and a small pasted declaration, are both found and deliberately not reported, and a clean R10 is not a claim that nothing was copied.
Method: Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm run over JS/TS tokens). Masking finds the candidates; a block is reported when its copies still agree on most of their own identifiers and literals, or when a renamed copy still agrees on most of its constants, AND the copies carry enough code to stand on their own — or when the copied extent reaches 30 lines. So a re-implementation sharing neither names nor values, and a small pasted declaration, are deliberately not counted. Deterministic.
paddleocr-js/packages/core/src/models/det.ts:205 · paddleocr-js/packages/core/src/models/rec.ts:114 — the two spans are one implementation copied and then locally edited — 648 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. — paddleocr-js/packages/core/src/models/det.ts:205
paddleocr-js/packages/core/src/models/det.ts:119 · paddleocr-js/packages/core/src/models/rec.ts:68 — the two spans are one implementation copied and then locally edited — 153 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. — paddleocr-js/packages/core/src/models/det.ts:119
api_sdk/typescript/src/client.ts:273 · api_sdk/typescript/src/client.ts:298 — 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. — api_sdk/typescript/src/client.ts:273
paddleocr-js/packages/core/src/platform/browser.ts:81 · paddleocr-js/packages/core/src/platform/worker.ts:42 — 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. — paddleocr-js/packages/core/src/platform/browser.ts:81
paddleocr-js/packages/core/src/platform/browser.ts:37 · paddleocr-js/packages/core/src/platform/browser.ts:58 — the two spans are one implementation copied and then locally edited — 72 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. — paddleocr-js/packages/core/src/platform/browser.ts:37
paddleocr-js/packages/core/src/viz/ocr/draw-boxes.ts:16 · paddleocr-js/packages/core/src/viz/ocr/draw-text.ts:45 — the two spans are one implementation copied and then locally edited — 92 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. — paddleocr-js/packages/core/src/viz/ocr/draw-boxes.ts:16
api_sdk/typescript/src/client.ts:354 · api_sdk/typescript/src/internal/poller.ts:150 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another. — api_sdk/typescript/src/client.ts:354
api_sdk/typescript/src/internal/http.ts:116 · api_sdk/typescript/src/internal/http.ts:126 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — api_sdk/typescript/src/internal/http.ts:116
paddleocr-js/packages/core/src/viz/ocr/renderer.ts:47 · paddleocr-js/packages/core/src/viz/ocr/renderer.ts:57 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — paddleocr-js/packages/core/src/viz/ocr/renderer.ts:47
paddleocr-js/packages/core/src/models/common.ts:159 · paddleocr-js/packages/core/src/models/common.ts:168 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — paddleocr-js/packages/core/src/models/common.ts:159
api_sdk/typescript/src/client.ts:79 · api_sdk/typescript/src/client.ts:85 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — api_sdk/typescript/src/client.ts:79
What to do
Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
React / JS · Code Health — Per-function cyclomatic/cognitive complexity from the token-level function scanner (D-386) — real branching, not a regex heuristic.
Method: Per-function cyclomatic/cognitive complexity from a token-level function scanner (real branching, not a regex heuristic), computed over every frontend function. Deterministic.
predict has cyclomatic complexity 25 and cognitive complexity 37; 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. — paddleocr-js/packages/core/src/pipelines/ocr/core.ts:197
normalizeOcrPipelineConfig has cyclomatic complexity 25 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 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. — paddleocr-js/packages/core/src/pipelines/ocr/config.ts:133
fetch has cyclomatic complexity 21 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. — api_sdk/typescript/src/internal/http.ts:178
decodeDetOutput has cyclomatic complexity 15 and cognitive complexity 25; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive 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. — paddleocr-js/packages/core/src/models/det.ts:468
readExplicitPipelineRuntimeDefaults has cyclomatic complexity 15 and cognitive complexity 20; 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. — paddleocr-js/packages/core/src/pipelines/ocr/shared.ts:210
drawTextPanel has cyclomatic complexity 12 and cognitive complexity 22; 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. — paddleocr-js/packages/core/src/viz/ocr/draw-text.ts:74
similar has cyclomatic complexity 11 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 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. — test_tipc/web/index.test.js:50
parseDetModelConfigText has cyclomatic complexity 11 and cognitive complexity 10; 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. — paddleocr-js/packages/core/src/models/det.ts:119
What to do
Break down the listed branch-heavy functions; aim P95 cyclomatic ≤ 5.
Do you agree with this assessment?
R3 · Large Files8.3 / 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.
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 Coverage10.0 / 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.
React / JS · Readiness — How outdated the npm dependencies are (a maturity signal). JS/npm CVEs are scored separately in D30 (JS/npm Dependency Vulnerabilities).
Method: npm dependency staleness from manifest/registry metadata (a maturity signal; JS/npm CVEs are scored separately in D30, which answers dependency vulnerabilities for every ecosystem). Deterministic.
What to do
Bump outdated dependencies to current versions to limit upgrade debt.
Do you agree with this assessment?
R6 · Tooling10.0 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each package.json script's COMMAND (eslint / tsc / vitest / jest / playwright), not just its name, and corroborated against CI-workflow invocations so a tool run only in CI still counts.
Method: package.json scanned for test/lint/typecheck script wiring. Deterministic presence check.
Do you agree with this assessment?
R7 · Dead Code10.0 / 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.
3 file(s) (~207 LoC) were excluded from dead-code analysis — declare main/module/exports or a conventional entry (src/index.*, an index.html script) so reachability can see this package.
2 file(s) (~60 LoC) were excluded from dead-code analysis — declare main/module/exports or a conventional entry (src/index.*, an index.html script) so reachability can see this package. — paddleocr-js
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.
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 · Security — Only what this repository's own non-C# files could be read for was assessed — markup this repository SHIPS is scored for third-party script integrity whether or not the repository serves it itself, since a page handed to a consumer runs in that consumer’s origin. Nothing else in this dimension was assessed: the transport, cookie, input-validation and crypto controls are read from a source model that was not loaded for this repository’s language, so their absence here is not a finding about this repository.
`https://giscus.app/client.js` is executed by this page with no Subresource Integrity. Whoever can answer that request — the CDN, anyone who compromises it, anyone on the network path — runs arbitrary script in this page's origin, with its session. The URL also names no version, so it resolves to whatever that origin serves at fetch time — the executed bytes can change with nobody touching this repository. — overrides/partials/comments.html:5
What to do
Pin third-party scripts and verify them: name an exact version in the URL and add an `integrity="sha384-…"` hash alongside `crossorigin="anonymous"` (both are required — an integrity hash on a cross-origin script without `crossorigin` is not evaluated, it blocks the script). Where the vendor ships a continuously-updated loader and publishes no stable hash (tag managers, analytics, chat widgets), Subresource Integrity is not available: constrain it instead with a `Content-Security-Policy` that names the exact origins allowed to execute, and drop the script from the pages that do not need it. Where the page is shipped inside a package that others host, prefer vendoring the asset and serving it from the app’s own origin, so no consumer inherits a third-party dependency they did not choose.
Do you agree with this assessment?
Reference — by lens
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Not evidenced — 4 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
C3 Audit Trail — Not assessed: these audit controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks audit controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C4 Data Retention — Not assessed: these retention controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks retention controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C5 Data-Subject Rights — Not assessed: these data-subject rights controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks data-subject rights controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 79 check(s) not relevant to this codebase
These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.
AC1 Text alternatives — Frontend below the scale floor (9 DOM element(s) < 25) — too little surface to assess accessibility.
AC2 Forms & labels — Frontend below the scale floor (9 DOM element(s) < 25) — too little surface to assess accessibility.
AC3 Page structure — Frontend below the scale floor (9 DOM element(s) < 25) — too little surface to assess accessibility.
AC4 Keyboard semantics — Frontend below the scale floor (9 DOM element(s) < 25) — too little surface to assess accessibility.
AC5 ARIA correctness — Frontend below the scale floor (9 DOM element(s) < 25) — too little surface to assess accessibility.
AC6 Visual & motion safety — Frontend below the scale floor (9 DOM element(s) < 25) — too little surface to assess accessibility.
AC7 A11y enforcement — Frontend below the scale floor (9 DOM element(s) < 25) — too little surface to assess accessibility.
AX1 Captive dependencies — no DI registrations detected
AX2 Stateful singletons — no singleton implementations detected
AX3 Project dependency cycles — not assessed — project cycles and dependency direction are computed over a project-reference graph that was not loaded for this repository, because the repository commits no project file of a kind this check models. This is a gap in the analyzer, not a finding about this repository
AX4 Dependency direction — not assessed — project cycles and dependency direction are computed over a project-reference graph that was not loaded for this repository, because the repository commits no project file of a kind this check models. This is a gap in the analyzer, not a finding about this repository
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AX8 Test isolation — not assessed — test isolation is computed from a project graph (which projects are test projects, and what they reference) that was not loaded for this repository, because the repository commits no project file of a kind this check models. This is a gap in the analyzer, not a finding about this repository
AXB2 Runtime readiness — 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.
C2 Access Controls — Not assessed: these authorization controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks authorization controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
D14 License Compliance — License Compliance not included (check did not complete)
D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
D22 Internal API Consistency — The exposed public-API surface could not be collected — no C#/VB projects loaded.
D23 Boundary Type-Coupling — Production source is present (.go, .java, .kt, .py, .swift, .ts) but bounded contexts are resolved over the C#/VB project set, which exposed none, so context scope could not be assessed. Not scored — this is a gap in the analyzer, not a verdict about this repository. Declaring the codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed — see the recommendation on this dimension for where. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — No inline comments to assess — comment value is not applicable here.
D25 ADR Conformance — no ADRs to check
D26 Project Cohesion — Project cohesion is assessed over the .NET project set; this target exposed no projects, so project size and spread could not be assessed. Not scored — this is a gap in the analyzer's reach, not a verdict about this repository.
D27 Navigability — symbol resolution incomplete — navigability not assessed
D32 Data Compliance (PII/GDPR) — 1 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
D5 Coupling — Inter-project coupling could not be assessed — no analyzable project graph was found for this repository. Not scored: a gap in the analyzer's reach, not a verdict about this repository. (Coupling here is Martin afferent/efferent/instability plus reference cycles across a project-reference graph, read today from .NET project files; other ecosystems' module graphs are not read yet.)
D6 Cohesion (LCOM4) — Cohesion (LCOM4) is measured over a CS/VB/GO/SCALA/SWIFT/DART class graph, and this repository's production source is .c, .cc, .cpp, .java, .kt, .mm, .py, .ts, which this pass does not read — so no class could be assessed. Not scored — this is a gap in the analyzer, not a finding about this repository.
D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
D8 Code Coverage — Coverage not measured — polyglot repository, one half has no runner
DM1 Domain Modelling — applicable but not scored (2 signals for this style, 2 needed — the count is met but a required primary signal is absent): 52 value object(s); 1 domain event(s)
ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and this analysis resolves a call's owner only where the receiver's type is written down in the source. Reported as guidance rather than measured
ED5 Idempotency — This check finds retry-prone mutations (command handlers and message/event consumers) by walking the repository's declared types, and none was loaded here, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
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# syntax, and none was loaded for this repository. 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'.
P2 Observability — Observability was not assessed: this check reads a source model that does not carry this repository's product — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of a logging idiom this check recognises is NOT evidence that this repo lacks structured logging (it may log through its own ecosystem's logger). This is a gap in the analyzer, not a finding about this repository.
P7 Outbound HTTP resilience — not measured — the application kind could not be determined for this repo
P8 Schema migrations — not assessed — schema-migration practice is read from 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
P9 Domain vs controller coverage — coverage data present for 36 file(s), but no domain-layer files were identified: no covered file's path contains any of the markers this check keys on (/domain/, /aggregates/, /valueobjects/, /domainmodel/, .domain/, /entities/), which are matched case-insensitively anywhere in the path. With no domain partition there is nothing to compare the web/controller layer against — if this repository keeps its business rules under a folder named none of those, that naming is what the check cannot see, not the domain logic.
PF1 Benchmark discipline — Performance was not assessed: this lens reads a source model that was not loaded for this repository, because the repository is written in a language this lens does not yet model or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository — in particular it is NOT a statement that this repo is unpackaged or performance-careless.
PF2 Allocation hygiene — Performance was not assessed: this lens reads a source model that was not loaded for this repository, because the repository is written in a language this lens does not yet model or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository — in particular it is NOT a statement that this repo is unpackaged or performance-careless.
PF3 Async & latency hygiene — Performance was not assessed: this lens reads a source model that was not loaded for this repository, because the repository is written in a language this lens does not yet model or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository — in particular it is NOT a statement that this repo is unpackaged or performance-careless.
R11 Import Boundaries — No recognizable feature-sliced/layered src layout — boundary rules not applicable.
SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X1 Async correctness — 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
X12 Unreachable branch — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X13 Undrained process stream — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X14 Bypassable address classification — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X15 Unvalidated length from an untrusted reader — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X16 Unfloored truncation loop — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X17 Uncapped recursion over a caller-supplied document — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X18 Disposal-pattern correctness — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X19 Unrestored process-global state — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X2 Cancellation propagation — 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
X20 Mistyped argument guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X21 Side-effecting pattern guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X22 Contradicted release guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X23 Unguarded diagnostic materialisation — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X24 Document value interpolated into markup unescaped — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X25 Inert configuration knob — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X26 Unsynchronised callback handoff — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X27 Collection changed while being enumerated — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X28 Index access outside its own emptiness guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X29 Per-element action decided by a fixed element — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X3 Exception handling — 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
X30 Support guard that admits what it rejects — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X32 Type resolved by simple name across every loaded assembly — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
TodoComment paddleocr/_cli.py:127— # TODO: Register the subparser whether the plugin is installed or not — 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 paddleocr/_pipelines/pp_chatocrv4_doc.py:589— # TODO: Support dict and list types — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment paddleocr/_pipelines/ocr.py:15— # TODO: Should we use a third-party CLI library to auto-generate command-line — 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 ppocr/data/collate_fn.py:27— # todo:support batch operators — 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 ppocr/data/collate_fn.py:47— # todo:support batch operators — 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:511— # todo: change to 0 and modified image shape — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment REDACTED:661— # todo: change to 0 and modified image shape — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment REDACTED:1157— # TODO: use tok.all_special_ids to remove — 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 ppocr/data/imaug/abinet_aug.py:253— # TODO: more robust way to crop image — 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:97— # TODO: n,h,w,c format is not supported yet — 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 ppocr/modeling/heads/rec_unimernet_head.py:1757— # TODO: add counting context weight to hidden_states — 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 ppocr/modeling/heads/rec_latexocr_head.py:760— # TODO: think of a cleaner solution — 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 ppocr/modeling/heads/rec_abinet_head.py:158— # TODO q=f(q,k) — 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 ppocr/modeling/heads/rec_abinet_head.py:249— # TODO:move to language model — 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 ppstructure/recovery/table_process.py:120— # TODO need some way to get rid of extra spaces in e.g. text <span> </span> text — 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 ppstructure/recovery/table_process.py:171— # TODO add this option back in? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment REDACTED:848— # TODO: — 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 tests/pipelines/test_table_recognition_v2.py:80— # TODO: Test constructor and other methods — 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 tests/pipelines/test_pp_structurev3.py:88— # TODO: Test constructor and other methods — 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 tests/pipelines/test_pp_doctranslation.py:96— # TODO: Test constructor and other methods — 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 tests/pipelines/test_pp_chatocrv4_doc.py:96— # TODO: Test constructor and other methods — 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 tests/pipelines/test_ocr.py:33— # TODO: Should we separate unit tests and integration tests? — 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 tests/pipelines/test_formula_recognition.py:32— # TODO: Should we separate unit tests and integration tests? — 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 tests/pipelines/test_ocr.py:59— # TODO: Also check passing `None` — 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 tests/pipelines/test_formula_recognition.py:57— # TODO: Also check passing `None` — 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.
FileTooLong: heads/rec_unimernet_head.py ppocr/modeling/heads/rec_unimernet_head.py— FileTooLong — 1974 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1474 over it, 3.95× 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 — 1758 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1258 over it, 3.52× 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: converters/docx.py paddleocr/_doc2md/converters/docx.py— FileTooLong — 1225 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 725 over it, 2.45× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: postprocess/rec_postprocess.py ppocr/postprocess/rec_postprocess.py— FileTooLong — 1212 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 712 over it, 2.42× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: REDACTED REDACTED— FileTooLong — 1115 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 615 over it, 2.23× 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: heads/rec_ppformulanet_head.py ppocr/modeling/heads/rec_ppformulanet_head.py— FileTooLong — 987 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 487 over it, 1.97× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: losses/distillation_loss.py ppocr/losses/distillation_loss.py— FileTooLong — 984 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 484 over it, 1.97× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: backbones/rec_resnetv2.py ppocr/modeling/backbones/rec_resnetv2.py— FileTooLong — 959 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 459 over it, 1.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: backbones/rec_donut_swin.py ppocr/modeling/backbones/rec_donut_swin.py— FileTooLong — 898 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 398 over it, 1.80× 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: _pipelines/pp_structurev3.py paddleocr/_pipelines/pp_structurev3.py— FileTooLong — 834 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 334 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: imaug/pg_process.py ppocr/data/imaug/pg_process.py— FileTooLong — 822 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 322 over it, 1.64× 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: infer/predict_rec.py tools/infer/predict_rec.py— FileTooLong — 784 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 284 over it, 1.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: tools/program.py tools/program.py— FileTooLong — 784 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 284 over it, 1.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: infer/utility.py tools/infer/utility.py— FileTooLong — 771 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 271 over it, 1.54× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: heads/rec_latexocr_head.py ppocr/modeling/heads/rec_latexocr_head.py— FileTooLong — 767 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 267 over it, 1.53× 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: _pipelines/pp_doctranslation.py paddleocr/_pipelines/pp_doctranslation.py— FileTooLong — 744 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 244 over it, 1.49× 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: necks/db_fpn.py ppocr/modeling/necks/db_fpn.py— FileTooLong — 721 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 221 over it, 1.44× 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 — 720 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 220 over it, 1.44× 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: imaug/unimernet_aug.py ppocr/data/imaug/unimernet_aug.py— FileTooLong — 649 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 149 over it, 1.30× 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: _pipelines/pp_chatocrv4_doc.py paddleocr/_pipelines/pp_chatocrv4_doc.py— FileTooLong — 590 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 90 over it, 1.18× 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 — 576 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 76 over it, 1.15× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: imaug/sast_process.py ppocr/data/imaug/sast_process.py— FileTooLong — 546 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 46 over it, 1.09× 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: imaug/drrg_targets.py ppocr/data/imaug/drrg_targets.py— FileTooLong — 540 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 40 over it, 1.08× 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 — 537 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 37 over it, 1.07× 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: backbones/rec_lcnetv4.py ppocr/modeling/backbones/rec_lcnetv4.py— FileTooLong — 523 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 23 over it, 1.05× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
Duplicated block (8 lines × 2) ppocr/data/collate_fn.py:51— ppocr/data/collate_fn.py:51-58 | tools/infer_kie_token_ser.py:49-56 — 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 `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 × 2) ppocr/data/imaug/abinet_aug.py:400— ppocr/data/imaug/abinet_aug.py:400-407 | ppocr/data/imaug/abinet_aug.py:436-443 — both copies are in the same file, so extract the 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, `ppocr/data/imaug/abinet_aug.py:409` calls `shuffle`, `Compose` and `ppocr/data/imaug/abinet_aug.py:444` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) REDACTED:130— REDACTED:130-137 | ppocr/postprocess/rec_postprocess.py:36-43 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (8 lines × 2) REDACTED:87— REDACTED:87-94 | REDACTED:81-88 — 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 `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 × 2) ppocr/data/imaug/pg_process.py:979— ppocr/data/imaug/pg_process.py:979-986 | ppocr/data/imaug/sast_process.py:712-719 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (8 lines × 2) REDACTED:512— REDACTED:512-519 | tools/infer/predict_cls.py:69-76 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (8 lines × 2) ppocr/data/imaug/unimernet_aug.py:172— ppocr/data/imaug/unimernet_aug.py:172-179 | ppocr/data/imaug/unimernet_aug.py:275-283 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/data/imaug/unimernet_aug.py:275` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) ppocr/data/pubtab_dataset.py:73— ppocr/data/pubtab_dataset.py:73-80 | ppocr/data/pubtab_dataset.py:98-105 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) ppocr/modeling/backbones/rec_donut_swin.py:725— ppocr/modeling/backbones/rec_donut_swin.py:725-732 | ppocr/modeling/backbones/rec_donut_swin.py:757-764 — both copies are in the same file, so extract the 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, `ppocr/modeling/backbones/rec_donut_swin.py:723` calls `to_tensor`, `cast` and `ppocr/modeling/backbones/rec_donut_swin.py:755` 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) ppocr/modeling/backbones/rec_hgnet.py:271— ppocr/modeling/backbones/rec_hgnet.py:271-278 | REDACTED:1393-1400 — 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) REDACTED:29— REDACTED:29-36 | REDACTED:39-46 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, 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:34` calls `to_2tuple`, `tuple` and `REDACTED:25` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) ppocr/modeling/transforms/tbsrn.py:242— ppocr/modeling/transforms/tbsrn.py:242-249 | ppocr/modeling/transforms/tsrn.py:117-125 — before extracting anything, compare `ppocr/modeling/transforms/tbsrn.py` and `ppocr/modeling/transforms/tsrn.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/transforms/tbsrn.py:242` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) ppocr/postprocess/sast_postprocess.py:56— ppocr/postprocess/sast_postprocess.py:56-64 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:317-324 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (8 lines × 2) ppocr/utils/utility.py:27— ppocr/utils/utility.py:27-34 | REDACTED:25-32 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (8 lines × 2) ppocr/utils/visual.py:33— ppocr/utils/visual.py:33-40 | ppocr/utils/visual.py:90-97 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) test_tipc/supplementary/config.py:17— test_tipc/supplementary/config.py:17-24 | tools/program.py:46-54 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `test_tipc/supplementary/config.py:17` 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 lines × 2) tools/infer/predict_cls.py:91— tools/infer/predict_cls.py:91-99 | tools/infer/predict_rec.py:584-591 — 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, `tools/infer/predict_cls.py:90` calls `deepcopy` and `tools/infer/predict_rec.py:583` 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) tools/infer/predict_det.py:77— tools/infer/predict_det.py:77-84 | tools/infer/predict_det.py:86-93 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) tools/infer/predict_rec.py:254— tools/infer/predict_rec.py:254-261 | tools/infer/predict_rec.py:421-428 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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 × 2) REDACTED:69— REDACTED:69-76 | REDACTED:9-16 — 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) ppocr/modeling/backbones/det_mobilenet_v3.py:251— ppocr/modeling/backbones/det_mobilenet_v3.py:251-258 | test_tipc/supplementary/mv3.py:303-310 — 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 `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 × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:838— ppocr/modeling/heads/rec_ppformulanet_head.py:838-845 | ppocr/modeling/heads/rec_unimernet_head.py:2300-2308 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (8 lines × 2) ppocr/data/imaug/ct_process.py:231— ppocr/data/imaug/ct_process.py:231-238 | ppocr/data/imaug/random_crop_data.py:549-556 — 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) ppocr/utils/e2e_utils/extract_textpoint_fast.py:458— ppocr/utils/e2e_utils/extract_textpoint_fast.py:458-465 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:521-528 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:39— ppocr/utils/e2e_utils/extract_textpoint_fast.py:39-46 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:104-111 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 (5 lines × 2) ppocr/data/imaug/latex_ocr_aug.py:104— ppocr/data/imaug/latex_ocr_aug.py:104-108 | tools/infer/predict_rec.py:500-504 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (5 lines × 2) ppocr/data/imaug/pg_process.py:823— ppocr/data/imaug/pg_process.py:823-827 | ppocr/data/imaug/sast_process.py:601-605 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) REDACTED:36— REDACTED:36-40 | REDACTED:36-40 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 48 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 (5 lines × 2) ppocr/modeling/heads/proposal_local_graph.py:41— ppocr/modeling/heads/proposal_local_graph.py:41-45 | ppocr/postprocess/fce_postprocess.py:29-33 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (5 lines × 2) ppocr/modeling/heads/rec_satrn_head.py:139— ppocr/modeling/heads/rec_satrn_head.py:139-143 | ppocr/modeling/heads/rec_satrn_head.py:339-343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/heads/rec_satrn_head.py:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) ppocr/modeling/necks/rf_adaptor.py:57— ppocr/modeling/necks/rf_adaptor.py:57-61 | ppocr/modeling/necks/rf_adaptor.py:90-94 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) ppocr/modeling/necks/rnn.py:229— ppocr/modeling/necks/rnn.py:229-233 | ppocr/modeling/necks/rnn.py:338-342 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) mcp_server/paddleocr_mcp/inference/ocr/local.py:60— mcp_server/paddleocr_mcp/inference/ocr/local.py:60-64 | mcp_server/paddleocr_mcp/inference/paddleocr_vl/local.py:45-49 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (5 lines × 2) ppocr/data/imaug/pg_process.py:774— ppocr/data/imaug/pg_process.py:774-778 | ppocr/data/imaug/sast_process.py:550-554 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (5 lines × 2) ppocr/modeling/backbones/det_pp_lcnet.py:124— ppocr/modeling/backbones/det_pp_lcnet.py:124-128 | ppocr/modeling/backbones/rec_lcnetv3.py:396-400 — before extracting anything, compare `ppocr/modeling/backbones/det_pp_lcnet.py` and `ppocr/modeling/backbones/rec_lcnetv3.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) ppocr/modeling/backbones/det_pp_lcnet_v2.py:79— ppocr/modeling/backbones/det_pp_lcnet_v2.py:79-83 | ppocr/modeling/backbones/rec_hgnet.py:66-70 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) REDACTED:568— REDACTED:568-572 | ppocr/postprocess/rec_postprocess.py:444-448 — 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) ppocr/losses/rec_sar_loss.py:11— ppocr/losses/rec_sar_loss.py:11-15 | ppocr/losses/rec_satrn_loss.py:28-32 — before extracting anything, compare `ppocr/losses/rec_sar_loss.py` and `ppocr/losses/rec_satrn_loss.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) ppocr/data/imaug/fce_aug.py:244— ppocr/data/imaug/fce_aug.py:244-248 | ppocr/data/imaug/fce_aug.py:254-258 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) ppocr/data/imaug/fce_aug.py:432— ppocr/data/imaug/fce_aug.py:432-436 | ppocr/data/imaug/fce_aug.py:530-534 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/data/imaug/fce_aug.py:432` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) ppocr/modeling/backbones/rec_lcnetv4.py:207— ppocr/modeling/backbones/rec_lcnetv4.py:207-211 | ppocr/modeling/backbones/rec_lcnetv4.py:269-273 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/backbones/rec_lcnetv4.py:207` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) ppocr/modeling/necks/pren_fpn.py:95— ppocr/modeling/necks/pren_fpn.py:95-99 | ppocr/modeling/necks/pren_fpn.py:103-107 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) ppocr/utils/visual.py:81— ppocr/utils/visual.py:81-85 | ppstructure/kie/tools/trans_funsd_label.py:24-28 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) tools/infer/utility.py:704— tools/infer/utility.py:704-708 | tools/infer/utility.py:711-715 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) ppocr/utils/e2e_metric/Deteval.py:71— ppocr/utils/e2e_metric/Deteval.py:71-75 | ppocr/utils/e2e_metric/Deteval.py:202-206 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:393— ppocr/utils/e2e_utils/extract_textpoint_fast.py:393-397 | ppocr/utils/e2e_utils/pgnet_pp_utils.py:153-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.
Duplicated block (7 lines × 2) paddleocr/_doc2md/converters/docx.py:1015— paddleocr/_doc2md/converters/docx.py:1015-1021 | paddleocr/_doc2md/converters/pptx.py:374-380 — 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, `paddleocr/_doc2md/converters/pptx.py:372` calls `find` and `paddleocr/_doc2md/converters/docx.py:1013` 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 (7 lines × 2) ppocr/data/imaug/ct_process.py:34— ppocr/data/imaug/ct_process.py:34-40 | ppocr/data/imaug/ct_process.py:362-368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) REDACTED:666— REDACTED:666-672 | tools/infer/predict_rec.py:416-422 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (7 lines × 2) ppocr/losses/det_ct_loss.py:104— ppocr/losses/det_ct_loss.py:104-110 | ppocr/utils/iou.py:48-54 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (7 lines × 2) ppocr/losses/distillation_loss.py:830— ppocr/losses/distillation_loss.py:830-836 | ppocr/losses/distillation_loss.py:977-983 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (7 lines × 2) REDACTED:101— REDACTED:101-107 | REDACTED:110-116 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 2) ppocr/utils/export_model.py:438— ppocr/utils/export_model.py:438-444 | ppocr/utils/export_model.py:457-463 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) ppocr/data/imaug/pg_process.py:781— ppocr/data/imaug/pg_process.py:781-787 | ppocr/data/imaug/sast_process.py:557-563 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (7 lines × 2) ppocr/data/imaug/pg_process.py:797— ppocr/data/imaug/pg_process.py:797-803 | ppocr/data/imaug/sast_process.py:573-579 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (7 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:67— ppocr/modeling/heads/rec_ppformulanet_head.py:67-73 | ppocr/modeling/heads/rec_unimernet_head.py:285-291 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:245— ppocr/modeling/heads/rec_ppformulanet_head.py:245-252 | ppocr/modeling/heads/rec_unimernet_head.py:324-330 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (7 lines × 2) ppocr/data/imaug/drrg_targets.py:594— ppocr/data/imaug/drrg_targets.py:594-600 | ppocr/modeling/heads/proposal_local_graph.py:149-155 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (7 lines × 2) REDACTED:272— REDACTED:272-278 | REDACTED:171-177 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 48 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 (7 lines × 2) ppocr/modeling/backbones/rec_svtrv2.py:146— ppocr/modeling/backbones/rec_svtrv2.py:146-152 | REDACTED:124-130 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/backbones/rec_svtrv2.py:146` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) ppocr/modeling/transforms/gaspin_transformer.py:237— ppocr/modeling/transforms/gaspin_transformer.py:237-243 | ppocr/modeling/transforms/tps.py:156-162 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (7 lines × 2) deploy/ios_demo/scripts/build_onnx_calib_npy.py:194— deploy/ios_demo/scripts/build_onnx_calib_npy.py:194-200 | deploy/ios_demo/scripts/build_onnx_calib_npy.py:211-217 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (7 lines × 2) ppocr/losses/e2e_pg_loss.py:46— ppocr/losses/e2e_pg_loss.py:46-52 | ppocr/losses/e2e_pg_loss.py:73-79 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:384— ppocr/utils/e2e_utils/extract_textpoint_fast.py:384-390 | ppocr/utils/e2e_utils/pgnet_pp_utils.py:139-145 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (7 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:200— ppocr/utils/e2e_utils/extract_textpoint_fast.py:200-206 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:227-233 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 (6 lines × 2) ppocr/data/imaug/fce_targets.py:612— ppocr/data/imaug/fce_targets.py:612-617 | ppocr/data/imaug/fce_targets.py:621-626 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) ppocr/data/imaug/pg_process.py:1091— ppocr/data/imaug/pg_process.py:1091-1096 | ppocr/data/imaug/sast_process.py:796-801 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 2) REDACTED:718— REDACTED:718-723 | tools/infer/predict_rec.py:463-468 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) ppocr/data/imaug/unimernet_aug.py:171— ppocr/data/imaug/unimernet_aug.py:171-176 | ppocr/data/imaug/unimernet_aug.py:209-214 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) ppocr/modeling/heads/det_ct_head.py:49— ppocr/modeling/heads/det_ct_head.py:49-54 | ppocr/modeling/necks/ct_fpn.py:53-58 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) ppocr/modeling/heads/table_att_head.py:102— ppocr/modeling/heads/table_att_head.py:102-107 | ppocr/modeling/heads/table_att_head.py:129-134 — both copies are in the same file, so extract the 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, `ppocr/modeling/heads/table_att_head.py:125` calls `argmax`, `structure_generator`, `softmax` and `ppocr/modeling/heads/table_att_head.py:101` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 2) ppocr/modeling/transforms/tbsrn.py:172— ppocr/modeling/transforms/tbsrn.py:172-177 | ppocr/modeling/transforms/tsrn.py:75-80 — before extracting anything, compare `ppocr/modeling/transforms/tbsrn.py` and `ppocr/modeling/transforms/tsrn.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/transforms/tbsrn.py:172` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) ppocr/postprocess/db_postprocess.py:97— ppocr/postprocess/db_postprocess.py:97-102 | ppocr/postprocess/db_postprocess.py:148-153 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/postprocess/db_postprocess.py:97` 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 (6 lines × 2) ppocr/utils/utility.py:35— ppocr/utils/utility.py:35-40 | REDACTED:33-38 — 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 `ppocr/utils/utility.py:35` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) ppstructure/utility.py:34— ppstructure/utility.py:34-39 | tools/infer/utility.py:95-100 — 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 `ppstructure/utility.py:34` 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 (6 lines × 2) test_tipc/supplementary/config.py:120— test_tipc/supplementary/config.py:120-125 | tools/program.py:884-889 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) tools/infer/utility.py:66— tools/infer/utility.py:66-71 | tools/infer/utility.py:74-79 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tools/infer/utility.py:74` calls `add_argument` and `tools/infer/utility.py:86` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 2) mcp_server/paddleocr_mcp/inference/paddleocr_vl/aistudio.py:53— mcp_server/paddleocr_mcp/inference/paddleocr_vl/aistudio.py:53-58 | mcp_server/paddleocr_mcp/inference/pp_structurev3/aistudio.py:53-58 — `mcp_server/paddleocr_mcp/inference/paddleocr_vl/aistudio.py` and `mcp_server/paddleocr_mcp/inference/pp_structurev3/aistudio.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 27 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
Duplicated block (6 lines × 2) REDACTED:2062— REDACTED:2062-2067 | ppocr/postprocess/rec_postprocess.py:1417-1422 — 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 `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) ppocr/data/imaug/latex_ocr_aug.py:72— ppocr/data/imaug/latex_ocr_aug.py:72-77 | ppocr/data/imaug/unimernet_aug.py:459-464 — 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) ppocr/modeling/backbones/rec_hybridvit.py:55— ppocr/modeling/backbones/rec_hybridvit.py:55-60 | ppocr/modeling/backbones/rec_resnetv2.py:45-50 — 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, `ppocr/modeling/backbones/rec_hybridvit.py:50` calls `TruncatedNormal`, `XavierUniform` and `ppocr/modeling/backbones/rec_resnetv2.py:41` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 2) ppocr/data/collate_fn.py:96— ppocr/data/collate_fn.py:96-101 | ppocr/data/collate_fn.py:153-158 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) ppocr/modeling/necks/db_fpn.py:416— ppocr/modeling/necks/db_fpn.py:416-421 | ppocr/modeling/necks/db_fpn.py:937-942 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot 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) paddleocr/_doc2md/converters/docx.py:1005— paddleocr/_doc2md/converters/docx.py:1005-1013 | paddleocr/_doc2md/converters/pptx.py:362-370 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `paddleocr/_doc2md/converters/pptx.py:372` calls `find` and `paddleocr/_doc2md/converters/docx.py:1015` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 2) ppocr/data/imaug/drrg_targets.py:189— ppocr/data/imaug/drrg_targets.py:189-197 | ppocr/data/imaug/fce_targets.py:160-168 — 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 (9 lines × 2) ppocr/data/imaug/pg_process.py:440— ppocr/data/imaug/pg_process.py:440-448 | ppocr/data/imaug/sast_process.py:246-254 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (9 lines × 2) ppocr/data/imaug/text_image_aug/augment.py:27— ppocr/data/imaug/text_image_aug/augment.py:27-35 | ppocr/data/imaug/text_image_aug/augment.py:105-113 — both copies are in the same file, so extract the block into 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) ppocr/data/imaug/unimernet_aug.py:541— ppocr/data/imaug/unimernet_aug.py:541-549 | ppocr/data/imaug/unimernet_aug.py:648-656 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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:164— REDACTED:164-172 | ppocr/modeling/backbones/rec_svtrv2.py:131-139 — before extracting anything, compare `REDACTED` and `ppocr/modeling/backbones/rec_svtrv2.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 2) ppocr/modeling/heads/det_ct_head.py:37— ppocr/modeling/heads/det_ct_head.py:37-45 | ppocr/modeling/heads/det_pse_head.py:25-33 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (9 lines × 2) ppocr/modeling/heads/rec_latexocr_head.py:919— ppocr/modeling/heads/rec_latexocr_head.py:919-927 | ppocr/modeling/heads/rec_latexocr_head.py:977-985 — both copies are in the same file, so extract the 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) ppocr/modeling/necks/sast_fpn.py:112— ppocr/modeling/necks/sast_fpn.py:112-120 | ppocr/modeling/necks/sast_fpn.py:199-207 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) ppocr/postprocess/rec_postprocess.py:164— ppocr/postprocess/rec_postprocess.py:164-172 | ppocr/postprocess/rec_postprocess.py:1077-1086 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/postprocess/rec_postprocess.py:164` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) ppocr/postprocess/rec_postprocess.py:261— ppocr/postprocess/rec_postprocess.py:261-269 | ppocr/postprocess/rec_postprocess.py:860-868 — both copies are in the same file, so extract the 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) tools/eval.py:73— tools/eval.py:73-81 | tools/infer_rec.py:84-92 — before extracting anything, compare `tools/eval.py` and `tools/infer_rec.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. 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, `tools/infer_rec.py:82` calls `getattr` and `tools/eval.py:71` 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) REDACTED:83— REDACTED:83-91 | tools/infer/predict_det.py:186-194 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. 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:76— REDACTED:76-84 | REDACTED:70-78 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (9 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:160— ppocr/utils/e2e_utils/extract_textpoint_fast.py:160-168 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:187-195 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:486— ppocr/utils/e2e_utils/extract_textpoint_fast.py:486-494 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:549-557 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:120— mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:120-129 | mcp_server/paddleocr_mcp/inference/shared/http_result_parsers.py:34-43 — 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 `mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:120` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot 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) paddleocr/_doc2md/converters/docx.py:866— paddleocr/_doc2md/converters/docx.py:866-875 | paddleocr/_doc2md/converters/docx.py:1193-1202 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) REDACTED:2049— REDACTED:2049-2058 | ppocr/postprocess/rec_postprocess.py:1404-1413 — 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 `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) ppocr/data/imaug/pg_process.py:110— ppocr/data/imaug/pg_process.py:110-119 | ppocr/data/imaug/sast_process.py:89-98 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (10 lines × 2) ppocr/data/imaug/pg_process.py:1005— ppocr/data/imaug/pg_process.py:1005-1014 | ppocr/data/imaug/sast_process.py:738-747 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:1005` it begins part-way through the construct above it, so those exact lines 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) ppocr/data/imaug/pg_process.py:1017— ppocr/data/imaug/pg_process.py:1017-1026 | ppocr/data/imaug/sast_process.py:750-759 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) ppocr/data/imaug/pg_process.py:1037— ppocr/data/imaug/pg_process.py:1037-1046 | ppocr/data/imaug/sast_process.py:771-780 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) ppocr/modeling/backbones/rec_donut_swin.py:706— ppocr/modeling/backbones/rec_donut_swin.py:706-715 | ppocr/modeling/backbones/rec_donut_swin.py:740-749 — both copies are in the same file, so extract the 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, `ppocr/modeling/backbones/rec_donut_swin.py:716` calls `zeros` and `ppocr/modeling/backbones/rec_donut_swin.py:751` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 2) ppocr/modeling/backbones/rec_resnetv2.py:469— ppocr/modeling/backbones/rec_resnetv2.py:469-478 | ppocr/modeling/backbones/rec_resnetv2.py:517-526 — both copies are in the same file, so extract the 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, `ppocr/modeling/backbones/rec_resnetv2.py:479` calls `register_buffer`, `ones` and `ppocr/modeling/backbones/rec_resnetv2.py:527` 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 lines × 2) ppocr/modeling/heads/rec_unimernet_head.py:1375— ppocr/modeling/heads/rec_unimernet_head.py:1375-1384 | ppocr/modeling/heads/rec_unimernet_head.py:1385-1394 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) ppocr/postprocess/drrg_postprocess.py:328— ppocr/postprocess/drrg_postprocess.py:328-337 | ppocr/postprocess/fce_postprocess.py:118-127 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ppocr/postprocess/fce_postprocess.py:117` calls `valid_boundary` and `ppocr/postprocess/drrg_postprocess.py:327` 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 lines × 2) REDACTED:978— REDACTED:978-987 | ppocr/postprocess/rec_postprocess.py:878-887 — 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 `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) ppocr/modeling/backbones/rec_donut_swin.py:302— ppocr/modeling/backbones/rec_donut_swin.py:302-311 | ppocr/modeling/backbones/rec_hybridvit.py:104-113 — 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 (10 lines × 2) REDACTED:105— REDACTED:105-114 | REDACTED:225-234 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:80— ppocr/utils/e2e_utils/extract_textpoint_fast.py:80-89 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:145-154 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 (17 lines × 2) ppocr/data/imaug/latex_ocr_aug.py:110— ppocr/data/imaug/latex_ocr_aug.py:110-126 | tools/infer/predict_rec.py:506-522 — 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 (17 lines × 2) ppocr/data/imaug/pg_process.py:137— ppocr/data/imaug/pg_process.py:137-153 | ppocr/data/imaug/sast_process.py:116-132 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (17 lines × 2) REDACTED:403— REDACTED:403-419 | REDACTED:512-528 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17 lines × 2) ppocr/modeling/backbones/det_pp_lcnet.py:133— ppocr/modeling/backbones/det_pp_lcnet.py:133-149 | ppocr/modeling/backbones/det_pp_lcnet_v2.py:88-104 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (17 lines × 2) ppocr/modeling/backbones/rec_lcnetv3.py:92— ppocr/modeling/backbones/rec_lcnetv3.py:92-108 | REDACTED:922-938 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (17 lines × 2) ppocr/modeling/backbones/rec_lcnetv4.py:239— ppocr/modeling/backbones/rec_lcnetv4.py:239-255 | REDACTED:975-991 — 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, `REDACTED:993` calls `LearnableAffineBlock` and `ppocr/modeling/backbones/rec_lcnetv4.py:257` 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 (17 lines × 2) REDACTED:367— REDACTED:367-383 | REDACTED:433-449 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:367` 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) ppocr/modeling/backbones/rec_resnet_rfl.py:188— ppocr/modeling/backbones/rec_resnet_rfl.py:188-204 | ppocr/modeling/backbones/rec_resnet_rfl.py:307-323 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17 lines × 2) REDACTED:304— REDACTED:304-320 | REDACTED:334-350 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift 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:304` it begins part-way through the construct above it, so those exact lines 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) ppocr/modeling/heads/rec_robustscanner_head.py:451— ppocr/modeling/heads/rec_robustscanner_head.py:451-467 | ppocr/modeling/heads/rec_robustscanner_head.py:489-505 — both copies are in the same file, so extract the 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 (17 lines × 2) ppocr/postprocess/db_postprocess.py:170— ppocr/postprocess/db_postprocess.py:170-186 | tools/infer/utility.py:914-930 — 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 (17 lines × 2) REDACTED:88— REDACTED:88-105 | REDACTED:317-333 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift 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:88` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) deploy/slim/quantization/quant.py:105— deploy/slim/quantization/quant.py:105-115 | tools/train.py:76-86 — before extracting anything, compare `deploy/slim/quantization/quant.py` and `tools/train.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `deploy/slim/quantization/quant.py:105` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) mcp_server/paddleocr_mcp/inference/ocr/local.py:110— mcp_server/paddleocr_mcp/inference/ocr/local.py:110-120 | mcp_server/paddleocr_mcp/inference/shared/http_result_parsers.py:27-37 — 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 `mcp_server/paddleocr_mcp/inference/ocr/local.py:110` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) paddleocr/_api_client/_http.py:160— paddleocr/_api_client/_http.py:160-170 | paddleocr/_api_client/_http.py:173-183 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11 lines × 2) paddleocr/_doc2md/converters/pptx.py:287— paddleocr/_doc2md/converters/pptx.py:287-298 | paddleocr/_doc2md/converters/pptx.py:511-521 — both copies are in the same file, so extract the 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 lines × 2) ppocr/data/imaug/drrg_targets.py:178— ppocr/data/imaug/drrg_targets.py:178-188 | ppocr/data/imaug/fce_targets.py:149-159 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) ppocr/data/imaug/latex_ocr_aug.py:173— ppocr/data/imaug/latex_ocr_aug.py:173-183 | ppocr/data/imaug/unimernet_aug.py:824-834 — 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 (11 lines × 2) ppocr/data/imaug/make_border_map.py:167— ppocr/data/imaug/make_border_map.py:167-177 | ppocr/data/imaug/make_border_map.py:180-190 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/data/imaug/make_border_map.py:167` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) ppocr/data/imaug/pg_process.py:540— ppocr/data/imaug/pg_process.py:540-550 | ppocr/data/imaug/sast_process.py:312-322 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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, `ppocr/data/imaug/pg_process.py:551` calls `fillPoly`, `round`, `astype` and `ppocr/data/imaug/sast_process.py:325` 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) ppocr/losses/rec_att_loss.py:31— ppocr/losses/rec_att_loss.py:31-41 | ppocr/losses/rec_spin_att_loss.py:40-50 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:1085— ppocr/modeling/heads/rec_ppformulanet_head.py:1085-1095 | ppocr/modeling/heads/rec_ppformulanet_head.py:1224-1234 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/heads/rec_ppformulanet_head.py:1085` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) tools/infer/utility.py:587— tools/infer/utility.py:587-597 | tools/infer_e2e.py:81-91 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (11 lines × 2) ppocr/data/imaug/pg_process.py:293— ppocr/data/imaug/pg_process.py:293-303 | ppocr/data/imaug/pg_process.py:393-403 — both copies are in the same file, so extract the 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.
D30 · Dependency Vulnerabilities· Medium CVE · ×11
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×11
Members sharing a duplicated core (4 members, 50+ identical tokens) ppocr/data/imaug/east_process.py:292— ppocr/data/imaug/east_process.py:292-364 | ppocr/data/imaug/fce_aug.py:87-185 | ppocr/data/imaug/pg_process.py:158-236 | ppocr/data/imaug/sast_process.py:135-207 — 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:878— REDACTED:878-889 | REDACTED:927-938 | ppocr/postprocess/rec_postprocess.py:693-703 | ppocr/postprocess/rec_postprocess.py:768-778 — 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) ppocr/modeling/backbones/det_resnet_vd_sast.py:39— ppocr/modeling/backbones/det_resnet_vd_sast.py:39-66 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:39-66 | ppocr/modeling/backbones/rec_resnet_vd.py:39-66 | ppocr/modeling/necks/pg_fpn.py:37-65 — 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) ppocr/modeling/backbones/det_resnet_vd_sast.py:86— ppocr/modeling/backbones/det_resnet_vd_sast.py:86-121 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:84-119 | ppocr/modeling/backbones/rec_resnet_fpn.py:243-275 | ppocr/modeling/backbones/rec_resnet_vd.py:86-121 — 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) ppocr/modeling/backbones/rec_resnet_32.py:109— ppocr/modeling/backbones/rec_resnet_32.py:109-123 | ppocr/modeling/backbones/rec_resnet_45.py:71-85 | ppocr/modeling/backbones/rec_resnet_aster.py:65-76 | ppocr/modeling/backbones/rec_resnet_rfl.py:70-84 — 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) ppocr/modeling/heads/rec_ppformulanet_head.py:1062— ppocr/modeling/heads/rec_ppformulanet_head.py:1062-1180 | ppocr/modeling/heads/rec_ppformulanet_head.py:1188-1292 | ppocr/modeling/heads/rec_unimernet_head.py:2416-2489 | ppocr/modeling/heads/rec_unimernet_head.py:2497-2574 — 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) ppocr/modeling/necks/db_fpn.py:248— ppocr/modeling/necks/db_fpn.py:248-268 | ppocr/modeling/necks/db_fpn.py:334-374 | ppocr/modeling/necks/db_fpn.py:434-506 | ppocr/modeling/necks/db_fpn.py:839-895 — 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) ppocr/postprocess/sast_postprocess.py:56— ppocr/postprocess/sast_postprocess.py:56-65 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:317-325 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:39-58 | ppocr/utils/e2e_utils/visual.py:96-115 — 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) tools/infer_cls.py:41— tools/infer_cls.py:41-79 | tools/infer_det.py:58-138 | tools/infer_e2e.py:103-165 | tools/infer_table.py:47-115 — 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) ppocr/utils/e2e_utils/extract_textpoint_fast.py:160— ppocr/utils/e2e_utils/extract_textpoint_fast.py:160-196 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:486-523 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:187-223 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:549-586 — 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) ppocr/utils/e2e_utils/extract_textpoint_fast.py:210— ppocr/utils/e2e_utils/extract_textpoint_fast.py:210-254 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:258-313 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:237-282 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:286-342 — 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 (14 lines × 2) mcp_server/paddleocr_mcp/inference/shared/paddleocr_api_sdk.py:77— mcp_server/paddleocr_mcp/inference/shared/paddleocr_api_sdk.py:77-90 | mcp_server/paddleocr_mcp/inference/shared/paddleocr_api_sdk.py:97-110 — both copies are in the same file, so extract the 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) paddleocr/_pipelines/pp_chatocrv4_doc.py:131— paddleocr/_pipelines/pp_chatocrv4_doc.py:131-144 | paddleocr/_pipelines/pp_doctranslation.py:140-153 — before extracting anything, compare `paddleocr/_pipelines/pp_chatocrv4_doc.py` and `paddleocr/_pipelines/pp_doctranslation.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 372 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 `paddleocr/_pipelines/pp_chatocrv4_doc.py:131` 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 (14 lines × 2) ppocr/data/imaug/latex_ocr_aug.py:133— ppocr/data/imaug/latex_ocr_aug.py:133-146 | tools/infer/predict_rec.py:534-547 — 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (14 lines × 2) ppocr/data/imaug/pg_process.py:832— ppocr/data/imaug/pg_process.py:832-845 | ppocr/data/imaug/sast_process.py:610-623 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:832` 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 (14 lines × 2) REDACTED:732— REDACTED:732-745 | tools/infer/predict_rec.py:298-311 — 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 `REDACTED:732` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) ppocr/modeling/heads/det_drrg_head.py:58— ppocr/modeling/heads/det_drrg_head.py:58-71 | ppocr/modeling/heads/proposal_local_graph.py:70-83 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (14 lines × 2) ppocr/modeling/heads/rec_att_head.py:187— ppocr/modeling/heads/rec_att_head.py:187-200 | ppocr/modeling/heads/rec_spin_att_head.py:96-109 — before extracting anything, compare `ppocr/modeling/heads/rec_att_head.py` and `ppocr/modeling/heads/rec_spin_att_head.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 81 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (14 lines × 2) ppocr/modeling/heads/rec_latexocr_head.py:891— ppocr/modeling/heads/rec_latexocr_head.py:891-904 | ppocr/modeling/heads/rec_latexocr_head.py:945-958 — both copies are in the same file, so extract the block into 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) ppocr/modeling/heads/rec_ppformulanet_head.py:385— ppocr/modeling/heads/rec_ppformulanet_head.py:385-398 | ppocr/modeling/heads/rec_unimernet_head.py:405-418 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 `ppocr/modeling/heads/rec_ppformulanet_head.py:385` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) ppstructure/kie/tools/eval_with_label_end2end.py:187— ppstructure/kie/tools/eval_with_label_end2end.py:187-200 | tools/end2end/eval_end2end.py:167-180 — before extracting anything, compare `ppstructure/kie/tools/eval_with_label_end2end.py` and `tools/end2end/eval_end2end.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (14 lines × 2) REDACTED:289— REDACTED:289-302 | REDACTED:423-436 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift 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: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.
Duplicated block (12 lines × 2) REDACTED:57— REDACTED:57-68 | REDACTED:50-61 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) ppocr/data/imaug/table_ops.py:37— ppocr/data/imaug/table_ops.py:37-48 | ppocr/data/imaug/table_ops.py:87-98 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) ppocr/modeling/backbones/e2e_resnet_vd_pg.py:190— ppocr/modeling/backbones/e2e_resnet_vd_pg.py:190-201 | ppocr/modeling/backbones/rec_resnet_vd.py:193-204 — before extracting anything, compare `ppocr/modeling/backbones/e2e_resnet_vd_pg.py` and `ppocr/modeling/backbones/rec_resnet_vd.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 123 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:1117— ppocr/modeling/heads/rec_ppformulanet_head.py:1117-1128 | ppocr/modeling/heads/rec_unimernet_head.py:2535-2546 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) ppocr/modeling/necks/db_fpn.py:453— ppocr/modeling/necks/db_fpn.py:453-466 | ppocr/modeling/necks/db_fpn.py:850-861 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/necks/db_fpn.py:453` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) ppocr/postprocess/picodet_postprocess.py:52— ppocr/postprocess/picodet_postprocess.py:52-63 | ppocr/postprocess/picodet_postprocess.py:82-93 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) ppocr/postprocess/rec_postprocess.py:151— ppocr/postprocess/rec_postprocess.py:151-162 | ppocr/postprocess/rec_postprocess.py:1064-1075 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/postprocess/rec_postprocess.py:151` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) ppstructure/kie/tools/eval_with_label_end2end.py:143— ppstructure/kie/tools/eval_with_label_end2end.py:143-154 | tools/end2end/eval_end2end.py:123-134 — before extracting anything, compare `ppstructure/kie/tools/eval_with_label_end2end.py` and `tools/end2end/eval_end2end.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) REDACTED:815— REDACTED:815-826 | ppocr/postprocess/table_postprocess.py:160-171 — 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (12 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:471— ppocr/utils/e2e_utils/extract_textpoint_fast.py:471-482 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:534-545 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 (12 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_slow.py:386— ppocr/utils/e2e_utils/extract_textpoint_slow.py:386-397 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:464-475 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) paddleocr/_doc2md/converters/docx.py:422— paddleocr/_doc2md/converters/docx.py:422-437 | paddleocr/_doc2md/converters/docx.py:443-458 — both copies are in the same file, so extract the 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) paddleocr/_pipelines/pp_chatocrv4_doc.py:184— paddleocr/_pipelines/pp_chatocrv4_doc.py:184-199 | paddleocr/_pipelines/pp_doctranslation.py:211-226 — before extracting anything, compare `paddleocr/_pipelines/pp_chatocrv4_doc.py` and `paddleocr/_pipelines/pp_doctranslation.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 372 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 `paddleocr/_pipelines/pp_chatocrv4_doc.py:184` 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 (16 lines × 2) ppocr/modeling/heads/det_sast_head.py:38— ppocr/modeling/heads/det_sast_head.py:38-53 | ppocr/modeling/necks/sast_fpn.py:37-52 — before extracting anything, compare `ppocr/modeling/heads/det_sast_head.py` and `ppocr/modeling/necks/sast_fpn.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/heads/det_sast_head.py:38` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:1132— ppocr/modeling/heads/rec_ppformulanet_head.py:1132-1147 | ppocr/modeling/heads/rec_ppformulanet_head.py:1250-1265 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/heads/rec_ppformulanet_head.py:1132` it begins part-way through the construct above it, so those exact lines 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) ppocr/modeling/heads/rec_ppformulanet_head.py:1159— ppocr/modeling/heads/rec_ppformulanet_head.py:1159-1174 | ppocr/modeling/heads/rec_ppformulanet_head.py:1274-1289 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/heads/rec_ppformulanet_head.py:1159` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) ppocr/modeling/necks/db_fpn.py:474— ppocr/modeling/necks/db_fpn.py:474-489 | ppocr/modeling/necks/db_fpn.py:866-881 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/necks/db_fpn.py:474` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) ppstructure/kie/tools/eval_with_label_end2end.py:71— ppstructure/kie/tools/eval_with_label_end2end.py:71-86 | tools/end2end/eval_end2end.py:48-63 — before extracting anything, compare `ppstructure/kie/tools/eval_with_label_end2end.py` and `tools/end2end/eval_end2end.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 42 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16 lines × 2) tools/infer_det.py:68— tools/infer_det.py:68-83 | tools/infer_e2e.py:114-129 — before extracting anything, compare `tools/infer_det.py` and `tools/infer_e2e.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 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 (16 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:818— ppocr/modeling/heads/rec_ppformulanet_head.py:818-833 | ppocr/modeling/heads/rec_unimernet_head.py:2264-2280 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (16 lines × 2) REDACTED:237— REDACTED:237-252 | REDACTED:357-372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) deploy/slim/quantization/export_model.py:69— deploy/slim/quantization/export_model.py:69-81 | ppocr/utils/export_model.py:422-434 — 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 `deploy/slim/quantization/export_model.py:69` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) ppocr/modeling/backbones/rec_resnet_32.py:292— ppocr/modeling/backbones/rec_resnet_32.py:292-304 | ppocr/modeling/backbones/rec_resnet_rfl.py:229-241 — before extracting anything, compare `ppocr/modeling/backbones/rec_resnet_32.py` and `ppocr/modeling/backbones/rec_resnet_rfl.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 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:55— REDACTED:55-67 | ppocr/modeling/backbones/rec_svtrv2.py:100-112 — before extracting anything, compare `REDACTED` and `ppocr/modeling/backbones/rec_svtrv2.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 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:300— REDACTED:300-312 | REDACTED:321-333 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift 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: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 (13 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:1062— ppocr/modeling/heads/rec_ppformulanet_head.py:1062-1074 | ppocr/modeling/heads/rec_ppformulanet_head.py:1202-1215 — both copies are in the same file, so extract the 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, `ppocr/modeling/heads/rec_ppformulanet_head.py:1076` calls `reshape` and `ppocr/modeling/heads/rec_ppformulanet_head.py:1217` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:1166— ppocr/modeling/heads/rec_ppformulanet_head.py:1166-1180 | ppocr/modeling/heads/rec_unimernet_head.py:2562-2574 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 `ppocr/modeling/heads/rec_ppformulanet_head.py:1166` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) ppocr/modeling/transforms/tbsrn.py:226— ppocr/modeling/transforms/tbsrn.py:226-238 | ppocr/modeling/transforms/tsrn.py:101-113 — before extracting anything, compare `ppocr/modeling/transforms/tbsrn.py` and `ppocr/modeling/transforms/tsrn.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 2) REDACTED:51— REDACTED:51-63 | REDACTED:25-37 — 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) ppstructure/pdf2word/pdf2word.py:392— ppstructure/pdf2word/pdf2word.py:392-404 | ppstructure/pdf2word/pdf2word.py:407-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.
Duplicated block (13 lines × 2) ppocr/utils/e2e_metric/Deteval.py:564— ppocr/utils/e2e_metric/Deteval.py:564-576 | ppocr/utils/e2e_metric/Deteval.py:579-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.
Duplicated block (20 lines × 2) deploy/slim/prune/sensitivity_anal.py:58— deploy/slim/prune/sensitivity_anal.py:58-77 | deploy/slim/quantization/quant.py:91-110 — 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 (20 lines × 2) paddleocr/_doc2md/converters/docx.py:330— paddleocr/_doc2md/converters/docx.py:330-349 | paddleocr/_doc2md/converters/docx.py:491-510 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot 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) ppocr/data/imaug/drrg_targets.py:667— ppocr/data/imaug/drrg_targets.py:667-686 | ppocr/data/imaug/fce_targets.py:552-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. 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 (20 lines × 2) ppocr/data/imaug/pg_process.py:882— ppocr/data/imaug/pg_process.py:882-901 | ppocr/data/imaug/sast_process.py:660-679 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:882` 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 (20 lines × 2) ppocr/modeling/backbones/rec_mv1_enhance.py:256— ppocr/modeling/backbones/rec_mv1_enhance.py:256-275 | test_tipc/supplementary/mv3.py:315-334 — 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 (20 lines × 2) ppocr/modeling/backbones/vqa_layoutlm.py:127— ppocr/modeling/backbones/vqa_layoutlm.py:127-146 | ppocr/modeling/backbones/vqa_layoutlm.py:169-188 — both copies are in the same file, so extract the 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) ppocr/modeling/necks/rnn.py:169— ppocr/modeling/necks/rnn.py:169-188 | ppocr/modeling/necks/rnn.py:287-306 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/necks/rnn.py:169` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) ppocr/postprocess/rec_postprocess.py:286— ppocr/postprocess/rec_postprocess.py:286-305 | ppocr/postprocess/rec_postprocess.py:364-383 — both copies are in the same file, so extract the 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) ppocr/utils/e2e_utils/extract_textpoint_slow.py:39— ppocr/utils/e2e_utils/extract_textpoint_slow.py:39-58 | ppocr/utils/e2e_utils/visual.py:96-115 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_slow.py` and `ppocr/utils/e2e_utils/visual.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 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 (18 lines × 2) ppocr/data/imaug/pg_process.py:482— ppocr/data/imaug/pg_process.py:482-499 | ppocr/data/imaug/sast_process.py:266-283 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 lines × 2) ppocr/losses/rec_sar_loss.py:18— ppocr/losses/rec_sar_loss.py:18-35 | ppocr/losses/rec_satrn_loss.py:35-52 — before extracting anything, compare `ppocr/losses/rec_sar_loss.py` and `ppocr/losses/rec_satrn_loss.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (18 lines × 2) ppocr/modeling/backbones/rec_resnet_32.py:273— ppocr/modeling/backbones/rec_resnet_32.py:273-290 | ppocr/modeling/backbones/rec_resnet_rfl.py:329-346 — before extracting anything, compare `ppocr/modeling/backbones/rec_resnet_32.py` and `ppocr/modeling/backbones/rec_resnet_rfl.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 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 lines × 2) REDACTED:259— REDACTED:259-276 | REDACTED:76-93 — 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:259` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) REDACTED:110— REDACTED:110-127 | REDACTED:94-111 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (18 lines × 2) ppstructure/table/matcher.py:119— ppstructure/table/matcher.py:119-136 | ppstructure/table/matcher.py:164-181 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, 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, `ppstructure/table/matcher.py:118` calls `extend` and `ppstructure/table/matcher.py:163` 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 (18 lines × 2) ppocr/utils/e2e_metric/Deteval.py:658— ppocr/utils/e2e_metric/Deteval.py:658-675 | ppocr/utils/e2e_metric/Deteval.py:678-695 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 3) deploy/slim/quantization/quant.py:48— deploy/slim/quantization/quant.py:48-56 | deploy/slim/quantization/quant_kl.py:50-58 | test_tipc/supplementary/slim/slim_quant.py:10-18 — before extracting anything, compare `deploy/slim/quantization/quant.py` and `test_tipc/supplementary/slim/slim_quant.py` as WHOLE FILES: 87% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 3) ppocr/losses/rec_att_loss.py:30— ppocr/losses/rec_att_loss.py:30-38 | ppocr/losses/rec_rfl_loss.py:50-58 | ppocr/losses/rec_spin_att_loss.py:39-47 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (9 lines × 3) ppocr/modeling/backbones/rec_resnet_32.py:262— ppocr/modeling/backbones/rec_resnet_32.py:262-270 | ppocr/modeling/backbones/rec_resnet_rfl.py:199-207 | ppocr/modeling/backbones/rec_resnet_rfl.py:318-326 — before extracting anything, compare `ppocr/modeling/backbones/rec_resnet_32.py` and `ppocr/modeling/backbones/rec_resnet_rfl.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 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 `ppocr/modeling/backbones/rec_resnet_32.py:262` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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) ppocr/postprocess/rec_postprocess.py:1241— ppocr/postprocess/rec_postprocess.py:1241-1249 | ppocr/postprocess/rec_postprocess.py:1500-1508 | ppocr/postprocess/rec_postprocess.py:1525-1533 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 3) mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:64— mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:64-72 | mcp_server/paddleocr_mcp/inference/paddleocr_vl/aistudio.py:65-73 | mcp_server/paddleocr_mcp/inference/pp_structurev3/aistudio.py:65-73 — `mcp_server/paddleocr_mcp/inference/paddleocr_vl/aistudio.py` and `mcp_server/paddleocr_mcp/inference/pp_structurev3/aistudio.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 27 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
Duplicated block (9 lines × 3) ppocr/modeling/heads/rec_att_head.py:27— ppocr/modeling/heads/rec_att_head.py:27-35 | ppocr/modeling/heads/rec_att_head.py:120-128 | ppocr/modeling/heads/rec_spin_att_head.py:31-39 — before extracting anything, compare `ppocr/modeling/heads/rec_att_head.py` and `ppocr/modeling/heads/rec_spin_att_head.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 81 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 3) REDACTED:107— REDACTED:107-115 | REDACTED:227-235 | REDACTED:338-346 — 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:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) paddleocr/_pipelines/ocr.py:113— paddleocr/_pipelines/ocr.py:113-127 | paddleocr/_pipelines/pp_structurev3.py:120-134 — before extracting anything, compare `paddleocr/_pipelines/ocr.py` and `paddleocr/_pipelines/pp_structurev3.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 233 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (15 lines × 2) ppocr/data/imaug/pg_process.py:649— ppocr/data/imaug/pg_process.py:649-663 | ppocr/data/imaug/sast_process.py:434-448 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (15 lines × 2) REDACTED:1641— REDACTED:1641-1655 | REDACTED:1699-1713 — both copies are in the same file, so extract the 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) ppocr/modeling/heads/rec_ppformulanet_head.py:106— ppocr/modeling/heads/rec_ppformulanet_head.py:106-120 | ppocr/modeling/heads/rec_ppformulanet_head.py:151-165 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/heads/rec_ppformulanet_head.py:106` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot 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) tools/infer_rec.py:97— tools/infer_rec.py:97-111 | tools/infer_sr.py:50-64 — 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 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:50— ppocr/utils/e2e_utils/extract_textpoint_fast.py:50-64 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:115-129 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 `ppocr/utils/e2e_utils/extract_textpoint_fast.py:50` 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.
D4 · Code Duplication· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×5
Members sharing a duplicated core (5 members, 50+ identical tokens) ppocr/data/imaug/east_process.py:292— ppocr/data/imaug/east_process.py:292-364 | ppocr/data/imaug/fce_aug.py:188-224 | ppocr/data/imaug/pg_process.py:158-236 | ppocr/data/imaug/random_crop_data.py:417-463 | ppocr/data/imaug/sast_process.py:135-207 — 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) ppocr/losses/distillation_loss.py:89— ppocr/losses/distillation_loss.py:89-99 | ppocr/losses/distillation_loss.py:185-195 | ppocr/losses/distillation_loss.py:293-303 | ppocr/losses/distillation_loss.py:439-449 | ppocr/losses/distillation_loss.py:547-557 — 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) ppocr/losses/rec_att_loss.py:29— ppocr/losses/rec_att_loss.py:29-43 | ppocr/losses/rec_rfl_loss.py:36-70 | ppocr/losses/rec_sar_loss.py:18-36 | ppocr/losses/rec_satrn_loss.py:35-53 | ppocr/losses/rec_spin_att_loss.py:36-52 — 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) ppocr/modeling/backbones/det_resnet.py:75— ppocr/modeling/backbones/det_resnet.py:75-86 | ppocr/modeling/backbones/det_resnet_vd.py:202-212 | ppocr/modeling/backbones/det_resnet_vd_sast.py:124-134 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:122-132 | ppocr/modeling/backbones/rec_resnet_vd.py:124-135 — 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) ppocr/postprocess/rec_postprocess.py:316— ppocr/postprocess/rec_postprocess.py:316-333 | ppocr/postprocess/rec_postprocess.py:395-420 | ppocr/postprocess/rec_postprocess.py:743-753 | ppocr/postprocess/rec_postprocess.py:818-828 | ppocr/postprocess/rec_postprocess.py:935-960 — 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 (21 lines × 2) deploy/slim/prune/export_prune_model.py:45— deploy/slim/prune/export_prune_model.py:45-65 | deploy/slim/prune/sensitivity_anal.py:72-92 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (21 lines × 2) ppocr/data/imaug/table_ops.py:49— ppocr/data/imaug/table_ops.py:49-69 | ppocr/data/imaug/table_ops.py:100-120 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot 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) ppocr/metrics/det_metric.py:31— ppocr/metrics/det_metric.py:31-51 | ppocr/metrics/det_metric.py:81-102 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/metrics/det_metric.py:31` 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 lines × 2) ppocr/modeling/necks/fpn.py:39— ppocr/modeling/necks/fpn.py:39-59 | ppocr/modeling/necks/fpn.py:100-120 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (21 lines × 2) tools/infer/predict_rec.py:782— tools/infer/predict_rec.py:782-802 | tools/infer/predict_rec.py:805-825 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 3) mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:89— mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:89-100 | mcp_server/paddleocr_mcp/inference/paddleocr_vl/aistudio.py:91-102 | mcp_server/paddleocr_mcp/inference/pp_structurev3/aistudio.py:92-103 — `mcp_server/paddleocr_mcp/inference/paddleocr_vl/aistudio.py` and `mcp_server/paddleocr_mcp/inference/pp_structurev3/aistudio.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 27 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:89` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 3) REDACTED:369— REDACTED:369-380 | REDACTED:405-416 | REDACTED:514-525 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:367` calls `randint`, `__len__` and `REDACTED:404` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) ppocr/modeling/backbones/det_resnet_vd.py:316— ppocr/modeling/backbones/det_resnet_vd.py:316-327 | ppocr/modeling/backbones/det_resnet_vd_sast.py:261-272 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:241-252 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd.py` and `ppocr/modeling/backbones/det_resnet_vd_sast.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 76 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 `ppocr/modeling/backbones/det_resnet_vd.py:316` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) ppocr/modeling/heads/rec_srn_head.py:57— ppocr/modeling/heads/rec_srn_head.py:57-68 | ppocr/modeling/heads/rec_srn_head.py:141-152 | ppocr/modeling/heads/rec_srn_head.py:158-169 — 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 `ppocr/modeling/heads/rec_srn_head.py:57` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 3) tools/infer/predict_rec.py:718— tools/infer/predict_rec.py:718-729 | tools/infer/predict_rec.py:742-753 | tools/infer/predict_rec.py:765-776 — 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 `tools/infer/predict_rec.py:718` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) ppocr/data/imaug/unimernet_aug.py:556— ppocr/data/imaug/unimernet_aug.py:556-563 | ppocr/data/imaug/unimernet_aug.py:696-703 | ppocr/data/imaug/unimernet_aug.py:795-802 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 3) configs/rec/multi_language/generate_multi_language_configs.py:177— configs/rec/multi_language/generate_multi_language_configs.py:177-184 | test_tipc/supplementary/config.py:35-42 | tools/program.py:65-72 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 3) ppocr/data/imaug/pg_process.py:58— ppocr/data/imaug/pg_process.py:58-65 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:28-35 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:28-35 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The `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) ppocr/modeling/backbones/det_pp_lcnet.py:153— ppocr/modeling/backbones/det_pp_lcnet.py:153-160 | ppocr/modeling/backbones/det_pp_lcnet_v2.py:108-115 | ppocr/modeling/backbones/rec_lcnetv3.py:349-356 — 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) REDACTED:171— REDACTED:171-178 | REDACTED:287-294 | REDACTED:421-428 — 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 (27 lines × 2) ppocr/data/imaug/drrg_targets.py:83— ppocr/data/imaug/drrg_targets.py:83-109 | ppocr/data/imaug/fce_targets.py:184-210 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (27 lines × 2) ppocr/data/imaug/drrg_targets.py:149— ppocr/data/imaug/drrg_targets.py:149-175 | ppocr/data/imaug/fce_targets.py:250-276 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/data/imaug/drrg_targets.py:149` it begins part-way through the construct above it, so those 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 (27 lines × 2) ppocr/utils/e2e_metric/Deteval.py:512— ppocr/utils/e2e_metric/Deteval.py:512-538 | ppocr/utils/e2e_metric/Deteval.py:606-632 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (27 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:228— ppocr/utils/e2e_utils/extract_textpoint_fast.py:228-254 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:256-282 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 (16–17 lines × 2) REDACTED:80— REDACTED:80-96 | REDACTED:20-35 — 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16–17 lines × 2) ppocr/modeling/necks/east_fpn.py:80— ppocr/modeling/necks/east_fpn.py:80-95 | ppocr/modeling/necks/pg_fpn.py:86-102 — before extracting anything, compare `ppocr/modeling/necks/east_fpn.py` and `ppocr/modeling/necks/pg_fpn.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 43 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 `ppocr/modeling/necks/east_fpn.py:80` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–17 lines × 2) ppocr/modeling/transforms/tbsrn.py:155— ppocr/modeling/transforms/tbsrn.py:155-171 | ppocr/modeling/transforms/tsrn.py:59-74 — before extracting anything, compare `ppocr/modeling/transforms/tbsrn.py` and `ppocr/modeling/transforms/tsrn.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/transforms/tbsrn.py:155` it begins part-way through the construct above it, so those exact lines 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) REDACTED:181— REDACTED:181-196 | REDACTED:297-313 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11–12 lines × 3) deploy/slim/quantization/export_model.py:96— deploy/slim/quantization/export_model.py:96-106 | deploy/slim/quantization/quant.py:130-140 | tools/train.py:108-119 — before extracting anything, compare `deploy/slim/quantization/export_model.py` and `deploy/slim/quantization/quant.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (11–12 lines × 3) REDACTED:147— REDACTED:147-157 | REDACTED:161-171 | REDACTED:178-189 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:147` it begins part-way through the construct above it, so those 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 first that the copies are not typed on the same thing: `Callable` names `collections` in one and `collections.abc` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (11–12 lines × 3) ppocr/modeling/heads/rec_att_head.py:104— ppocr/modeling/heads/rec_att_head.py:104-115 | ppocr/modeling/heads/rec_att_head.py:205-215 | ppocr/modeling/heads/rec_spin_att_head.py:114-124 — before extracting anything, compare `ppocr/modeling/heads/rec_att_head.py` and `ppocr/modeling/heads/rec_spin_att_head.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 81 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (11–12 lines × 3) REDACTED:180— REDACTED:180-190 | REDACTED:296-307 | REDACTED:430-440 — 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:180` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 3) ppocr/data/imaug/pg_process.py:677— ppocr/data/imaug/pg_process.py:677-687 | ppocr/data/imaug/sast_process.py:65-75 | ppocr/data/imaug/sast_process.py:462-472 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:677` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 3) ppocr/data/pgnet_dataset.py:61— ppocr/data/pgnet_dataset.py:61-71 | ppocr/data/pubtab_dataset.py:58-68 | REDACTED:291-301 — 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 (11 lines × 3) ppocr/postprocess/rec_postprocess.py:545— ppocr/postprocess/rec_postprocess.py:545-555 | ppocr/postprocess/rec_postprocess.py:706-716 | ppocr/postprocess/rec_postprocess.py:781-791 — 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 (11 lines × 3) mcp_server/paddleocr_mcp/inference/ocr/local.py:88— mcp_server/paddleocr_mcp/inference/ocr/local.py:88-98 | mcp_server/paddleocr_mcp/inference/paddleocr_vl/local.py:77-87 | mcp_server/paddleocr_mcp/inference/pp_structurev3/local.py:62-72 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The `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 × 4) ppocr/data/imaug/pg_process.py:90— ppocr/data/imaug/pg_process.py:90-96 | ppocr/data/imaug/pg_process.py:681-687 | ppocr/data/imaug/sast_process.py:69-75 | ppocr/data/imaug/sast_process.py:466-472 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:90` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 4) ppocr/postprocess/rec_postprocess.py:290— ppocr/postprocess/rec_postprocess.py:290-296 | ppocr/postprocess/rec_postprocess.py:368-374 | ppocr/postprocess/rec_postprocess.py:710-716 | ppocr/postprocess/rec_postprocess.py:785-791 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ppocr/postprocess/rec_postprocess.py:289` calls `get_ignored_tokens` and `ppocr/postprocess/rec_postprocess.py:708` 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 (7 lines × 4) tools/eval.py:56— tools/eval.py:56-62 | tools/eval.py:72-78 | tools/infer_rec.py:66-72 | tools/infer_rec.py:83-89 — before extracting anything, compare `tools/eval.py` and `tools/infer_rec.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. 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, `tools/infer_rec.py:82` calls `getattr` and `tools/eval.py:71` 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 (7 lines × 4) REDACTED:104— REDACTED:104-110 | ppocr/modeling/backbones/rec_svtrv2.py:71-77 | REDACTED:71-77 | REDACTED:81-87 — before extracting anything, compare `REDACTED` and `ppocr/modeling/backbones/rec_svtrv2.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication· Members sharing a duplicated core (9 members, 50+ identical tokens) · ×3
Members sharing a duplicated core (9 members, 50+ identical tokens) deploy/hubserving/kie_ser/module.py:50— deploy/hubserving/kie_ser/module.py:50-70 | deploy/hubserving/kie_ser_re/module.py:50-70 | deploy/hubserving/ocr_cls/module.py:46-66 | deploy/hubserving/ocr_det/module.py:48-68 | deploy/hubserving/ocr_rec/module.py:46-66 | deploy/hubserving/ocr_system/module.py:49-69 | deploy/hubserving/structure_layout/module.py:48-67 | deploy/hubserving/structure_system/module.py:50-70 | deploy/hubserving/structure_table/module.py:50-69 — These 9 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 9 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 9 times.
Members sharing a duplicated core (9 members, 50+ identical tokens) deploy/hubserving/kie_ser/module.py:76— deploy/hubserving/kie_ser/module.py:76-86 | deploy/hubserving/kie_ser_re/module.py:76-86 | deploy/hubserving/ocr_cls/module.py:72-82 | deploy/hubserving/ocr_det/module.py:74-84 | deploy/hubserving/ocr_rec/module.py:72-82 | deploy/hubserving/ocr_system/module.py:75-85 | deploy/hubserving/structure_layout/module.py:71-81 | deploy/hubserving/structure_system/module.py:74-84 | deploy/hubserving/structure_table/module.py:73-83 — These 9 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 9 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 9 times.
Members sharing a duplicated core (9 members, 50+ identical tokens) deploy/hubserving/kie_ser/module.py:102— deploy/hubserving/kie_ser/module.py:102-132 | deploy/hubserving/kie_ser_re/module.py:102-134 | deploy/hubserving/ocr_cls/module.py:98-139 | deploy/hubserving/ocr_det/module.py:100-135 | deploy/hubserving/ocr_rec/module.py:98-139 | deploy/hubserving/ocr_system/module.py:101-145 | deploy/hubserving/structure_layout/module.py:97-131 | deploy/hubserving/structure_system/module.py:100-137 | deploy/hubserving/structure_table/module.py:99-131 — These 9 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 9 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 9 times.
D4 · Code Duplication· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×3
Members sharing a duplicated core (6 members, 50+ identical tokens) REDACTED:327— REDACTED:327-347 | REDACTED:372-387 | REDACTED:390-417 | ppocr/utils/e2e_utils/visual.py:20-46 | ppocr/utils/e2e_utils/visual.py:50-70 | ppocr/utils/e2e_utils/visual.py:74-92 — 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) ppocr/data/imaug/pg_process.py:702— ppocr/data/imaug/pg_process.py:702-710 | ppocr/data/imaug/sast_process.py:487-495 | ppocr/postprocess/sast_postprocess.py:68-76 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:329-332 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:62-68 | ppocr/utils/e2e_utils/visual.py:119-125 — 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) ppocr/postprocess/rec_postprocess.py:286— ppocr/postprocess/rec_postprocess.py:286-313 | ppocr/postprocess/rec_postprocess.py:364-391 | ppocr/postprocess/rec_postprocess.py:464-488 | ppocr/postprocess/rec_postprocess.py:545-571 | ppocr/postprocess/rec_postprocess.py:706-740 | ppocr/postprocess/rec_postprocess.py:781-815 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Duplicated block (25 lines × 2) configs/rec/multi_language/generate_multi_language_configs.py:222— configs/rec/multi_language/generate_multi_language_configs.py:222-246 | test_tipc/supplementary/config.py:82-106 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (25 lines × 2) ppocr/data/imaug/east_process.py:75— ppocr/data/imaug/east_process.py:75-99 | ppocr/data/imaug/pg_process.py:913-937 — 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) REDACTED:78— REDACTED:78-124 | REDACTED:38-62 — 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 `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 (22–23 lines × 2) paddleocr/_pipelines/paddleocr_vl.py:428— paddleocr/_pipelines/paddleocr_vl.py:428-449 | paddleocr/_pipelines/pp_structurev3.py:1003-1025 — before extracting anything, compare `paddleocr/_pipelines/paddleocr_vl.py` and `paddleocr/_pipelines/pp_structurev3.py` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 354 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 `paddleocr/_pipelines/paddleocr_vl.py:428` it begins part-way through the construct above it, so those exact lines 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) ppocr/data/imaug/drrg_targets.py:709— ppocr/data/imaug/drrg_targets.py:709-731 | ppocr/data/imaug/fce_targets.py:658-679 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (22–23 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:978— ppocr/modeling/heads/rec_ppformulanet_head.py:978-1000 | ppocr/modeling/heads/rec_unimernet_head.py:2165-2186 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (22 lines × 2) ppocr/modeling/necks/db_fpn.py:523— ppocr/modeling/necks/db_fpn.py:523-544 | ppocr/modeling/necks/db_fpn.py:912-933 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/necks/db_fpn.py:523` it begins part-way through the construct above it, so those exact lines 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) ppocr/utils/e2e_metric/Deteval.py:547— ppocr/utils/e2e_metric/Deteval.py:547-568 | ppocr/utils/e2e_metric/Deteval.py:641-662 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/utils/e2e_metric/Deteval.py:547` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) REDACTED:107— REDACTED:107-128 | REDACTED:338-359 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) ppocr/data/imaug/pg_process.py:668— ppocr/data/imaug/pg_process.py:668-686 | ppocr/data/imaug/sast_process.py:453-471 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:668` 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 × 2) ppocr/modeling/backbones/kie_unet_sdmgr.py:30— ppocr/modeling/backbones/kie_unet_sdmgr.py:30-48 | ppocr/modeling/backbones/kie_unet_sdmgr.py:65-83 — both copies are in the same file, so extract the block into 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) ppocr/utils/e2e_metric/Deteval.py:25— ppocr/utils/e2e_metric/Deteval.py:25-43 | ppocr/utils/e2e_metric/Deteval.py:179-197 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17–18 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:210— ppocr/modeling/heads/rec_ppformulanet_head.py:210-227 | ppocr/modeling/heads/rec_unimernet_head.py:351-367 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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–18 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:791— ppocr/modeling/heads/rec_ppformulanet_head.py:791-807 | ppocr/modeling/heads/rec_unimernet_head.py:2118-2135 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 `ppocr/modeling/heads/rec_unimernet_head.py:2118` it begins part-way through the construct above it, so those exact lines 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–18 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:427— ppocr/utils/e2e_utils/extract_textpoint_fast.py:427-444 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:605-621 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 (10–12 lines × 2) ppocr/data/imaug/pg_process.py:553— ppocr/data/imaug/pg_process.py:553-564 | ppocr/data/imaug/sast_process.py:325-334 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:553` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–12 lines × 2) ppocr/data/pgnet_dataset.py:33— ppocr/data/pgnet_dataset.py:33-42 | ppocr/data/pubtab_dataset.py:33-44 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (10–12 lines × 2) tools/infer_rec.py:125— tools/infer_rec.py:125-136 | tools/infer_sr.py:65-74 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (10–11 lines × 2) ppocr/data/imaug/pg_process.py:991— ppocr/data/imaug/pg_process.py:991-1000 | ppocr/data/imaug/sast_process.py:723-733 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:991` it begins part-way through the construct above it, so those 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–11 lines × 2) ppocr/postprocess/rec_postprocess.py:1024— ppocr/postprocess/rec_postprocess.py:1024-1034 | ppocr/postprocess/rec_postprocess.py:1207-1216 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10–11 lines × 2) ppocr/postprocess/sast_postprocess.py:296— ppocr/postprocess/sast_postprocess.py:296-306 | ppocr/utils/e2e_utils/pgnet_pp_utils.py:132-141 — 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 `ppocr/postprocess/sast_postprocess.py:296` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) deploy/slim/quantization/export_model.py:76— deploy/slim/quantization/export_model.py:76-85 | deploy/slim/quantization/quant.py:110-119 | tools/train.py:81-90 — before extracting anything, compare `deploy/slim/quantization/export_model.py` and `deploy/slim/quantization/quant.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 3) ppocr/modeling/backbones/det_resnet_vd.py:341— ppocr/modeling/backbones/det_resnet_vd.py:341-350 | ppocr/modeling/backbones/det_resnet_vd_sast.py:286-295 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:266-275 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd.py` and `ppocr/modeling/backbones/det_resnet_vd_sast.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 76 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 `ppocr/modeling/backbones/det_resnet_vd.py:341` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) REDACTED:1630— REDACTED:1630-1639 | REDACTED:1688-1697 | ppocr/modeling/backbones/rec_vary_vit.py:591-600 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ppocr/modeling/backbones/rec_vary_vit.py:587` calls `Linear` and `REDACTED:1627` 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–10 lines × 2) REDACTED:478— REDACTED:478-487 | tools/infer/predict_rec.py:417-425 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (9–10 lines × 2) ppocr/modeling/heads/rec_robustscanner_head.py:228— ppocr/modeling/heads/rec_robustscanner_head.py:228-236 | ppocr/modeling/heads/rec_robustscanner_head.py:306-315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–10 lines × 2) REDACTED:223— REDACTED:223-232 | REDACTED:162-170 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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, `REDACTED:234` calls `info` and `REDACTED:171` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–9 lines × 3) deploy/slim/quantization/export_model.py:119— deploy/slim/quantization/export_model.py:119-127 | deploy/slim/quantization/quant.py:153-160 | tools/train.py:136-144 — before extracting anything, compare `deploy/slim/quantization/export_model.py` and `deploy/slim/quantization/quant.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (8–9 lines × 3) mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:117— mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:117-124 | mcp_server/paddleocr_mcp/inference/ocr/local.py:114-122 | mcp_server/paddleocr_mcp/inference/shared/http_result_parsers.py:31-38 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `mcp_server/paddleocr_mcp/inference/ocr/aistudio.py:117` 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–9 lines × 3) tools/infer_det.py:94— tools/infer_det.py:94-102 | tools/infer_e2e.py:133-140 | tools/infer_table.py:85-93 — before extracting anything, compare `tools/infer_det.py` and `tools/infer_e2e.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 4) deploy/avh/convert_image.py:34— deploy/avh/convert_image.py:34-41 | REDACTED:637-644 | REDACTED:474-482 | tools/infer/predict_rec.py:438-445 — before extracting anything, compare `deploy/avh/convert_image.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:474` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 4) ppocr/losses/rec_att_loss.py:31— ppocr/losses/rec_att_loss.py:31-38 | ppocr/losses/rec_sar_loss.py:24-31 | ppocr/losses/rec_satrn_loss.py:41-48 | ppocr/losses/rec_spin_att_loss.py:40-47 — before extracting anything, compare `ppocr/losses/rec_sar_loss.py` and `ppocr/losses/rec_satrn_loss.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 4) ppocr/modeling/backbones/det_resnet.py:178— ppocr/modeling/backbones/det_resnet.py:178-185 | ppocr/modeling/backbones/det_resnet_vd_sast.py:254-261 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:234-241 | ppocr/modeling/backbones/rec_resnet_fpn.py:54-61 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet.py` and `ppocr/modeling/backbones/det_resnet_vd_sast.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 45 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 `ppocr/modeling/backbones/det_resnet.py:178` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–8 lines × 2) ppocr/modeling/transforms/gaspin_transformer.py:157— ppocr/modeling/transforms/gaspin_transformer.py:157-164 | ppocr/modeling/transforms/gaspin_transformer.py:174-180 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7–8 lines × 2) ppocr/utils/formula_utils/unimernet_data_convert.py:27— ppocr/utils/formula_utils/unimernet_data_convert.py:27-33 | ppocr/utils/formula_utils/unimernet_data_convert.py:54-61 — both copies are in the same file, so extract the 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, `ppocr/utils/formula_utils/unimernet_data_convert.py:34` calls `join` and `ppocr/utils/formula_utils/unimernet_data_convert.py:62` 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–8 lines × 2) tools/infer_cls.py:66— tools/infer_cls.py:66-73 | tools/infer_e2e.py:131-137 — 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, `tools/infer_e2e.py:138` calls `expand_dims` and `tools/infer_cls.py:74` 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 × 3) ppocr/losses/distillation_loss.py:763— ppocr/losses/distillation_loss.py:763-769 | ppocr/losses/distillation_loss.py:823-829 | ppocr/losses/distillation_loss.py:902-908 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 3) ppocr/modeling/backbones/det_resnet_vd.py:334— ppocr/modeling/backbones/det_resnet_vd.py:334-340 | ppocr/modeling/backbones/det_resnet_vd_sast.py:278-284 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:258-264 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd.py` and `ppocr/modeling/backbones/det_resnet_vd_sast.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 76 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, `ppocr/modeling/backbones/det_resnet_vd_sast.py:285` calls `str`, `chr` and `ppocr/modeling/backbones/det_resnet_vd.py:341` 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 (7 lines × 3) REDACTED:118— REDACTED:118-124 | REDACTED:216-222 | REDACTED:349-355 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 4) ppocr/data/imaug/east_process.py:311— ppocr/data/imaug/east_process.py:311-316 | ppocr/data/imaug/fce_aug.py:218-223 | ppocr/data/imaug/pg_process.py:177-182 | ppocr/data/imaug/sast_process.py:154-159 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
Duplicated block (6 lines × 4) paddleocr/_pipelines/formula_recognition.py:49— paddleocr/_pipelines/formula_recognition.py:49-54 | paddleocr/_pipelines/pp_chatocrv4_doc.py:73-78 | paddleocr/_pipelines/pp_doctranslation.py:93-98 | paddleocr/_pipelines/table_recognition_v2.py:61-66 — before extracting anything, compare `paddleocr/_pipelines/formula_recognition.py` and `paddleocr/_pipelines/pp_chatocrv4_doc.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 134 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 4) REDACTED:113— REDACTED:113-118 | ppocr/modeling/backbones/rec_svtrv2.py:80-85 | REDACTED:80-85 | REDACTED:90-95 — before extracting anything, compare `REDACTED` and `ppocr/modeling/backbones/rec_svtrv2.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 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 (6 lines × 3) ppocr/data/collate_fn.py:32— ppocr/data/collate_fn.py:32-37 | ppocr/data/collate_fn.py:52-57 | tools/infer_kie_token_ser.py:50-55 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (6 lines × 3) ppocr/data/imaug/pg_process.py:509— ppocr/data/imaug/pg_process.py:509-514 | ppocr/data/imaug/sast_process.py:290-295 | ppocr/data/imaug/sast_process.py:367-372 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:509` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 3) tools/infer_cls.py:67— tools/infer_cls.py:67-73 | tools/infer_det.py:93-99 | tools/infer_e2e.py:132-137 — before extracting anything, compare `tools/infer_det.py` and `tools/infer_e2e.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 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, `tools/infer_det.py:100` calls `expand_dims` and `tools/infer_cls.py:74` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 3) ppocr/modeling/backbones/table_master_resnet.py:268— ppocr/modeling/backbones/table_master_resnet.py:268-272 | ppocr/modeling/backbones/table_master_resnet.py:275-279 | ppocr/modeling/backbones/table_master_resnet.py:284-288 — 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 `ppocr/modeling/backbones/table_master_resnet.py:268` it begins part-way through the construct above it, so those 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, `ppocr/modeling/backbones/table_master_resnet.py:281` calls `Conv2D` and `ppocr/modeling/backbones/table_master_resnet.py:273` 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) ppocr/modeling/backbones/det_resnet_vd.py:149— ppocr/modeling/backbones/det_resnet_vd.py:149-153 | ppocr/modeling/backbones/det_resnet_vd_sast.py:69-73 | ppocr/modeling/backbones/rec_resnet_vd.py:69-73 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd.py` and `ppocr/modeling/backbones/det_resnet_vd_sast.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 76 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 (5 lines × 3) ppocr/modeling/backbones/rec_donut_swin.py:122— ppocr/modeling/backbones/rec_donut_swin.py:122-126 | ppocr/modeling/backbones/rec_donut_swin.py:157-161 | ppocr/modeling/heads/rec_unimernet_head.py:126-130 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2 locations) api_sdk/typescript/src/client.ts:354— api_sdk/typescript/src/client.ts:354 · api_sdk/typescript/src/internal/poller.ts:150 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another.
Duplicated block (9 lines × 2 locations) api_sdk/typescript/src/internal/http.ts:116— api_sdk/typescript/src/internal/http.ts:116 · api_sdk/typescript/src/internal/http.ts:126 — both copies are in the same file, so extract the block into 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) paddleocr-js/packages/core/src/viz/ocr/renderer.ts:47— paddleocr-js/packages/core/src/viz/ocr/renderer.ts:47 · paddleocr-js/packages/core/src/viz/ocr/renderer.ts:57 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
HackComment paddleocr/_pipelines/pp_doctranslation.py:323— # HACK: We should consider reducing duplication. — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
HackComment tools/infer/utility.py:460— # HACK — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
FixmeComment paddleocr/_pipelines/pp_doctranslation.py:902— # FIXME: Passing API key through CLI is not secure; consider using — 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.
FixmeComment paddleocr/_pipelines/pp_chatocrv4_doc.py:671— # FIXME: Passing API key through CLI is not secure; consider using — 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.
XxxComment REDACTED:71— # XXX: `term_mp` kills all processes in the process group, which in — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
XxxComment tools/infer/utility.py:488— # XXX: Currently we have no way to get the data type of the tensor — 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.
DistillationKLDivLoss.forward (cognitive 31) ppocr/losses/distillation_loss.py:197— DistillationKLDivLoss.forward has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 4 (13 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 4 other methods here (DistillationDMLLoss.forward, DistillationDKDLoss.forward, DistillationKLDivLoss.forward, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 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.
DistillationKLDivLoss.forward (cognitive 31) ppocr/losses/distillation_loss.py:451— DistillationKLDivLoss.forward has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 4 (13 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 4 other methods here (DistillationDMLLoss.forward, DistillationKLDivLoss.forward, DistillationDKDLoss.forward, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 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.
DistillationDKDLoss.forward (cognitive 31) ppocr/losses/distillation_loss.py:305— DistillationDKDLoss.forward has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 4 (13 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 4 other methods here (DistillationDMLLoss.forward, DistillationKLDivLoss.forward, DistillationKLDivLoss.forward, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 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.
DistillationDKDLoss.forward (cognitive 31) ppocr/losses/distillation_loss.py:559— DistillationDKDLoss.forward has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 4 (13 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 4 other methods here (DistillationDMLLoss.forward, DistillationKLDivLoss.forward, DistillationDKDLoss.forward, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 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.
TooManyFields: PPStructureV3Options api_sdk/go/models.go:66— TooManyFields — 32 stored fields beside 1 method. The bar is 30 stored fields; this is 2 over it, 1.07× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: PaddleOCRVLOptions api_sdk/go/models.go:101— TooManyFields — 31 stored fields beside 1 method. The bar is 30 stored fields; this is 1 over it, 1.03× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
Duplicated block (33 lines × 2) ppocr/modeling/heads/rec_att_head.py:49— ppocr/modeling/heads/rec_att_head.py:49-81 | ppocr/modeling/heads/rec_spin_att_head.py:56-88 — before extracting anything, compare `ppocr/modeling/heads/rec_att_head.py` and `ppocr/modeling/heads/rec_spin_att_head.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 81 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (33 lines × 2) ppocr/postprocess/rec_postprocess.py:708— ppocr/postprocess/rec_postprocess.py:708-740 | ppocr/postprocess/rec_postprocess.py:783-815 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (32 lines × 2) ppocr/data/imaug/pg_process.py:848— ppocr/data/imaug/pg_process.py:848-879 | ppocr/data/imaug/sast_process.py:626-657 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (32 lines × 2) REDACTED:597— REDACTED:597-628 | tools/infer/predict_rec.py:360-391 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. 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 (27–28 lines × 2) paddleocr/_pipelines/doc_preprocessor.py:116— paddleocr/_pipelines/doc_preprocessor.py:116-142 | paddleocr/_pipelines/paddleocr_vl.py:386-413 — before extracting anything, compare `paddleocr/_pipelines/doc_preprocessor.py` and `paddleocr/_pipelines/paddleocr_vl.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 93 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 `paddleocr/_pipelines/doc_preprocessor.py:116` it begins part-way through the construct above it, so those exact lines 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–28 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:501— ppocr/modeling/heads/rec_ppformulanet_head.py:501-528 | ppocr/modeling/heads/rec_unimernet_head.py:1076-1102 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (28 lines × 2) tools/program.py:619— tools/program.py:619-646 | tools/program.py:658-685 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/program.py:619` 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 lines × 2) ppocr/utils/e2e_metric/Deteval.py:125— ppocr/utils/e2e_metric/Deteval.py:125-152 | ppocr/utils/e2e_metric/Deteval.py:256-283 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (26–27 lines × 2) ppocr/data/imaug/pg_process.py:504— ppocr/data/imaug/pg_process.py:504-529 | ppocr/data/imaug/sast_process.py:285-311 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (26–27 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:941— ppocr/modeling/heads/rec_ppformulanet_head.py:941-966 | ppocr/modeling/heads/rec_unimernet_head.py:2383-2409 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (24 lines × 3) paddleocr/_pipelines/formula_recognition.py:240— paddleocr/_pipelines/formula_recognition.py:240-263 | paddleocr/_pipelines/pp_chatocrv4_doc.py:593-616 | paddleocr/_pipelines/seal_recognition.py:326-349 — before extracting anything, compare `paddleocr/_pipelines/formula_recognition.py` and `paddleocr/_pipelines/pp_chatocrv4_doc.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 134 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `paddleocr/_pipelines/formula_recognition.py:240` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24 lines × 3) ppocr/utils/e2e_utils/extract_textpoint_fast.py:341— ppocr/utils/e2e_utils/extract_textpoint_fast.py:341-364 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:77-100 | ppocr/utils/e2e_utils/visual.py:134-157 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 `ppocr/utils/e2e_utils/extract_textpoint_fast.py:341` 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 (20 lines × 3) paddleocr/_pipelines/paddleocr_vl.py:427— paddleocr/_pipelines/paddleocr_vl.py:427-446 | paddleocr/_pipelines/pp_doctranslation.py:884-906 | paddleocr/_pipelines/pp_structurev3.py:1002-1022 — before extracting anything, compare `paddleocr/_pipelines/paddleocr_vl.py` and `paddleocr/_pipelines/pp_doctranslation.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 301 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 `paddleocr/_pipelines/paddleocr_vl.py:427` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 3) ppocr/modeling/backbones/det_resnet_vd_sast.py:39— ppocr/modeling/backbones/det_resnet_vd_sast.py:39-58 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:39-58 | ppocr/modeling/necks/pg_fpn.py:37-56 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd_sast.py` and `ppocr/modeling/backbones/e2e_resnet_vd_pg.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 266 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 (19–20 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:333— ppocr/modeling/heads/rec_ppformulanet_head.py:333-352 | ppocr/modeling/heads/rec_unimernet_head.py:450-468 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (19–20 lines × 2) ppstructure/table/predict_structure.py:130— ppstructure/table/predict_structure.py:130-148 | tools/infer/predict_det.py:258-277 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (16–18 lines × 2) ppocr/modeling/heads/det_db_head.py:116— ppocr/modeling/heads/det_db_head.py:116-133 | ppocr/modeling/necks/db_fpn.py:774-789 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (16–18 lines × 2) ppocr/modeling/heads/local_graph.py:337— ppocr/modeling/heads/local_graph.py:337-352 | ppocr/modeling/heads/proposal_local_graph.py:382-399 — 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 `ppocr/modeling/heads/proposal_local_graph.py:382` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 4) paddleocr/_pipelines/paddleocr_vl.py:186— paddleocr/_pipelines/paddleocr_vl.py:186-201 | paddleocr/_pipelines/pp_structurev3.py:261-276 | paddleocr/_pipelines/seal_recognition.py:146-161 | paddleocr/_pipelines/table_recognition_v2.py:143-158 — before extracting anything, compare `paddleocr/_pipelines/paddleocr_vl.py` and `paddleocr/_pipelines/pp_structurev3.py` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 354 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 `paddleocr/_pipelines/paddleocr_vl.py:186` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 4) ppocr/modeling/backbones/det_resnet_vd_sast.py:50— ppocr/modeling/backbones/det_resnet_vd_sast.py:50-65 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:50-65 | ppocr/modeling/backbones/rec_resnet_vd.py:50-65 | ppocr/modeling/necks/pg_fpn.py:48-63 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd_sast.py` and `ppocr/modeling/backbones/e2e_resnet_vd_pg.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 266 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 `ppocr/modeling/backbones/det_resnet_vd_sast.py:50` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–16 lines × 2) ppocr/data/imaug/iaa_augment.py:95— ppocr/data/imaug/iaa_augment.py:95-110 | ppocr/data/imaug/iaa_augment.py:115-128 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot 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–16 lines × 2) REDACTED:256— REDACTED:256-269 | REDACTED:153-168 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 48 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:153` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–16 lines × 2) REDACTED:144— REDACTED:144-159 | REDACTED:122-136 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:144` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–16 lines × 2) ppocr/utils/e2e_utils/pgnet_pp_utils.py:48— ppocr/utils/e2e_utils/pgnet_pp_utils.py:48-63 | ppocr/utils/e2e_utils/pgnet_pp_utils.py:89-103 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 3) ppocr/data/imaug/east_process.py:336— ppocr/data/imaug/east_process.py:336-350 | ppocr/data/imaug/pg_process.py:197-210 | ppocr/data/imaug/sast_process.py:177-190 — 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 (14–15 lines × 3) REDACTED:132— REDACTED:132-146 | REDACTED:245-258 | REDACTED:366-379 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13–15 lines × 2) ppocr/data/imaug/drrg_targets.py:373— ppocr/data/imaug/drrg_targets.py:373-387 | ppocr/data/imaug/fce_targets.py:351-363 — 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 `ppocr/data/imaug/drrg_targets.py:373` it begins part-way through the construct above it, so those exact lines 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) ppocr/data/imaug/pg_process.py:951— ppocr/data/imaug/pg_process.py:951-963 | ppocr/data/imaug/sast_process.py:696-710 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (14–15 lines × 2) REDACTED:1679— REDACTED:1679-1692 | REDACTED:1698-1712 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14–15 lines × 2) REDACTED:163— REDACTED:163-176 | REDACTED:180-194 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED: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. Note first that the copies are not typed on the same thing: `Callable` names `collections` in one and `collections.abc` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (14 lines × 4) paddleocr/_pipelines/paddleocr_vl.py:129— paddleocr/_pipelines/paddleocr_vl.py:129-142 | paddleocr/_pipelines/pp_structurev3.py:186-199 | paddleocr/_pipelines/seal_recognition.py:107-120 | paddleocr/_pipelines/table_recognition_v2.py:96-109 — before extracting anything, compare `paddleocr/_pipelines/paddleocr_vl.py` and `paddleocr/_pipelines/pp_structurev3.py` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 354 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 `paddleocr/_pipelines/paddleocr_vl.py:129` 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 (14 lines × 4) ppocr/modeling/necks/db_fpn.py:271— ppocr/modeling/necks/db_fpn.py:271-284 | ppocr/modeling/necks/db_fpn.py:386-399 | ppocr/modeling/necks/db_fpn.py:509-522 | ppocr/modeling/necks/db_fpn.py:898-911 — 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 `ppocr/modeling/necks/db_fpn.py:271` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 3) ppocr/data/imaug/unimernet_aug.py:565— ppocr/data/imaug/unimernet_aug.py:565-578 | ppocr/data/imaug/unimernet_aug.py:705-718 | ppocr/data/imaug/unimernet_aug.py:804-816 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (13–14 lines × 3) ppocr/modeling/heads/det_sast_head.py:42— ppocr/modeling/heads/det_sast_head.py:42-55 | ppocr/modeling/necks/sast_fpn.py:41-54 | ppocr/modeling/necks/sast_fpn.py:82-94 — before extracting anything, compare `ppocr/modeling/heads/det_sast_head.py` and `ppocr/modeling/necks/sast_fpn.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/heads/det_sast_head.py:42` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 2) deploy/avh/convert_image.py:30— deploy/avh/convert_image.py:30-41 | REDACTED:469-482 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (12–14 lines × 2) REDACTED:372— REDACTED:372-383 | ppocr/utils/e2e_utils/visual.py:75-88 — before extracting anything, compare `REDACTED` and `ppocr/utils/e2e_utils/visual.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 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 (13–14 lines × 2) paddleocr/_doc2md/converters/docx.py:1110— paddleocr/_doc2md/converters/docx.py:1110-1123 | paddleocr/_doc2md/converters/pptx.py:424-436 — 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 `paddleocr/_doc2md/converters/docx.py:1110` it begins part-way through the construct above it, so those exact lines 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) ppocr/utils/e2e_utils/extract_textpoint_slow.py:367— ppocr/utils/e2e_utils/extract_textpoint_slow.py:367-379 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:423-436 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 3) REDACTED:54— REDACTED:54-66 | REDACTED:215-227 | REDACTED:251-263 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:69` calls `expand_points_num` and `REDACTED:228` 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 × 3) ppocr/modeling/heads/rec_ppformulanet_head.py:595— ppocr/modeling/heads/rec_ppformulanet_head.py:595-610 | ppocr/modeling/heads/rec_unimernet_head.py:1166-1178 | ppocr/modeling/heads/rec_unimernet_head.py:1842-1856 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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) ppocr/modeling/necks/db_fpn.py:121— ppocr/modeling/necks/db_fpn.py:121-133 | ppocr/modeling/necks/table_fpn.py:29-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. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/necks/db_fpn.py:121` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) tools/program.py:541— tools/program.py:541-552 | tools/program.py:585-597 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/program.py:541` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 4) REDACTED:878— REDACTED:878-889 | REDACTED:927-938 | ppocr/postprocess/rec_postprocess.py:693-703 | ppocr/postprocess/rec_postprocess.py:768-778 — 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 (11–12 lines × 4) ppocr/modeling/heads/rec_ppformulanet_head.py:1165— ppocr/modeling/heads/rec_ppformulanet_head.py:1165-1176 | ppocr/modeling/heads/rec_ppformulanet_head.py:1280-1291 | ppocr/modeling/heads/rec_unimernet_head.py:2476-2487 | ppocr/modeling/heads/rec_unimernet_head.py:2561-2571 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (12 lines × 4) ppocr/losses/det_sast_loss.py:61— ppocr/losses/det_sast_loss.py:61-72 | ppocr/losses/det_sast_loss.py:82-93 | ppocr/losses/det_sast_loss.py:103-114 | ppocr/losses/e2e_pg_loss.py:48-59 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (12 lines × 4) ppocr/postprocess/sast_postprocess.py:90— ppocr/postprocess/sast_postprocess.py:90-101 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:347-358 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:83-94 | ppocr/utils/e2e_utils/visual.py:140-151 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/postprocess/sast_postprocess.py:90` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 2) ppocr/modeling/backbones/det_pp_lcnet.py:252— ppocr/modeling/backbones/det_pp_lcnet.py:252-262 | ppocr/modeling/backbones/rec_lcnetv3.py:543-554 — before extracting anything, compare `ppocr/modeling/backbones/det_pp_lcnet.py` and `ppocr/modeling/backbones/rec_lcnetv3.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (11–12 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:1076— ppocr/modeling/heads/rec_ppformulanet_head.py:1076-1087 | ppocr/modeling/heads/rec_unimernet_head.py:2508-2518 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 9) deploy/hubserving/kie_ser/module.py:76— deploy/hubserving/kie_ser/module.py:76-86 | deploy/hubserving/kie_ser_re/module.py:76-86 | deploy/hubserving/ocr_cls/module.py:72-82 | deploy/hubserving/ocr_det/module.py:74-84 | deploy/hubserving/ocr_rec/module.py:72-82 | deploy/hubserving/ocr_system/module.py:75-85 | deploy/hubserving/structure_layout/module.py:71-81 | deploy/hubserving/structure_system/module.py:74-84 | deploy/hubserving/structure_table/module.py:73-83 — `deploy/hubserving/kie_ser/module.py` and `deploy/hubserving/kie_ser_re/module.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 64 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11 lines × 9) deploy/hubserving/kie_ser/module.py:89— deploy/hubserving/kie_ser/module.py:89-99 | deploy/hubserving/kie_ser_re/module.py:89-99 | deploy/hubserving/ocr_cls/module.py:85-95 | deploy/hubserving/ocr_det/module.py:87-97 | deploy/hubserving/ocr_rec/module.py:85-95 | deploy/hubserving/ocr_system/module.py:88-98 | deploy/hubserving/structure_layout/module.py:84-94 | deploy/hubserving/structure_system/module.py:87-97 | deploy/hubserving/structure_table/module.py:86-96 — `deploy/hubserving/kie_ser/module.py` and `deploy/hubserving/kie_ser_re/module.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 64 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot 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 × 5) ppocr/losses/distillation_loss.py:89— ppocr/losses/distillation_loss.py:89-99 | ppocr/losses/distillation_loss.py:185-195 | ppocr/losses/distillation_loss.py:293-303 | ppocr/losses/distillation_loss.py:439-449 | ppocr/losses/distillation_loss.py:547-557 — 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. The matched lines also transfer control out of the body holding them, which cannot 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 × 5) ppocr/modeling/backbones/det_pp_lcnet.py:182— ppocr/modeling/backbones/det_pp_lcnet.py:182-192 | ppocr/modeling/backbones/det_pp_lcnet.py:195-205 | ppocr/modeling/backbones/det_pp_lcnet.py:208-218 | ppocr/modeling/backbones/det_pp_lcnet.py:221-231 | ppocr/modeling/backbones/det_pp_lcnet.py:234-244 — 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 `ppocr/modeling/backbones/det_pp_lcnet.py:182` it begins part-way through the construct above it, so those exact lines 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 × 4) ppocr/data/imaug/pg_process.py:98— ppocr/data/imaug/pg_process.py:98-107 | ppocr/data/imaug/pg_process.py:689-697 | ppocr/data/imaug/sast_process.py:77-86 | ppocr/data/imaug/sast_process.py:474-482 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:98` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9–10 lines × 4) ppocr/postprocess/rec_postprocess.py:325— ppocr/postprocess/rec_postprocess.py:325-333 | ppocr/postprocess/rec_postprocess.py:398-406 | ppocr/postprocess/rec_postprocess.py:744-753 | ppocr/postprocess/rec_postprocess.py:819-828 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `ppocr/postprocess/rec_postprocess.py:395` calls `isinstance` and `ppocr/postprocess/rec_postprocess.py:742` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 4) ppocr/postprocess/sast_postprocess.py:79— ppocr/postprocess/sast_postprocess.py:79-88 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:336-345 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:72-81 | ppocr/utils/e2e_utils/visual.py:129-138 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
Duplicated block (10 lines × 4) ppocr/utils/e2e_utils/extract_textpoint_fast.py:233— ppocr/utils/e2e_utils/extract_textpoint_fast.py:233-242 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:284-293 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:261-270 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:313-322 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 5) ppocr/modeling/backbones/det_resnet.py:135— ppocr/modeling/backbones/det_resnet.py:135-143 | ppocr/modeling/backbones/det_resnet_vd.py:269-277 | ppocr/modeling/backbones/det_resnet_vd_sast.py:196-204 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:194-202 | ppocr/modeling/backbones/rec_resnet_vd.py:197-205 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet.py` and `ppocr/modeling/backbones/det_resnet_vd.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 5) ppocr/modeling/necks/db_fpn.py:195— ppocr/modeling/necks/db_fpn.py:195-203 | ppocr/modeling/necks/db_fpn.py:278-286 | ppocr/modeling/necks/db_fpn.py:393-401 | ppocr/modeling/necks/db_fpn.py:516-524 | ppocr/modeling/necks/db_fpn.py:905-913 — 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 (8–9 lines × 2) ppocr/modeling/transforms/tbsrn.py:272— ppocr/modeling/transforms/tbsrn.py:272-280 | ppocr/modeling/transforms/tsrn.py:149-156 — before extracting anything, compare `ppocr/modeling/transforms/tbsrn.py` and `ppocr/modeling/transforms/tsrn.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (8–9 lines × 2) tools/program.py:349— tools/program.py:349-357 | tools/program.py:746-753 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tools/program.py:349` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–9 lines × 2) ppstructure/kie/predict_kie_token_ser.py:179— ppstructure/kie/predict_kie_token_ser.py:179-187 | ppstructure/table/predict_structure.py:195-201 — 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 `ppstructure/kie/predict_kie_token_ser.py:179` it begins part-way through the construct above it, so those 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, `ppstructure/table/predict_structure.py:203` calls `report` and `ppstructure/kie/predict_kie_token_ser.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 (7–9 lines × 2) ppocr/losses/e2e_pg_loss.py:38— ppocr/losses/e2e_pg_loss.py:38-44 | ppocr/losses/e2e_pg_loss.py:63-71 — both copies are in the same file, so extract the block into 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 × 5) deploy/avh/convert_image.py:44— deploy/avh/convert_image.py:44-51 | REDACTED:647-654 | REDACTED:674-681 | tools/infer/predict_cls.py:79-86 | tools/infer/predict_rec.py:448-455 — before extracting anything, compare `deploy/avh/convert_image.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 5) ppocr/losses/distillation_loss.py:103— ppocr/losses/distillation_loss.py:103-110 | ppocr/losses/distillation_loss.py:199-206 | ppocr/losses/distillation_loss.py:308-315 | ppocr/losses/distillation_loss.py:453-460 | ppocr/losses/distillation_loss.py:562-569 — 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 (7 lines × 7) REDACTED:590— REDACTED:590-596 | ppocr/modeling/backbones/rec_svtrv2.py:563-569 | REDACTED:252-258 | REDACTED:293-299 | REDACTED:110-116 | REDACTED:287-293 | ppocr/modeling/necks/rnn.py:208-214 — before extracting anything, compare `REDACTED` and `ppocr/modeling/backbones/rec_svtrv2.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 7) REDACTED:490— REDACTED:490-496 | REDACTED:548-554 | REDACTED:628-634 | ppocr/postprocess/rec_postprocess.py:341-347 | ppocr/postprocess/rec_postprocess.py:428-434 | ppocr/postprocess/rec_postprocess.py:455-461 | ppocr/postprocess/rec_postprocess.py:583-589 — there are 7 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. 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) deploy/avh/convert_image.py:36— deploy/avh/convert_image.py:36-42 | REDACTED:639-645 | REDACTED:477-483 | tools/infer/predict_cls.py:71-77 | tools/infer/predict_rec.py:440-446 — before extracting anything, compare `deploy/avh/convert_image.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 5) ppocr/postprocess/rec_postprocess.py:324— ppocr/postprocess/rec_postprocess.py:324-331 | ppocr/postprocess/rec_postprocess.py:397-404 | ppocr/postprocess/rec_postprocess.py:743-751 | ppocr/postprocess/rec_postprocess.py:818-826 | ppocr/postprocess/rec_postprocess.py:952-958 — 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. 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, `ppocr/postprocess/rec_postprocess.py:395` calls `isinstance` and `ppocr/postprocess/rec_postprocess.py:742` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6–7 lines × 3) ppocr/data/imaug/east_process.py:312— ppocr/data/imaug/east_process.py:312-318 | ppocr/data/imaug/pg_process.py:178-183 | ppocr/data/imaug/sast_process.py:155-160 — 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. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 3) REDACTED:164— REDACTED:164-170 | REDACTED:280-286 | REDACTED:414-419 — 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. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 2) ppocr/modeling/transforms/tbsrn.py:146— ppocr/modeling/transforms/tbsrn.py:146-152 | ppocr/modeling/transforms/tsrn.py:52-57 — before extracting anything, compare `ppocr/modeling/transforms/tbsrn.py` and `ppocr/modeling/transforms/tsrn.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/transforms/tbsrn.py:146` 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 (6–7 lines × 2) ppocr/utils/e2e_metric/Deteval.py:345— ppocr/utils/e2e_metric/Deteval.py:345-350 | ppocr/utils/e2e_metric/Deteval.py:406-412 — both copies are in the same file, so extract the 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, `ppocr/utils/e2e_metric/Deteval.py:344` calls `enumerate` and `ppocr/utils/e2e_metric/Deteval.py:404` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 5) ppocr/modeling/backbones/det_resnet.py:179— ppocr/modeling/backbones/det_resnet.py:179-184 | ppocr/modeling/backbones/det_resnet_vd_sast.py:255-260 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:235-240 | ppocr/modeling/backbones/rec_resnet_fpn.py:55-60 | ppocr/modeling/backbones/rec_resnet_vd.py:248-253 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet.py` and `ppocr/modeling/backbones/det_resnet_vd_sast.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 45 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 5) ppocr/modeling/backbones/det_mobilenet_v3.py:29— ppocr/modeling/backbones/det_mobilenet_v3.py:29-34 | ppocr/modeling/backbones/det_pp_lcnet.py:69-74 | ppocr/modeling/backbones/det_pp_lcnet_v2.py:45-50 | ppocr/modeling/backbones/rec_lcnetv3.py:82-87 | test_tipc/supplementary/mv3.py:40-45 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 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 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/backbones/det_mobilenet_v3.py:29` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 4) paddleocr/_doc2md/converters/docx.py:1008— paddleocr/_doc2md/converters/docx.py:1008-1012 | paddleocr/_doc2md/converters/docx.py:1017-1021 | paddleocr/_doc2md/converters/pptx.py:365-369 | paddleocr/_doc2md/converters/pptx.py:376-380 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `paddleocr/_doc2md/converters/pptx.py:372` calls `find` and `paddleocr/_doc2md/converters/docx.py:1015` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) ppocr/postprocess/sast_postprocess.py:60— ppocr/postprocess/sast_postprocess.py:60-64 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:320-324 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:53-57 | ppocr/utils/e2e_utils/visual.py:110-114 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
R10 · Code Duplication· Duplicated block with local edits (11 matched lines × 2 locations) · ×2
Duplicated block with local edits (11 matched lines × 2 locations) paddleocr-js/packages/core/src/platform/browser.ts:37— paddleocr-js/packages/core/src/platform/browser.ts:37 · paddleocr-js/packages/core/src/platform/browser.ts:58 — the two spans are one implementation copied and then locally edited — 72 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 with local edits (11 matched lines × 2 locations) paddleocr-js/packages/core/src/viz/ocr/draw-boxes.ts:16— paddleocr-js/packages/core/src/viz/ocr/draw-boxes.ts:16 · paddleocr-js/packages/core/src/viz/ocr/draw-text.ts:45 — the two spans are one implementation copied and then locally edited — 92 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.
program.train (cyclomatic 79) tools/program.py:200— program.train has cyclomatic complexity 79 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
utility.create_predictor (cyclomatic 60) tools/infer/utility.py:177— utility.create_predictor has cyclomatic complexity 60 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CustomMBartDecoder.forward (cyclomatic 55) ppocr/modeling/heads/rec_unimernet_head.py:1663— CustomMBartDecoder.forward 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.
docx._extract_chart_tables (cyclomatic 53) paddleocr/_doc2md/converters/docx.py:967— docx._extract_chart_tables 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.
CustomMBartDecoder.forward (cyclomatic 53) ppocr/modeling/heads/rec_ppformulanet_head.py:412— CustomMBartDecoder.forward 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.
TextRecognizer.__call__ (cyclomatic 52) tools/infer/predict_rec.py:583— TextRecognizer.__call__ 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.
MBartDecoder.forward (cyclomatic 48) ppocr/modeling/heads/rec_unimernet_head.py:1006— MBartDecoder.forward has cyclomatic complexity 48 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
XlsxConverter.convert_file (cyclomatic 43) paddleocr/_doc2md/converters/xlsx.py:162— XlsxConverter.convert_file 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.
docx._convert_body (cyclomatic 41) paddleocr/_doc2md/converters/docx.py:1288— docx._convert_body 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.
infer_rec.main (cyclomatic 38) tools/infer_rec.py:41— infer_rec.main 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.
PptxConverter._chart_to_html (cyclomatic 37) paddleocr/_doc2md/converters/pptx.py:344— PptxConverter._chart_to_html 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.
PaddleOCR._get_ocr_model_names (cyclomatic 36) paddleocr/_pipelines/ocr.py:318— PaddleOCR._get_ocr_model_names has cyclomatic complexity 36 (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.
export_model.dynamic_to_static (cyclomatic 33) ppocr/utils/export_model.py:169— export_model.dynamic_to_static 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.
PptxConverter._table_to_html (cyclomatic 32) paddleocr/_doc2md/converters/pptx.py:459— PptxConverter._table_to_html 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.
RandomCrop.__call__ (cyclomatic 32) ppocr/data/imaug/random_crop_data.py:201— RandomCrop.__call__ 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.
docx._table_to_html (cyclomatic 31) paddleocr/_doc2md/converters/docx.py:832— docx._table_to_html 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.
save_load.load_model (cyclomatic 31) REDACTED:66— save_load.load_model 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.
docx._iter_paragraph_items (cyclomatic 30) paddleocr/_doc2md/converters/docx.py:358— docx._iter_paragraph_items has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
train.main (cyclomatic 30) tools/train.py:46— train.main 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.
DYMicroBlock.__init__ (cyclomatic 29) REDACTED:337— DYMicroBlock.__init__ 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.
PGProcessTrain.__call__ (cyclomatic 28) ppocr/data/imaug/pg_process.py:940— PGProcessTrain.__call__ 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.
save_load.update_train_results (cyclomatic 28) REDACTED:332— save_load.update_train_results has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DetectionIoUEvaluator.evaluate_image (cyclomatic 25) ppocr/metrics/eval_det_iou.py:18— DetectionIoUEvaluator.evaluate_image 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.
ResNet.__init__ (cyclomatic 25) ppocr/modeling/backbones/det_resnet.py:128— ResNet.__init__ 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.
export_model.export (cyclomatic 25) ppocr/utils/export_model.py:419— export_model.export 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.
TextRecognizer.__init__ (cyclomatic 25) tools/infer/predict_rec.py:40— TextRecognizer.__init__ 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.
program.eval (cyclomatic 25) tools/program.py:709— program.eval 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.
PptxConverter._process_shape (cyclomatic 24) paddleocr/_doc2md/converters/pptx.py:233— PptxConverter._process_shape 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.
export_model.dump_infer_config (cyclomatic 24) ppocr/utils/export_model.py:41— export_model.dump_infer_config 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.
Client.SaveResource (cyclomatic 24) api_sdk/go/resource.go:44— Client.SaveResource has cyclomatic complexity 24 (threshold 15). Of this number, 23 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: 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.
config.normalizeOcrPipelineConfig (cyclomatic 24) paddleocr-js/packages/core/src/pipelines/ocr/config.ts:133— config.normalizeOcrPipelineConfig has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
docx._runs_to_markdown (cyclomatic 23) paddleocr/_doc2md/converters/docx.py:618— docx._runs_to_markdown 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.
PPStructureV3._get_ocr_model_names (cyclomatic 23) paddleocr/_pipelines/pp_structurev3.py:530— PPStructureV3._get_ocr_model_names 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.
ResNet_vd.__init__ (cyclomatic 23) ppocr/modeling/backbones/det_resnet_vd.py:262— ResNet_vd.__init__ 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.
AttentionLayers.__init__ (cyclomatic 23) ppocr/modeling/heads/rec_latexocr_head.py:483— AttentionLayers.__init__ 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.
eval.main (cyclomatic 23) tools/eval.py:35— eval.main 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.
ResNet_SAST.__init__ (cyclomatic 22) ppocr/modeling/backbones/det_resnet_vd_sast.py:191— ResNet_SAST.__init__ 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.
ResNet.__init__ (cyclomatic 22) ppocr/modeling/backbones/rec_resnet_vd.py:192— ResNet.__init__ 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.
eval_end2end.e2e_eval (cyclomatic 22) tools/end2end/eval_end2end.py:70— eval_end2end.e2e_eval 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.
trans_funsd_label.load_funsd_label (cyclomatic 21) ppstructure/kie/tools/trans_funsd_label.py:39— trans_funsd_label.load_funsd_label 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.
predict_system.main (cyclomatic 21) REDACTED:304— predict_system.main 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.
TextDetector.__call__ (cyclomatic 21) tools/infer/predict_det.py:310— TextDetector.__call__ 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.
OcrPipelineRunner.predict (cyclomatic 21) paddleocr-js/packages/core/src/pipelines/ocr/core.ts:197— OcrPipelineRunner.predict has cyclomatic complexity 21 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
RandomCropFlip.random_crop_flip (cyclomatic 20) ppocr/data/imaug/fce_aug.py:86— RandomCropFlip.random_crop_flip has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
VQATokenLabelEncode.__call__ (cyclomatic 20) REDACTED:1100— VQATokenLabelEncode.__call__ 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.
TextDetector.__init__ (cyclomatic 20) tools/infer/predict_det.py:37— TextDetector.__init__ has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HttpClient.fetch (cyclomatic 20) api_sdk/typescript/src/internal/http.ts:178— HttpClient.fetch has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
GenTableMask.projection_cx (cyclomatic 19) ppocr/data/imaug/table_ops.py:72— GenTableMask.projection_cx 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.
VQATokenPad.__call__ (cyclomatic 19) ppocr/data/imaug/vqa/token/vqa_token_pad.py:41— VQATokenPad.__call__ 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.
program.check_device (cyclomatic 19) tools/program.py:118— program.check_device 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.
WarpMLS.calc_delta (cyclomatic 18) ppocr/data/imaug/text_image_aug/warp_mls.py:43— WarpMLS.calc_delta 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.
VLLabelDecode.__call__ (cyclomatic 18) ppocr/postprocess/rec_postprocess.py:1090— VLLabelDecode.__call__ 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.
eval_with_label_end2end.eval_e2e (cyclomatic 18) ppstructure/kie/tools/eval_with_label_end2end.py:109— eval_with_label_end2end.eval_e2e 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.
TableMatch.get_pred_html (cyclomatic 18) ppstructure/table/matcher.py:104— TableMatch.get_pred_html 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.
predict_system.main (cyclomatic 18) tools/infer/predict_system.py:185— predict_system.main 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.
quant.main (cyclomatic 17) deploy/slim/quantization/quant.py:89— quant.main 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.
docx._iter_math_paragraph_parts (cyclomatic 17) paddleocr/_doc2md/converters/docx.py:137— docx._iter_math_paragraph_parts 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.
pptx._format_run_segment (cyclomatic 17) paddleocr/_doc2md/converters/pptx.py:111— pptx._format_run_segment 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.
RandomCropImgMask.__call__ (cyclomatic 17) ppocr/data/imaug/random_crop_data.py:533— RandomCropImgMask.__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.
SASTProcessTrain.__call__ (cyclomatic 17) ppocr/data/imaug/sast_process.py:681— SASTProcessTrain.__call__ 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.
Attention.forward (cyclomatic 17) ppocr/modeling/heads/rec_latexocr_head.py:332— Attention.forward 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.
recovery_to_doc.convert_info_docx (cyclomatic 17) ppstructure/recovery/recovery_to_doc.py:32— recovery_to_doc.convert_info_docx 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.
TableMatch.get_pred_html_master (cyclomatic 17) ppstructure/table/matcher.py:151— TableMatch.get_pred_html_master 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.
UniMERNetLabelEncode.__init__ (cyclomatic 16) REDACTED:1939— UniMERNetLabelEncode.__init__ 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.
random_crop_data.clip_poly_to_rect (cyclomatic 16) ppocr/data/imaug/random_crop_data.py:110— random_crop_data.clip_poly_to_rect 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.
DonutSwinEncoder.forward (cyclomatic 16) ppocr/modeling/backbones/rec_donut_swin.py:980— DonutSwinEncoder.forward 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.
AttentionLayers.forward (cyclomatic 16) ppocr/modeling/heads/rec_latexocr_head.py:601— AttentionLayers.forward 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.
PPFormulaNet_Head._prepare_decoder_input_ids_for_generation (cyclomatic 16) ppocr/modeling/heads/rec_ppformulanet_head.py:968— PPFormulaNet_Head._prepare_decoder_input_ids_for_generation 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.
BaseRecLabelDecode.get_word_info (cyclomatic 16) ppocr/postprocess/rec_postprocess.py:72— BaseRecLabelDecode.get_word_info 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.
UniMERNetDecode.__init__ (cyclomatic 16) ppocr/postprocess/rec_postprocess.py:1292— UniMERNetDecode.__init__ 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.
save_load.save_model (cyclomatic 16) REDACTED:241— save_load.save_model has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
program.preprocess (cyclomatic 16) tools/program.py:873— program.preprocess 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.
Client.submitFile (cyclomatic 16) api_sdk/go/transport.go:104— Client.submitFile 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.
det.decodeDetOutput (cyclomatic 16) paddleocr-js/packages/core/src/models/det.ts:468— det.decodeDetOutput has cyclomatic complexity 16 (threshold 15). Of this number, 15 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
No assertions: dispose() is safe to call multiple times paddleocr-js/packages/core/test/viz-renderer.test.ts:44— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
program.train (cognitive 173) tools/program.py:200— program.train has cognitive complexity 173 (threshold 15). Drivers by points: if/else 50 (132 pts), ternaries 9 (23 pts), boolean chains 12, loops 3 (5 pts), error handling 1 (nesting depth added 98). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
docx._extract_chart_tables (cognitive 163) paddleocr/_doc2md/converters/docx.py:967— docx._extract_chart_tables has cognitive complexity 163 (threshold 15). Drivers by points: if/else 28 (87 pts), ternaries 6 (31 pts), loops 9 (26 pts), error handling 4 (11 pts), boolean chains 8 (nesting depth added 108). 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.
XlsxConverter.convert_file (cognitive 138) paddleocr/_doc2md/converters/xlsx.py:162— XlsxConverter.convert_file has cognitive complexity 138 (threshold 15). Drivers by points: if/else 20 (77 pts), loops 9 (24 pts), error handling 5 (20 pts), ternaries 4 (13 pts), boolean chains 4 (nesting depth added 96). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utility.create_predictor (cognitive 127) tools/infer/utility.py:177— utility.create_predictor has cognitive complexity 127 (threshold 15). Drivers by points: if/else 46 (106 pts), loops 3 (8 pts), boolean chains 6, error handling 1 (5 pts), ternaries 1 (2 pts) (nesting depth added 70). 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.
TextRecognizer.__call__ (cognitive 117) tools/infer/predict_rec.py:583— TextRecognizer.__call__ has cognitive complexity 117 (threshold 15). Drivers by points: if/else 29 (66 pts), loops 16 (51 pts) (nesting depth added 72). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
docx._convert_body (cognitive 116) paddleocr/_doc2md/converters/docx.py:1288— docx._convert_body has cognitive complexity 116 (threshold 15). Drivers by points: if/else 26 (86 pts), loops 7 (21 pts), boolean chains 8, error handling 1 (nesting depth added 74). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
PptxConverter._table_to_html (cognitive 115) paddleocr/_doc2md/converters/pptx.py:459— PptxConverter._table_to_html has cognitive complexity 115 (threshold 15). Drivers by points: if/else 17 (70 pts), loops 8 (27 pts), error handling 2 (10 pts), ternaries 2 (6 pts), boolean chains 2 (nesting depth added 84). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
docx._table_to_html (cognitive 91) paddleocr/_doc2md/converters/docx.py:832— docx._table_to_html has cognitive complexity 91 (threshold 15). Drivers by points: if/else 12 (42 pts), loops 9 (29 pts), ternaries 3 (10 pts), boolean chains 6, error handling 1 (4 pts) (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.
CustomMBartDecoder.forward (cognitive 89) ppocr/modeling/heads/rec_unimernet_head.py:1663— CustomMBartDecoder.forward has cognitive complexity 89 (threshold 15). Drivers by points: if/else 27 (44 pts), ternaries 20 (37 pts), boolean chains 6, loops 2 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
save_load.load_model (cognitive 89) REDACTED:66— save_load.load_model has cognitive complexity 89 (threshold 15). Drivers by points: if/else 29 (80 pts), loops 2 (7 pts), boolean chains 2 (nesting depth added 56). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
RandomCrop.__call__ (cognitive 87) ppocr/data/imaug/random_crop_data.py:201— RandomCrop.__call__ has cognitive complexity 87 (threshold 15). Drivers by points: if/else 25 (59 pts), ternaries 6 (16 pts), loops 4 (8 pts), error handling 1 (3 pts), boolean chains 1 (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.
CustomMBartDecoder.forward (cognitive 85) ppocr/modeling/heads/rec_ppformulanet_head.py:412— CustomMBartDecoder.forward has cognitive complexity 85 (threshold 15). Drivers by points: if/else 25 (40 pts), ternaries 20 (37 pts), boolean chains 6, loops 2 (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.
docx._iter_paragraph_items (cognitive 79) paddleocr/_doc2md/converters/docx.py:358— docx._iter_paragraph_items has cognitive complexity 79 (threshold 15). Drivers by points: if/else 21 (64 pts), error handling 4 (7 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 48). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
MBartDecoder.forward (cognitive 78) ppocr/modeling/heads/rec_unimernet_head.py:1006— MBartDecoder.forward has cognitive complexity 78 (threshold 15). Drivers by points: if/else 23 (38 pts), ternaries 18 (32 pts), boolean chains 6, loops 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.
TableMatch.get_pred_html (cognitive 69) ppstructure/table/matcher.py:104— TableMatch.get_pred_html has cognitive complexity 69 (threshold 15). Drivers by points: if/else 15 (62 pts), loops 2 (5 pts), boolean chains 2 (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.
trans_funsd_label.load_funsd_label (cognitive 65) ppstructure/kie/tools/trans_funsd_label.py:39— trans_funsd_label.load_funsd_label has cognitive complexity 65 (threshold 15). Drivers by points: if/else 11 (38 pts), loops 9 (25 pts), boolean chains 2 (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.
infer_rec.main (cognitive 65) tools/infer_rec.py:41— infer_rec.main has cognitive complexity 65 (threshold 15). Drivers by points: if/else 26 (56 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 34). 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.
PptxConverter._chart_to_html (cognitive 64) paddleocr/_doc2md/converters/pptx.py:344— PptxConverter._chart_to_html has cognitive complexity 64 (threshold 15). Drivers by points: ternaries 7 (18 pts), loops 8 (16 pts), if/else 10 (14 pts), error handling 6 (10 pts), boolean chains 6 (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.
TableMatch.get_pred_html_master (cognitive 64) ppstructure/table/matcher.py:151— TableMatch.get_pred_html_master has cognitive complexity 64 (threshold 15). Drivers by points: if/else 13 (57 pts), loops 2 (5 pts), boolean chains 2 (nesting depth added 47). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
train.main (cognitive 64) tools/train.py:46— train.main has cognitive complexity 64 (threshold 15). Drivers by points: if/else 29 (58 pts), loops 1 (3 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PptxConverter._process_shape (cognitive 62) paddleocr/_doc2md/converters/pptx.py:233— PptxConverter._process_shape has cognitive complexity 62 (threshold 15). Drivers by points: if/else 14 (35 pts), loops 5 (16 pts), error handling 3 (8 pts), boolean chains 3 (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.
eval_end2end.e2e_eval (cognitive 59) tools/end2end/eval_end2end.py:70— eval_end2end.e2e_eval has cognitive complexity 59 (threshold 15). Drivers by points: if/else 15 (41 pts), loops 8 (16 pts), boolean chains 2 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TextDetector.__call__ (cognitive 58) tools/infer/predict_det.py:310— TextDetector.__call__ has cognitive complexity 58 (threshold 15). Drivers by points: if/else 18 (42 pts), ternaries 2 (8 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
save_load.update_train_results (cognitive 57) REDACTED:332— save_load.update_train_results has cognitive complexity 57 (threshold 15). Drivers by points: if/else 17 (26 pts), ternaries 4 (16 pts), loops 6 (12 pts), boolean chains 3 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ResNet.__init__ (cognitive 53) ppocr/modeling/backbones/det_resnet.py:128— ResNet.__init__ has cognitive complexity 53 (threshold 15). Drivers by points: if/else 9 (20 pts), ternaries 7 (19 pts), loops 4 (10 pts), boolean chains 4 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DetectionIoUEvaluator.evaluate_image (cognitive 52) ppocr/metrics/eval_det_iou.py:18— DetectionIoUEvaluator.evaluate_image has cognitive complexity 52 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 7 (15 pts), ternaries 6 (11 pts), boolean chains 2 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
export_model.export (cognitive 50) ppocr/utils/export_model.py:419— export_model.export has cognitive complexity 50 (threshold 15). Drivers by points: if/else 24 (42 pts), loops 2 (5 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
eval_with_label_end2end.eval_e2e (cognitive 49) ppstructure/kie/tools/eval_with_label_end2end.py:109— eval_with_label_end2end.eval_e2e has cognitive complexity 49 (threshold 15). Drivers by points: if/else 9 (35 pts), loops 6 (12 pts), boolean chains 2 (nesting depth added 32). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
DYMicroBlock.__init__ (cognitive 48) REDACTED:337— DYMicroBlock.__init__ has cognitive complexity 48 (threshold 15). Drivers by points: ternaries 20 (40 pts), boolean chains 6, if/else 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.
ResNet.__init__ (cognitive 47) ppocr/modeling/backbones/rec_resnet_vd.py:192— ResNet.__init__ has cognitive complexity 47 (threshold 15). Drivers by points: if/else 11 (24 pts), loops 4 (10 pts), ternaries 3 (9 pts), boolean chains 4 (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.
eval.main (cognitive 46) tools/eval.py:35— eval.main has cognitive complexity 46 (threshold 15). Drivers by points: if/else 19 (37 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ResNet_SAST.__init__ (cognitive 45) ppocr/modeling/backbones/det_resnet_vd_sast.py:191— ResNet_SAST.__init__ has cognitive complexity 45 (threshold 15). Drivers by points: ternaries 5 (17 pts), if/else 7 (14 pts), loops 4 (10 pts), boolean chains 4 (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.
VQATokenPad.__call__ (cognitive 42) ppocr/data/imaug/vqa/token/vqa_token_pad.py:41— VQATokenPad.__call__ has cognitive complexity 42 (threshold 15). Drivers by points: if/else 16 (40 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.
docx._runs_to_markdown (cognitive 41) paddleocr/_doc2md/converters/docx.py:618— docx._runs_to_markdown has cognitive complexity 41 (threshold 15). Drivers by points: if/else 9 (28 pts), ternaries 2 (6 pts), boolean chains 5, loops 2 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WarpMLS.calc_delta (cognitive 41) ppocr/data/imaug/text_image_aug/warp_mls.py:43— WarpMLS.calc_delta has cognitive complexity 41 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 5 (14 pts), boolean chains 3 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ResNet_vd.__init__ (cognitive 41) ppocr/modeling/backbones/det_resnet_vd.py:262— ResNet_vd.__init__ has cognitive complexity 41 (threshold 15). Drivers by points: ternaries 7 (19 pts), loops 4 (10 pts), if/else 5 (9 pts), boolean chains 3 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
predict_system.main (cognitive 41) REDACTED:304— predict_system.main has cognitive complexity 41 (threshold 15). Drivers by points: if/else 13 (30 pts), boolean chains 5, error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
UniMERNetLabelEncode.__init__ (cognitive 39) REDACTED:1939— UniMERNetLabelEncode.__init__ has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (6 pts), ternaries 1 (4 pts), boolean chains 3 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RandomCropImgMask.__call__ (cognitive 39) ppocr/data/imaug/random_crop_data.py:533— RandomCropImgMask.__call__ has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (28 pts), ternaries 4 (8 pts), boolean chains 2, loops 1 (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
ResNetFPN.__init__ (cognitive 39) ppocr/modeling/backbones/rec_resnet_fpn.py:28— ResNetFPN.__init__ has cognitive complexity 39 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 5 (11 pts), ternaries 2 (8 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.
UniMERNetDecode.__init__ (cognitive 39) ppocr/postprocess/rec_postprocess.py:1292— UniMERNetDecode.__init__ has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (6 pts), ternaries 1 (4 pts), boolean chains 3 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
predict_system.main (cognitive 39) tools/infer/predict_system.py:185— predict_system.main has cognitive complexity 39 (threshold 15). Drivers by points: if/else 14 (29 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
VLLabelDecode.__call__ (cognitive 36) ppocr/postprocess/rec_postprocess.py:1090— VLLabelDecode.__call__ has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 5 (11 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
quant.main (cognitive 35) deploy/slim/quantization/quant.py:89— quant.main has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (28 pts), loops 2 (5 pts), boolean chains 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.
docx._iter_math_paragraph_parts (cognitive 35) paddleocr/_doc2md/converters/docx.py:137— docx._iter_math_paragraph_parts has cognitive complexity 35 (threshold 15). Drivers by points: if/else 5 (16 pts), error handling 3 (9 pts), loops 3 (7 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
VQATokenLabelEncode.__call__ (cognitive 35) REDACTED:1100— VQATokenLabelEncode.__call__ has cognitive complexity 35 (threshold 15). Drivers by points: if/else 18 (32 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.
ModelOutput.__post_init__ (cognitive 35) ppocr/modeling/heads/rec_unimernet_head.py:55— ModelOutput.__post_init__ has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (26 pts), loops 2 (5 pts), error handling 1 (3 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.
export_model.main (cognitive 34) deploy/slim/quantization/export_model.py:40— export_model.main has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (27 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
docx._update_field_state_for_paragraph (cognitive 34) paddleocr/_doc2md/converters/docx.py:319— docx._update_field_state_for_paragraph has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (30 pts), ternaries 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
docx._textbox_paragraphs_to_markdown (cognitive 34) paddleocr/_doc2md/converters/docx.py:1173— docx._textbox_paragraphs_to_markdown has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 3 (6 pts), error handling 2 (4 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PptxConverter.convert_file (cognitive 34) paddleocr/_doc2md/converters/pptx.py:161— PptxConverter.convert_file has cognitive complexity 34 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 6 (15 pts), error handling 2, 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.
PGProcessTrain.__call__ (cognitive 33) ppocr/data/imaug/pg_process.py:940— PGProcessTrain.__call__ has cognitive complexity 33 (threshold 15). Drivers by points: if/else 21 (26 pts), loops 4 (5 pts), boolean chains 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.
GenTableMask.projection_cx (cognitive 33) ppocr/data/imaug/table_ops.py:72— GenTableMask.projection_cx has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 6 (9 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.
RandomCropFlip.random_crop_flip (cognitive 32) ppocr/data/imaug/fce_aug.py:86— RandomCropFlip.random_crop_flip has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (18 pts), loops 5 (12 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
VQAReTokenMetric.re_score (cognitive 32) ppocr/metrics/vqa_token_re_metric.py:79— VQAReTokenMetric.re_score has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (28 pts), loops 3 (4 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utility.draw_structure_result (cognitive 32) ppstructure/utility.py:159— utility.draw_structure_result has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 3 (9 pts), boolean chains 3 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DistillationDMLLoss.forward (cognitive 31) ppocr/losses/distillation_loss.py:101— DistillationDMLLoss.forward has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 4 (13 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 4 other methods here (DistillationKLDivLoss.forward, DistillationDKDLoss.forward, DistillationKLDivLoss.forward, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 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.
convert_ppocr_label.convert_label (cognitive 31) tools/end2end/convert_ppocr_label.py:27— convert_ppocr_label.convert_label has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (23 pts), loops 3 (5 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Client.SaveResource (cognitive 31) api_sdk/go/resource.go:44— Client.SaveResource has cognitive complexity 31 (threshold 15). Drivers by points: if/else 22 (29 pts), boolean chains 1, loops 1 (nesting depth added 7). Of this number, 30 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: 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.
OcrPipelineRunner.predict (cognitive 31) paddleocr-js/packages/core/src/pipelines/ocr/core.ts:197— OcrPipelineRunner.predict has cognitive complexity 31 (threshold 15). Drivers by points: loops 7 (16 pts), if/else 4 (7 pts), boolean chains 4, ternaries 2 (4 pts) (nesting depth added 14). 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.
PGProcessTrain.generate_tcl_ctc_label (cognitive 30) ppocr/data/imaug/pg_process.py:450— PGProcessTrain.generate_tcl_ctc_label has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (25 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Adam.__call__ (cognitive 29) ppocr/optimizer/optimizer.py:83— Adam.__call__ has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 3 (9 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.
SARLabelDecode.decode (cognitive 29) ppocr/postprocess/rec_postprocess.py:705— SARLabelDecode.decode has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (SATRNLabelDecode.decode) 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.
SATRNLabelDecode.decode (cognitive 29) ppocr/postprocess/rec_postprocess.py:780— SATRNLabelDecode.decode has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (SARLabelDecode.decode) 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.
VQAReTokenChunk.__call__ (cognitive 28) ppocr/data/imaug/vqa/token/vqa_token_chunk.py:64— VQAReTokenChunk.__call__ has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 4 (7 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CTPostProcess.__call__ (cognitive 28) ppocr/postprocess/ct_postprocess.py:47— CTPostProcess.__call__ has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 4 (7 pts), error handling 1 (4 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
locality_aware_nms.soft_nms (cognitive 28) ppocr/postprocess/locality_aware_nms.py:106— locality_aware_nms.soft_nms has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PicoDetPostProcess.__call__ (cognitive 28) ppocr/postprocess/picodet_postprocess.py:167— PicoDetPostProcess.__call__ has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 5 (7 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
export_model.dump_infer_config (cognitive 28) ppocr/utils/export_model.py:41— export_model.dump_infer_config has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (25 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
program.eval (cognitive 28) tools/program.py:709— program.eval has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (22 pts), loops 2 (3 pts), boolean chains 2, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
export_model.dynamic_to_static (cognitive 27) ppocr/utils/export_model.py:169— export_model.dynamic_to_static has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 2, 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.
math.extract_math_from_paragraph (cognitive 26) paddleocr/_doc2md/math/__init__.py:37— math.extract_math_from_paragraph has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 5 (7 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PaddleOCR._get_ocr_model_names (cognitive 26) paddleocr/_pipelines/ocr.py:318— PaddleOCR._get_ocr_model_names has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (25 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.
save_load.save_model (cognitive 26) REDACTED:241— save_load.save_model has cognitive complexity 26 (threshold 15). Drivers by points: if/else 15 (23 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.
MakeShrinkMap.__call__ (cognitive 25) ppocr/data/imaug/make_shrink_map.py:45— MakeShrinkMap.__call__ has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (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.
TheseusLayer.init_net (cognitive 24) REDACTED:489— TheseusLayer.init_net has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 4 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AttentionLayers.__init__ (cognitive 24) ppocr/modeling/heads/rec_latexocr_head.py:483— AttentionLayers.__init__ has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (10 pts), ternaries 6 (8 pts), boolean chains 5, 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.
FCEFPN.__init__ (cognitive 24) ppocr/modeling/necks/fce_fpn.py:119— FCEFPN.__init__ has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 4 (5 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BaseRecLabelDecode.get_word_info (cognitive 24) ppocr/postprocess/rec_postprocess.py:72— BaseRecLabelDecode.get_word_info has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (19 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.
det.decodeDetOutput (cognitive 24) paddleocr-js/packages/core/src/models/det.ts:468— det.decodeDetOutput has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 5 (7 pts), boolean chains 3 (nesting depth added 9). Of this number, 23 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pptx._format_run_segment (cognitive 23) paddleocr/_doc2md/converters/pptx.py:111— pptx._format_run_segment has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (16 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CVRandomAffine.__init__ (cognitive 23) ppocr/data/imaug/abinet_aug.py:87— CVRandomAffine.__init__ has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 2 (4 pts), boolean chains 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.
rec_pphgnetv2.set_identity (cognitive 23) REDACTED:734— rec_pphgnetv2.set_identity has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 4 (9 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.
PPFormulaNet_Head.generate_export (cognitive 23) ppocr/modeling/heads/rec_ppformulanet_head.py:1057— PPFormulaNet_Head.generate_export has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (20 pts), loops 2, boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StructureSystem.__call__ (cognitive 23) REDACTED:98— StructureSystem.__call__ has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
infer_det.main (cognitive 23) tools/infer_det.py:57— infer_det.main has cognitive complexity 23 (threshold 15). Drivers by points: loops 5 (12 pts), if/else 7 (10 pts), boolean chains 1 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
CTCDecoder.decode (cognitive 23) deploy/ppocr-android/ppocr-sdk/src/main/java/com/paddle/ocr/postprocess/CTCDecoder.kt:20— CTCDecoder.decode has cognitive complexity 23 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HttpClient.fetch (cognitive 23) api_sdk/typescript/src/internal/http.ts:178— HttpClient.fetch has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 4, error handling 2, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
config.normalizeOcrPipelineConfig (cognitive 23) paddleocr-js/packages/core/src/pipelines/ocr/config.ts:133— config.normalizeOcrPipelineConfig has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 10, boolean chains 8, if/else 5. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
docx._extract_headers_footers (cognitive 22) paddleocr/_doc2md/converters/docx.py:1504— docx._extract_headers_footers has cognitive complexity 22 (threshold 15). Drivers by points: error handling 6 (13 pts), if/else 4 (8 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.
xlsx._extract_drawing_math (cognitive 22) paddleocr/_doc2md/converters/xlsx.py:36— xlsx._extract_drawing_math has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 4 (7 pts), error handling 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PGProcessTrain.crop_area (cognitive 22) ppocr/data/imaug/pg_process.py:155— PGProcessTrain.crop_area has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 4 (8 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.
random_crop_data.clip_poly_to_rect (cognitive 22) ppocr/data/imaug/random_crop_data.py:110— random_crop_data.clip_poly_to_rect has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 1 (2 pts), 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.
LaTeXOCRDataSet.__init__ (cognitive 22) ppocr/data/latexocr_dataset.py:63— LaTeXOCRDataSet.__init__ has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 4, loops 3 (4 pts), ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
recovery_to_doc.convert_info_docx (cognitive 22) ppstructure/recovery/recovery_to_doc.py:32— recovery_to_doc.convert_info_docx has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
utility.text_visual (cognitive 22) tools/infer/utility.py:774— utility.text_visual has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TableLabelEncode.__call__ (cognitive 21) REDACTED:700— TableLabelEncode.__call__ has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 2, loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SimpleDataSet.get_ext_data (cognitive 21) REDACTED:350— SimpleDataSet.get_ext_data has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), error handling 1 (2 pts), loops 2, ternaries 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bleu.compute_bleu (cognitive 21) ppocr/metrics/bleu.py:46— bleu.compute_bleu has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (12 pts), loops 5 (8 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.
PPFormulaNet_Head.generate (cognitive 21) ppocr/modeling/heads/rec_ppformulanet_head.py:1183— PPFormulaNet_Head.generate has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GA_SPIN_Transformer.forward (cognitive 21) ppocr/modeling/transforms/gaspin_transformer.py:248— GA_SPIN_Transformer.forward has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (21 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.
AttnLabelDecode.decode (cognitive 21) ppocr/postprocess/rec_postprocess.py:285— AttnLabelDecode.decode has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (17 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. This shape REPEATS in the file: one other method here (RFLLabelDecode.decode) 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.
RFLLabelDecode.decode (cognitive 21) ppocr/postprocess/rec_postprocess.py:363— RFLLabelDecode.decode has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (17 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. This shape REPEATS in the file: one other method here (AttnLabelDecode.decode) 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.
network._download (cognitive 21) ppocr/utils/network.py:49— network._download has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (7 pts), 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.
utility.get_image_file_list (cognitive 21) ppocr/utils/utility.py:67— utility.get_image_file_list has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (5 pts), boolean chains 4 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
APP_Image2Doc.downloadModels (cognitive 21) ppstructure/pdf2word/pdf2word.py:334— APP_Image2Doc.downloadModels has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (6 pts), error handling 2 (5 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TextSystem.__call__ (cognitive 21) tools/infer/predict_system.py:76— TextSystem.__call__ has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (16 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OCREngine.run (cognitive 21) deploy/ppocr-android/ppocr-sdk/src/main/java/com/paddle/ocr/engine/OCREngine.kt:76— OCREngine.run has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cli._execute_api (cognitive 20) paddleocr/_api_client/cli.py:208— cli._execute_api has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 2, error handling 2, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
DetResizeForTest.resize_image_type0 (cognitive 20) REDACTED:270— DetResizeForTest.resize_image_type0 has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 1, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
random_crop_data.crop_area (cognitive 20) ppocr/data/imaug/random_crop_data.py:416— random_crop_data.crop_area has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MultiScaleSampler.iter (cognitive 20) ppocr/data/multi_scale_sampler.py:123— MultiScaleSampler.iter has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), ternaries 1 (4 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DonutSwinEncoder.forward (cognitive 20) ppocr/modeling/backbones/rec_donut_swin.py:980— DonutSwinEncoder.forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 4 (5 pts), boolean chains 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelEMA.__init__ (cognitive 20) ppocr/utils/ema.py:41— ModelEMA.__init__ has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 3 (5 pts), ternaries 1 (4 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StructureSystem.__init__ (cognitive 20) REDACTED:45— StructureSystem.__init__ has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (19 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.
tablepyxl.write_rows (cognitive 20) ppstructure/table/tablepyxl/tablepyxl.py:26— tablepyxl.write_rows has cognitive complexity 20 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 3 (6 pts), boolean chains 4 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
program.check_device (cognitive 20) tools/program.py:118— program.check_device has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 7, 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.
shared.readExplicitPipelineRuntimeDefaults (cognitive 20) paddleocr-js/packages/core/src/pipelines/ocr/shared.ts:210— shared.readExplicitPipelineRuntimeDefaults has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13 (19 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.
draw-text.drawTextPanel (cognitive 20) paddleocr-js/packages/core/src/viz/ocr/draw-text.ts:74— draw-text.drawTextPanel has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
docx._extract_textbox_paragraphs (cognitive 19) paddleocr/_doc2md/converters/docx.py:1139— docx._extract_textbox_paragraphs has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 2 (3 pts), boolean chains 1, 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.
GroupRandomCropPadding.__call__ (cognitive 19) ppocr/data/imaug/ct_process.py:213— GroupRandomCropPadding.__call__ has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 6 (10 pts), if/else 5 (6 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.
AugmenterBuilder.map_arguments (cognitive 19) ppocr/data/imaug/iaa_augment.py:133— AugmenterBuilder.map_arguments 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.
MultiScaleSampler.__init__ (cognitive 19) ppocr/data/multi_scale_sampler.py:10— MultiScaleSampler.__init__ has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 3 (5 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Attention.forward (cognitive 19) ppocr/modeling/heads/rec_latexocr_head.py:332— Attention.forward has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15 (16 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
FCEFPN.forward (cognitive 19) ppocr/modeling/necks/fce_fpn.py:260— FCEFPN.forward has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (6 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SASTPostProcess.detect_sast (cognitive 19) ppocr/postprocess/sast_postprocess.py:201— SASTPostProcess.detect_sast has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 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.
Client.pollUntilDone (cognitive 19) api_sdk/go/poller.go:29— Client.pollUntilDone has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 2 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
paddleocr.parseDocParsingResult (cognitive 19) api_sdk/go/ocr.go:209— paddleocr.parseDocParsingResult has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
docx._detect_heading_level (cognitive 18) paddleocr/_doc2md/converters/docx.py:260— docx._detect_heading_level has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (13 pts), error handling 1 (2 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.
PPStructureV3._get_ocr_model_names (cognitive 18) paddleocr/_pipelines/pp_structurev3.py:530— PPStructureV3._get_ocr_model_names has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (18 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.
GenTableMask.projection (cognitive 18) ppocr/data/imaug/table_ops.py:35— GenTableMask.projection has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 5 (7 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.
BaseModel.forward (cognitive 18) ppocr/modeling/architectures/base_model.py:80— BaseModel.forward has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14 (17 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
rec_hybridvit._init_vit_weights (cognitive 18) ppocr/modeling/backbones/rec_hybridvit.py:495— rec_hybridvit._init_vit_weights has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 1 (nesting depth added 9). 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.
AttentionLayers.forward (cognitive 18) ppocr/modeling/heads/rec_latexocr_head.py:601— AttentionLayers.forward has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, loops 1, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SEEDLabelDecode.decode (cognitive 18) ppocr/postprocess/rec_postprocess.py:463— SEEDLabelDecode.decode has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (SRNLabelDecode.decode) 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.
SRNLabelDecode.decode (cognitive 18) ppocr/postprocess/rec_postprocess.py:544— SRNLabelDecode.decode has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (SEEDLabelDecode.decode) 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.
HtmlToDocx.handle_data (cognitive 18) ppstructure/recovery/table_process.py:289— HtmlToDocx.handle_data has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TextDetector.__init__ (cognitive 18) tools/infer/predict_det.py:37— TextDetector.__init__ has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
paddleocr.parseOCRResult (cognitive 18) api_sdk/go/ocr.go:172— paddleocr.parseOCRResult has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (6 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generate_multi_language_configs.merge_config (cognitive 17) configs/rec/multi_language/generate_multi_language_configs.py:221— generate_multi_language_configs.merge_config has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 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.
xlsx._find_data_bounds (cognitive 17) paddleocr/_doc2md/converters/xlsx.py:112— xlsx._find_data_bounds has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3, 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.
UniMERNetLabelEncode.set_truncation_and_padding (cognitive 17) REDACTED:2069— UniMERNetLabelEncode.set_truncation_and_padding has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (15 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.
DistillationVQADistanceLoss.forward (cognitive 17) ppocr/losses/distillation_loss.py:947— DistillationVQADistanceLoss.forward has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 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.
TheseusLayer.upgrade_sublayer (cognitive 17) REDACTED:564— TheseusLayer.upgrade_sublayer has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 2 (5 pts), ternaries 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
rec_pphgnetv2.parse_pattern_str (cognitive 17) REDACTED:772— rec_pphgnetv2.parse_pattern_str has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 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.
LocalGraphs.generate_local_graphs (cognitive 17) ppocr/modeling/heads/local_graph.py:161— LocalGraphs.generate_local_graphs has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PPFormulaNet_Head._prepare_decoder_input_ids_for_generation (cognitive 17) ppocr/modeling/heads/rec_ppformulanet_head.py:968— PPFormulaNet_Head._prepare_decoder_input_ids_for_generation has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 5 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HtmlToDocx.handle_table (cognitive 17) ppstructure/recovery/table_process.py:239— HtmlToDocx.handle_table has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TextRecognizer.resize_norm_img (cognitive 17) tools/infer/predict_rec.py:208— TextRecognizer.resize_norm_img has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (15 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.
program.merge_config (cognitive 17) tools/program.py:88— program.merge_config has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 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.
program.preprocess (cognitive 17) tools/program.py:873— program.preprocess has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
DRRGTargets.find_head_tail (cognitive 16) ppocr/data/imaug/drrg_targets.py:82— DRRGTargets.find_head_tail has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EASTProcessTrain.crop_area (cognitive 16) ppocr/data/imaug/east_process.py:291— EASTProcessTrain.crop_area has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 2, 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.
FCENetTargets.find_head_tail (cognitive 16) ppocr/data/imaug/fce_targets.py:170— FCENetTargets.find_head_tail has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AugmenterBuilder.build (cognitive 16) ppocr/data/imaug/iaa_augment.py:78— AugmenterBuilder.build has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LatexOCRLabelEncode._convert_encoding (cognitive 16) REDACTED:1800— LatexOCRLabelEncode._convert_encoding has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (UniMERNetLabelEncode._convert_encoding) 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.
UniMERNetLabelEncode._convert_encoding (cognitive 16) REDACTED:2116— UniMERNetLabelEncode._convert_encoding has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (LatexOCRLabelEncode._convert_encoding) 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.
SASTProcessTrain.crop_area (cognitive 16) ppocr/data/imaug/sast_process.py:134— SASTProcessTrain.crop_area has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 2, 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.
SASTProcessTrain.__call__ (cognitive 16) ppocr/data/imaug/sast_process.py:681— SASTProcessTrain.__call__ has cognitive complexity 16 (threshold 15). Drivers by points: if/else 15, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
GenTableMask.__call__ (cognitive 16) ppocr/data/imaug/table_ops.py:159— GenTableMask.__call__ has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 3 (7 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GoTImgDecode._compute_resized_output_size (cognitive 16) ppocr/data/imaug/unimernet_aug.py:516— GoTImgDecode._compute_resized_output_size has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 3 (6 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (UniMERNetImgDecode._compute_resized_output_size, UniMERNetResize._compute_resized_output_size) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 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.
UniMERNetImgDecode._compute_resized_output_size (cognitive 16) ppocr/data/imaug/unimernet_aug.py:623— UniMERNetImgDecode._compute_resized_output_size has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 3 (6 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (GoTImgDecode._compute_resized_output_size, UniMERNetResize._compute_resized_output_size) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 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.
UniMERNetResize._compute_resized_output_size (cognitive 16) ppocr/data/imaug/unimernet_aug.py:755— UniMERNetResize._compute_resized_output_size has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 3 (6 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 2 other methods here (GoTImgDecode._compute_resized_output_size, UniMERNetImgDecode._compute_resized_output_size) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 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.
DiverseBranchBlock.__init__ (cognitive 16) REDACTED:218— DiverseBranchBlock.__init__ has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), ternaries 1 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ParseQHead.forward_test (cognitive 16) ppocr/modeling/heads/rec_parseq_head.py:315— ParseQHead.forward_test has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (4 pts), boolean chains 1, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PRENLabelDecode.decode (cognitive 16) ppocr/postprocess/rec_postprocess.py:889— PRENLabelDecode.decode has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
save_load.load_pretrained_params (cognitive 16) REDACTED:199— save_load.load_pretrained_params has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
table_master_match.sort_bbox (cognitive 16) REDACTED:229— table_master_match.sort_bbox has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 4 (6 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TextDetector.predict (cognitive 16) tools/infer/predict_det.py:244— TextDetector.predict has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (12 pts), loops 2 (4 pts) (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Change coupling clique: REDACTED, REDACTED, REDACTED, REDACTED, program.py REDACTED— 5 files — `REDACTED`, `REDACTED`, `REDACTED`, `REDACTED`, `tools/program.py` — all change together with no explicit dependency: a fully-connected co-change clique, not 10 separate couplings. They share one concern (thin parallel siblings over a common abstraction), so extract the shared part into ONE unit and the whole clique's coupling clears at once — you do not need to break each pair individually.
Change coupling: recovery_to_doc.py ↔ utility.py ppstructure/recovery/recovery_to_doc.py— `ppstructure/recovery/recovery_to_doc.py` and `ppstructure/utility.py` change together 60% of the time (6 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `269e5b8f` 1.在ppstructure管道中添加latex_ocr公式识别功能;2.添加pdf转markdown文件功能 (#13868); `681467d4` [bug fix] fix none res in recovery (#10603); `03d88168` update code_doc (#7667) — run `git show` on any of them.
D4 · Code Duplication· Near-duplicate member family (7 members, 47 shared lines) · ×1
Near-duplicate member family (7 members, 47 shared lines) paddleocr/_pipelines/ocr.py:431— paddleocr/_pipelines/ocr.py:431-588 | paddleocr/_pipelines/paddleocr_vl.py:306-497 | paddleocr/_pipelines/pp_chatocrv4_doc.py:430-682 | paddleocr/_pipelines/pp_doctranslation.py:568-908 | paddleocr/_pipelines/pp_structurev3.py:699-1025 | paddleocr/_pipelines/seal_recognition.py:251-372 | paddleocr/_pipelines/table_recognition_v2.py:275-434 — These 7 members are variants of one another: a block of 47 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication· Near-duplicate member family (5 members, 38 shared lines) · ×1
Near-duplicate member family (5 members, 38 shared lines) ppocr/losses/distillation_loss.py:102— ppocr/losses/distillation_loss.py:102-140 | ppocr/losses/distillation_loss.py:198-245 | ppocr/losses/distillation_loss.py:306-356 | ppocr/losses/distillation_loss.py:452-499 | ppocr/losses/distillation_loss.py:560-610 — These 5 members are variants of one another: a block of 38 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Near-duplicate member family (5 members, 17 shared lines) · ×1
Near-duplicate member family (5 members, 17 shared lines) ppocr/losses/distillation_loss.py:198— ppocr/losses/distillation_loss.py:198-245 | ppocr/losses/distillation_loss.py:306-356 | ppocr/losses/distillation_loss.py:363-394 | ppocr/losses/distillation_loss.py:452-499 | ppocr/losses/distillation_loss.py:560-610 — These 5 members are variants of one another: a block of 17 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Near-duplicate member family (5 members, 11 shared lines) · ×1
Near-duplicate member family (5 members, 11 shared lines) ppocr/modeling/necks/db_fpn.py:188— ppocr/modeling/necks/db_fpn.py:188-218 | ppocr/modeling/necks/db_fpn.py:271-304 | ppocr/modeling/necks/db_fpn.py:386-421 | ppocr/modeling/necks/db_fpn.py:509-551 | ppocr/modeling/necks/db_fpn.py:898-942 — These 5 members are variants of one another: a block of 11 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 64 shared lines) · ×1
Near-duplicate member family (4 members, 64 shared lines) paddleocr/_pipelines/formula_recognition.py:185— paddleocr/_pipelines/formula_recognition.py:185-281 | paddleocr/_pipelines/pp_chatocrv4_doc.py:430-682 | paddleocr/_pipelines/pp_doctranslation.py:568-908 | paddleocr/_pipelines/pp_structurev3.py:699-1025 — These 4 members are variants of one another: a block of 64 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 54 shared lines) · ×1
Near-duplicate member family (4 members, 54 shared lines) paddleocr/_pipelines/formula_recognition.py:185— paddleocr/_pipelines/formula_recognition.py:185-281 | paddleocr/_pipelines/paddleocr_vl.py:306-497 | paddleocr/_pipelines/pp_doctranslation.py:568-908 | paddleocr/_pipelines/pp_structurev3.py:699-1025 — These 4 members are variants of one another: a block of 54 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 22 shared lines) · ×1
Near-duplicate member family (4 members, 22 shared lines) ppocr/postprocess/sast_postprocess.py:79— ppocr/postprocess/sast_postprocess.py:79-107 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:336-364 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:72-100 | ppocr/utils/e2e_utils/visual.py:129-157 — These 4 members are variants of one another: a block of 22 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 16 shared lines) · ×1
Near-duplicate member family (4 members, 16 shared lines) ppocr/data/imaug/pg_process.py:82— ppocr/data/imaug/pg_process.py:82-107 | ppocr/data/imaug/pg_process.py:668-699 | ppocr/data/imaug/sast_process.py:59-86 | ppocr/data/imaug/sast_process.py:453-484 — These 4 members are variants of one another: a block of 16 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 15 shared lines) · ×1
Near-duplicate member family (4 members, 15 shared lines) deploy/avh/convert_image.py:29— deploy/avh/convert_image.py:29-52 | REDACTED:632-656 | tools/infer/predict_cls.py:68-87 | tools/infer/predict_rec.py:433-457 — These 4 members are variants of one another: a block of 15 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 147 shared lines) · ×1
Near-duplicate member family (3 members, 147 shared lines) ppocr/modeling/heads/rec_ppformulanet_head.py:427— ppocr/modeling/heads/rec_ppformulanet_head.py:427-635 | ppocr/modeling/heads/rec_unimernet_head.py:1022-1199 | ppocr/modeling/heads/rec_unimernet_head.py:1679-1880 — These 3 members are variants of one another: a block of 147 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 40 shared lines) · ×1
Near-duplicate member family (3 members, 40 shared lines) ppocr/modeling/backbones/det_resnet_vd.py:265— ppocr/modeling/backbones/det_resnet_vd.py:265-357 | ppocr/modeling/backbones/det_resnet_vd_sast.py:192-302 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:190-282 — These 3 members are variants of one another: a block of 40 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
Near-duplicate member pair (89 shared lines) ppocr/data/imaug/drrg_targets.py:83— ppocr/data/imaug/drrg_targets.py:83-175 | ppocr/data/imaug/fce_targets.py:171-276 — These two members are variants of one another: 89 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 (67 shared lines) ppocr/data/imaug/pg_process.py:941— ppocr/data/imaug/pg_process.py:941-1116 | ppocr/data/imaug/sast_process.py:682-810 — These two members are variants of one another: 67 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 (66 shared lines) ppocr/data/imaug/pg_process.py:461— ppocr/data/imaug/pg_process.py:461-638 | ppocr/data/imaug/sast_process.py:259-335 — These two members are variants of one another: 66 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 (58 corresponding lines) · ×1
Edited copy of a member (58 corresponding lines) deploy/slim/quantization/export_model.py:44— deploy/slim/quantization/export_model.py:44-184 | deploy/slim/quantization/quant.py:91-221 — These two members are one piece of code written twice and then edited apart: 58 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 (25 corresponding lines) · ×1
Edited copy of a member (25 corresponding lines) ppocr/data/imaug/pg_process.py:641— ppocr/data/imaug/pg_process.py:641-665 | ppocr/data/imaug/sast_process.py:426-450 — These two members are one piece of code written twice and then edited apart: 25 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 (36 corresponding lines) · ×1
Edited copy of a member (36 corresponding lines) ppocr/modeling/heads/rec_att_head.py:42— ppocr/modeling/heads/rec_att_head.py:42-84 | ppocr/modeling/heads/rec_spin_att_head.py:46-91 — These two members are one piece of code written twice and then edited apart: 36 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 (22 corresponding lines) · ×1
Edited copy of a member (22 corresponding lines) ppocr/data/imaug/pg_process.py:315— ppocr/data/imaug/pg_process.py:315-403 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:95-131 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (21 corresponding lines) · ×1
Edited copy of a member (21 corresponding lines) ppocr/modeling/necks/fpn.py:27— ppocr/modeling/necks/fpn.py:27-59 | ppocr/modeling/necks/fpn.py:67-120 — These two members are one piece of code written twice and then edited apart: 21 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 (14 corresponding lines) · ×1
Edited copy of a member (14 corresponding lines) ppocr/postprocess/rec_postprocess.py:1237— ppocr/postprocess/rec_postprocess.py:1237-1250 | ppocr/postprocess/rec_postprocess.py:1521-1534 — These two members are one piece of code written twice and then edited apart: 14 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 (18 corresponding lines) · ×1
Edited copy of a member (18 corresponding lines) ppocr/postprocess/db_postprocess.py:169— ppocr/postprocess/db_postprocess.py:169-187 | tools/infer/utility.py:913-932 — These two members are one piece of code written twice and then edited apart: 18 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) paddleocr/_pipelines/paddleocr_vl.py:129— paddleocr/_pipelines/paddleocr_vl.py:129-155 | paddleocr/_pipelines/paddleocr_vl.py:186-214 | paddleocr/_pipelines/pp_chatocrv4_doc.py:131-155 | paddleocr/_pipelines/pp_chatocrv4_doc.py:184-210 | paddleocr/_pipelines/pp_doctranslation.py:140-173 | paddleocr/_pipelines/pp_doctranslation.py:211-246 | paddleocr/_pipelines/pp_structurev3.py:186-221 | paddleocr/_pipelines/pp_structurev3.py:261-298 | paddleocr/_pipelines/seal_recognition.py:107-124 | paddleocr/_pipelines/seal_recognition.py:146-165 | paddleocr/_pipelines/table_recognition_v2.py:96-117 | paddleocr/_pipelines/table_recognition_v2.py:143-166 — 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) ppocr/modeling/heads/det_east_head.py:39— ppocr/modeling/heads/det_east_head.py:39-60 | ppocr/modeling/heads/det_sast_head.py:38-59 | ppocr/modeling/heads/e2e_pg_head.py:39-61 | ppocr/modeling/necks/east_fpn.py:38-59 | ppocr/modeling/necks/east_fpn.py:80-100 | ppocr/modeling/necks/pg_fpn.py:86-108 | ppocr/modeling/necks/sast_fpn.py:37-58 | ppocr/modeling/necks/sast_fpn.py:78-98 — 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) REDACTED:590— REDACTED:590-596 | ppocr/modeling/backbones/rec_svtrv2.py:563-569 | REDACTED:252-258 | REDACTED:293-299 | REDACTED:110-116 | REDACTED:287-293 | ppocr/modeling/necks/rnn.py:208-214 — 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 (64–65 lines × 2) ppocr/modeling/backbones/det_resnet_vd_sast.py:239— ppocr/modeling/backbones/det_resnet_vd_sast.py:239-302 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:218-282 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd_sast.py` and `ppocr/modeling/backbones/e2e_resnet_vd_pg.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 266 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 `ppocr/modeling/backbones/det_resnet_vd_sast.py:239` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (62–63 lines × 2) REDACTED:1966— REDACTED:1966-2028 | ppocr/postprocess/rec_postprocess.py:1321-1382 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (49–50 lines × 2) paddleocr/_pipelines/pp_chatocrv4_doc.py:572— paddleocr/_pipelines/pp_chatocrv4_doc.py:572-621 | paddleocr/_pipelines/seal_recognition.py:306-354 — before extracting anything, compare `paddleocr/_pipelines/pp_chatocrv4_doc.py` and `paddleocr/_pipelines/seal_recognition.py` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 281 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 `paddleocr/_pipelines/pp_chatocrv4_doc.py:572` it begins part-way through the construct above it, so those exact lines 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–49 lines × 2) ppocr/modeling/backbones/det_mobilenet_v3.py:50— ppocr/modeling/backbones/det_mobilenet_v3.py:50-95 | ppocr/modeling/backbones/rec_mobilenet_v3.py:57-105 — 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 (49 lines × 2) ppocr/modeling/necks/db_fpn.py:134— ppocr/modeling/necks/db_fpn.py:134-182 | ppocr/modeling/necks/table_fpn.py:42-90 — 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 `ppocr/modeling/necks/db_fpn.py:134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (45–48 lines × 3) ppocr/modeling/heads/rec_ppformulanet_head.py:429— ppocr/modeling/heads/rec_ppformulanet_head.py:429-476 | ppocr/modeling/heads/rec_unimernet_head.py:1022-1066 | ppocr/modeling/heads/rec_unimernet_head.py:1680-1724 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (47–48 lines × 3) ppocr/modeling/heads/rec_ppformulanet_head.py:544— ppocr/modeling/heads/rec_ppformulanet_head.py:544-590 | ppocr/modeling/heads/rec_unimernet_head.py:1117-1164 | ppocr/modeling/heads/rec_unimernet_head.py:1791-1838 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 `ppocr/modeling/heads/rec_ppformulanet_head.py:544` it begins part-way through the construct above it, so those 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 (48 lines × 2) ppocr/data/imaug/pg_process.py:715— ppocr/data/imaug/pg_process.py:715-762 | ppocr/data/imaug/sast_process.py:500-547 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (47 lines × 2) deploy/slim/quantization/export_model.py:79— deploy/slim/quantization/export_model.py:79-125 | deploy/slim/quantization/quant.py:113-159 — before extracting anything, compare `deploy/slim/quantization/export_model.py` and `deploy/slim/quantization/quant.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `deploy/slim/quantization/export_model.py:79` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (30–46 lines × 5) paddleocr/_pipelines/pp_doctranslation.py:695— paddleocr/_pipelines/pp_doctranslation.py:695-739 | paddleocr/_pipelines/pp_doctranslation.py:817-862 | paddleocr/_pipelines/pp_structurev3.py:808-852 | paddleocr/_pipelines/pp_structurev3.py:930-975 | paddleocr/_pipelines/table_recognition_v2.py:387-416 — before extracting anything, compare `paddleocr/_pipelines/pp_doctranslation.py` and `paddleocr/_pipelines/pp_structurev3.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 459 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 `paddleocr/_pipelines/pp_doctranslation.py:695` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (40–44 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:1011— ppocr/modeling/heads/rec_ppformulanet_head.py:1011-1054 | ppocr/modeling/heads/rec_unimernet_head.py:2186-2225 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 `ppocr/modeling/heads/rec_ppformulanet_head.py:1011` it begins part-way through the construct above it, so those 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 (38–40 lines × 2) ppocr/modeling/heads/local_graph.py:162— ppocr/modeling/heads/local_graph.py:162-199 | ppocr/modeling/heads/proposal_local_graph.py:282-321 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (35–36 lines × 2) ppocr/utils/logging.py:30— ppocr/utils/logging.py:30-65 | REDACTED:43-77 — 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 (35 lines × 2) ppocr/data/imaug/drrg_targets.py:111— ppocr/data/imaug/drrg_targets.py:111-145 | ppocr/data/imaug/fce_targets.py:212-246 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/data/imaug/drrg_targets.py:111` 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 (32–35 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:855— ppocr/modeling/heads/rec_ppformulanet_head.py:855-889 | ppocr/modeling/heads/rec_unimernet_head.py:2317-2348 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 `ppocr/modeling/heads/rec_ppformulanet_head.py:855` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (30–33 lines × 2) ppocr/modeling/backbones/det_resnet_vd_sast.py:196— ppocr/modeling/backbones/det_resnet_vd_sast.py:196-228 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:194-223 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd_sast.py` and `ppocr/modeling/backbones/e2e_resnet_vd_pg.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 266 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–31 lines × 6) paddleocr/_pipelines/formula_recognition.py:200— paddleocr/_pipelines/formula_recognition.py:200-228 | paddleocr/_pipelines/ocr.py:476-504 | paddleocr/_pipelines/pp_chatocrv4_doc.py:547-575 | paddleocr/_pipelines/pp_doctranslation.py:842-872 | paddleocr/_pipelines/pp_structurev3.py:955-985 | paddleocr/_pipelines/seal_recognition.py:291-319 — 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 `paddleocr/_pipelines/formula_recognition.py:200` it begins part-way through the construct above it, so those exact lines 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–30 lines × 6) paddleocr/_pipelines/pp_chatocrv4_doc.py:653— paddleocr/_pipelines/pp_chatocrv4_doc.py:653-682 | paddleocr/_pipelines/pp_doctranslation.py:685-711 | paddleocr/_pipelines/pp_doctranslation.py:807-833 | paddleocr/_pipelines/pp_structurev3.py:798-824 | paddleocr/_pipelines/pp_structurev3.py:920-946 | paddleocr/_pipelines/table_recognition_v2.py:377-403 — before extracting anything, compare `paddleocr/_pipelines/pp_chatocrv4_doc.py` and `paddleocr/_pipelines/pp_doctranslation.py` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 372 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 `paddleocr/_pipelines/pp_chatocrv4_doc.py:653` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29–30 lines × 5) ppocr/losses/distillation_loss.py:112— ppocr/losses/distillation_loss.py:112-140 | ppocr/losses/distillation_loss.py:216-245 | ppocr/losses/distillation_loss.py:327-356 | ppocr/losses/distillation_loss.py:470-499 | ppocr/losses/distillation_loss.py:581-610 — 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 `ppocr/losses/distillation_loss.py:112` it begins part-way through the construct above it, so those 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–30 lines × 2) ppocr/utils/export_model.py:200— ppocr/utils/export_model.py:200-214 | ppocr/utils/export_model.py:243-272 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (29–30 lines × 2) tools/eval.py:42— tools/eval.py:42-71 | tools/infer_rec.py:53-81 — before extracting anything, compare `tools/eval.py` and `tools/infer_rec.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. 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, `tools/infer_rec.py:82` calls `getattr` and `tools/eval.py:72` 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–29 lines × 4) paddleocr/_pipelines/formula_recognition.py:226— paddleocr/_pipelines/formula_recognition.py:226-253 | paddleocr/_pipelines/paddleocr_vl.py:313-341 | paddleocr/_pipelines/pp_doctranslation.py:586-614 | paddleocr/_pipelines/pp_structurev3.py:701-727 — before extracting anything, compare `paddleocr/_pipelines/formula_recognition.py` and `paddleocr/_pipelines/paddleocr_vl.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 77 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 `paddleocr/_pipelines/formula_recognition.py:226` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (28–29 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:660— ppocr/modeling/heads/rec_ppformulanet_head.py:660-688 | ppocr/modeling/heads/rec_unimernet_head.py:826-853 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (25–28 lines × 2) tools/infer/predict_det.py:326— tools/infer/predict_det.py:326-353 | tools/infer/predict_det.py:374-398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (24–26 lines × 11) paddleocr/_pipelines/ocr.py:456— paddleocr/_pipelines/ocr.py:456-479 | paddleocr/_pipelines/pp_chatocrv4_doc.py:492-515 | paddleocr/_pipelines/pp_chatocrv4_doc.py:542-565 | paddleocr/_pipelines/pp_doctranslation.py:611-636 | paddleocr/_pipelines/pp_doctranslation.py:659-683 | paddleocr/_pipelines/pp_doctranslation.py:781-805 | paddleocr/_pipelines/pp_structurev3.py:724-749 | paddleocr/_pipelines/pp_structurev3.py:772-796 | paddleocr/_pipelines/pp_structurev3.py:894-918 | paddleocr/_pipelines/seal_recognition.py:286-309 | paddleocr/_pipelines/table_recognition_v2.py:351-375 — before extracting anything, compare `paddleocr/_pipelines/ocr.py` and `paddleocr/_pipelines/pp_chatocrv4_doc.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 218 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 `paddleocr/_pipelines/ocr.py:456` it begins part-way through the construct above it, so those exact lines 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–26 lines × 4) paddleocr/_pipelines/paddleocr_vl.py:365— paddleocr/_pipelines/paddleocr_vl.py:365-389 | paddleocr/_pipelines/pp_chatocrv4_doc.py:522-545 | paddleocr/_pipelines/pp_doctranslation.py:627-652 | paddleocr/_pipelines/pp_structurev3.py:740-765 — before extracting anything, compare `paddleocr/_pipelines/paddleocr_vl.py` and `paddleocr/_pipelines/pp_chatocrv4_doc.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 224 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 `paddleocr/_pipelines/paddleocr_vl.py:365` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (25–26 lines × 2) REDACTED:1812— REDACTED:1812-1837 | REDACTED:2128-2152 — both copies are in the same file, so extract the 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 (22–25 lines × 12) paddleocr/_pipelines/formula_recognition.py:187— paddleocr/_pipelines/formula_recognition.py:187-208 | paddleocr/_pipelines/ocr.py:462-484 | paddleocr/_pipelines/pp_chatocrv4_doc.py:498-520 | paddleocr/_pipelines/pp_doctranslation.py:617-641 | paddleocr/_pipelines/pp_doctranslation.py:665-688 | paddleocr/_pipelines/pp_doctranslation.py:701-723 | paddleocr/_pipelines/pp_doctranslation.py:787-810 | paddleocr/_pipelines/pp_structurev3.py:730-754 | paddleocr/_pipelines/pp_structurev3.py:778-801 | paddleocr/_pipelines/pp_structurev3.py:814-836 | paddleocr/_pipelines/pp_structurev3.py:900-923 | paddleocr/_pipelines/table_recognition_v2.py:357-380 — there are 12 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 12 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `paddleocr/_pipelines/formula_recognition.py:187` 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 (23–25 lines × 8) paddleocr/_pipelines/formula_recognition.py:191— paddleocr/_pipelines/formula_recognition.py:191-213 | paddleocr/_pipelines/ocr.py:467-489 | paddleocr/_pipelines/paddleocr_vl.py:361-384 | paddleocr/_pipelines/pp_chatocrv4_doc.py:503-525 | paddleocr/_pipelines/pp_doctranslation.py:623-647 | paddleocr/_pipelines/pp_doctranslation.py:706-728 | paddleocr/_pipelines/pp_structurev3.py:736-760 | paddleocr/_pipelines/pp_structurev3.py:819-841 — there are 8 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 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `paddleocr/_pipelines/formula_recognition.py:191` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (25 lines × 5) paddleocr/_pipelines/paddleocr_vl.py:333— paddleocr/_pipelines/paddleocr_vl.py:333-357 | paddleocr/_pipelines/pp_doctranslation.py:606-630 | paddleocr/_pipelines/pp_doctranslation.py:730-754 | paddleocr/_pipelines/pp_structurev3.py:719-743 | paddleocr/_pipelines/pp_structurev3.py:843-867 — before extracting anything, compare `paddleocr/_pipelines/paddleocr_vl.py` and `paddleocr/_pipelines/pp_doctranslation.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 301 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 `paddleocr/_pipelines/paddleocr_vl.py:333` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24–25 lines × 3) ppocr/modeling/heads/rec_ppformulanet_head.py:516— ppocr/modeling/heads/rec_ppformulanet_head.py:516-539 | ppocr/modeling/heads/rec_unimernet_head.py:1089-1112 | ppocr/modeling/heads/rec_unimernet_head.py:1762-1786 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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, `ppocr/modeling/heads/rec_unimernet_head.py:1759` calls `counting_context_weight`, `unsqueeze` and `ppocr/modeling/heads/rec_ppformulanet_head.py:514` 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 (24–25 lines × 2) paddleocr/_api_client/cli.py:118— paddleocr/_api_client/cli.py:118-142 | paddleocr/_api_client/cli.py:158-181 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `paddleocr/_api_client/cli.py:118` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24 lines × 11) paddleocr/_models/_text_detection.py:47— paddleocr/_models/_text_detection.py:47-70 | paddleocr/_pipelines/ocr.py:511-534 | paddleocr/_pipelines/paddleocr_vl.py:461-484 | paddleocr/_pipelines/pp_chatocrv4_doc.py:613-636 | paddleocr/_pipelines/pp_chatocrv4_doc.py:643-666 | paddleocr/_pipelines/pp_doctranslation.py:680-703 | paddleocr/_pipelines/pp_doctranslation.py:802-825 | paddleocr/_pipelines/pp_structurev3.py:793-816 | paddleocr/_pipelines/pp_structurev3.py:915-938 | paddleocr/_pipelines/seal_recognition.py:346-369 | paddleocr/_pipelines/table_recognition_v2.py:372-395 — there are 11 copies across 8 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 11 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `paddleocr/_models/_text_detection.py:47` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24 lines × 4) ppocr/modeling/backbones/det_resnet_vd_sast.py:86— ppocr/modeling/backbones/det_resnet_vd_sast.py:86-109 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:84-107 | ppocr/modeling/backbones/rec_resnet_fpn.py:243-266 | ppocr/modeling/backbones/rec_resnet_vd.py:86-109 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd_sast.py` and `ppocr/modeling/backbones/e2e_resnet_vd_pg.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 266 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:1848— REDACTED:1848-1870 | REDACTED:2170-2193 — both copies are in the same file, so extract the 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 (20–24 lines × 2) ppocr/data/imaug/pg_process.py:344— ppocr/data/imaug/pg_process.py:344-367 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:100-119 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (24 lines × 2) REDACTED:687— REDACTED:687-710 | tools/infer/predict_rec.py:272-295 — 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 `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–24 lines × 2) ppocr/modeling/backbones/rec_mv1_enhance.py:134— ppocr/modeling/backbones/rec_mv1_enhance.py:134-157 | ppocr/modeling/backbones/rec_mv1_enhance.py:172-190 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/backbones/rec_mv1_enhance.py:134` it begins part-way through the construct above it, so those 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 (22–23 lines × 9) deploy/hubserving/kie_ser/module.py:102— deploy/hubserving/kie_ser/module.py:102-123 | deploy/hubserving/kie_ser_re/module.py:102-123 | deploy/hubserving/ocr_cls/module.py:98-120 | deploy/hubserving/ocr_det/module.py:100-122 | deploy/hubserving/ocr_rec/module.py:98-120 | deploy/hubserving/ocr_system/module.py:101-123 | deploy/hubserving/structure_layout/module.py:97-119 | deploy/hubserving/structure_system/module.py:100-122 | deploy/hubserving/structure_table/module.py:99-121 — `deploy/hubserving/kie_ser/module.py` and `deploy/hubserving/kie_ser_re/module.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 64 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
Duplicated block (22–23 lines × 7) paddleocr/_models/_object_detection.py:57— paddleocr/_models/_object_detection.py:57-78 | paddleocr/_pipelines/formula_recognition.py:235-256 | paddleocr/_pipelines/paddleocr_vl.py:323-344 | paddleocr/_pipelines/pp_chatocrv4_doc.py:587-609 | paddleocr/_pipelines/pp_doctranslation.py:596-617 | paddleocr/_pipelines/pp_structurev3.py:709-730 | paddleocr/_pipelines/seal_recognition.py:321-342 — before extracting anything, compare `paddleocr/_pipelines/formula_recognition.py` and `paddleocr/_pipelines/paddleocr_vl.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 77 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 `paddleocr/_models/_object_detection.py:57` it begins part-way through the construct above it, so those exact lines 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 × 5) paddleocr/_pipelines/paddleocr_vl.py:401— paddleocr/_pipelines/paddleocr_vl.py:401-423 | paddleocr/_pipelines/pp_chatocrv4_doc.py:562-583 | paddleocr/_pipelines/pp_doctranslation.py:858-880 | paddleocr/_pipelines/pp_structurev3.py:971-993 | paddleocr/_pipelines/table_recognition_v2.py:412-434 — before extracting anything, compare `paddleocr/_pipelines/paddleocr_vl.py` and `paddleocr/_pipelines/pp_chatocrv4_doc.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 224 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 `paddleocr/_pipelines/paddleocr_vl.py:401` it begins part-way through the construct above it, so those exact lines 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 × 3) ppocr/modeling/backbones/det_resnet_vd_sast.py:147— ppocr/modeling/backbones/det_resnet_vd_sast.py:147-169 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:145-167 | ppocr/modeling/backbones/rec_resnet_vd.py:148-170 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd_sast.py` and `ppocr/modeling/backbones/e2e_resnet_vd_pg.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 266 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 `ppocr/modeling/backbones/det_resnet_vd_sast.py:147` 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–22 lines × 11) paddleocr/_pipelines/doc_preprocessor.py:114— paddleocr/_pipelines/doc_preprocessor.py:114-134 | paddleocr/_pipelines/ocr.py:434-454 | paddleocr/_pipelines/paddleocr_vl.py:373-394 | paddleocr/_pipelines/pp_chatocrv4_doc.py:460-480 | paddleocr/_pipelines/pp_chatocrv4_doc.py:530-550 | paddleocr/_pipelines/pp_doctranslation.py:636-657 | paddleocr/_pipelines/pp_doctranslation.py:739-759 | paddleocr/_pipelines/pp_structurev3.py:749-770 | paddleocr/_pipelines/pp_structurev3.py:852-872 | paddleocr/_pipelines/seal_recognition.py:254-274 | paddleocr/_pipelines/table_recognition_v2.py:278-298 — before extracting anything, compare `paddleocr/_pipelines/doc_preprocessor.py` and `paddleocr/_pipelines/ocr.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `paddleocr/_pipelines/doc_preprocessor.py:114` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 3) ppocr/data/imaug/unimernet_aug.py:517— ppocr/data/imaug/unimernet_aug.py:517-538 | ppocr/data/imaug/unimernet_aug.py:624-645 | ppocr/data/imaug/unimernet_aug.py:756-777 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16–22 lines × 2) deploy/slim/quantization/export_model.py:168— deploy/slim/quantization/export_model.py:168-183 | ppocr/utils/export_model.py:523-544 — 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 `ppocr/utils/export_model.py:523` 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, `ppocr/utils/export_model.py:522` calls `dump_infer_config` and `deploy/slim/quantization/export_model.py:166` 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) REDACTED:390— REDACTED:390-411 | ppocr/utils/e2e_utils/visual.py:20-40 — before extracting anything, compare `REDACTED` and `ppocr/utils/e2e_utils/visual.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 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 (21 lines × 3) ppocr/modeling/necks/fce_fpn.py:159— ppocr/modeling/necks/fce_fpn.py:159-179 | ppocr/modeling/necks/fce_fpn.py:187-207 | ppocr/modeling/necks/fce_fpn.py:223-243 — 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 `ppocr/modeling/necks/fce_fpn.py:159` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 12) configs/rec/multi_language/generate_multi_language_configs.py:149— configs/rec/multi_language/generate_multi_language_configs.py:149-168 | paddleocr/_pipelines/doc_preprocessor.py:113-132 | paddleocr/_pipelines/ocr.py:433-452 | paddleocr/_pipelines/paddleocr_vl.py:372-392 | paddleocr/_pipelines/pp_chatocrv4_doc.py:459-478 | paddleocr/_pipelines/pp_chatocrv4_doc.py:529-548 | paddleocr/_pipelines/pp_doctranslation.py:635-655 | paddleocr/_pipelines/pp_doctranslation.py:738-757 | paddleocr/_pipelines/pp_structurev3.py:748-768 | paddleocr/_pipelines/pp_structurev3.py:851-870 | paddleocr/_pipelines/seal_recognition.py:253-272 | paddleocr/_pipelines/table_recognition_v2.py:277-296 — before extracting anything, compare `paddleocr/_pipelines/doc_preprocessor.py` and `paddleocr/_pipelines/ocr.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (20 lines × 11) paddleocr/_pipelines/ocr.py:436— paddleocr/_pipelines/ocr.py:436-455 | paddleocr/_pipelines/paddleocr_vl.py:338-358 | paddleocr/_pipelines/paddleocr_vl.py:370-390 | paddleocr/_pipelines/pp_chatocrv4_doc.py:456-476 | paddleocr/_pipelines/pp_chatocrv4_doc.py:527-546 | paddleocr/_pipelines/pp_doctranslation.py:632-653 | paddleocr/_pipelines/pp_doctranslation.py:735-755 | paddleocr/_pipelines/pp_structurev3.py:745-766 | paddleocr/_pipelines/pp_structurev3.py:848-868 | paddleocr/_pipelines/seal_recognition.py:256-275 | paddleocr/_pipelines/table_recognition_v2.py:280-299 — there are 11 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 11 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `paddleocr/_pipelines/ocr.py:436` it begins part-way through the construct above it, so those exact lines 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 × 13) configs/rec/multi_language/generate_multi_language_configs.py:148— configs/rec/multi_language/generate_multi_language_configs.py:148-167 | paddleocr/_pipelines/doc_preprocessor.py:113-131 | paddleocr/_pipelines/ocr.py:433-451 | paddleocr/_pipelines/paddleocr_vl.py:339-359 | paddleocr/_pipelines/paddleocr_vl.py:371-391 | paddleocr/_pipelines/pp_chatocrv4_doc.py:457-477 | paddleocr/_pipelines/pp_chatocrv4_doc.py:528-547 | paddleocr/_pipelines/pp_doctranslation.py:633-654 | paddleocr/_pipelines/pp_doctranslation.py:736-756 | paddleocr/_pipelines/pp_structurev3.py:746-767 | paddleocr/_pipelines/pp_structurev3.py:849-869 | paddleocr/_pipelines/seal_recognition.py:253-271 | paddleocr/_pipelines/table_recognition_v2.py:277-295 — before extracting anything, compare `paddleocr/_pipelines/doc_preprocessor.py` and `paddleocr/_pipelines/ocr.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `configs/rec/multi_language/generate_multi_language_configs.py:148` it begins part-way through the construct above it, so those exact lines 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 × 9) deploy/hubserving/kie_ser/module.py:50— deploy/hubserving/kie_ser/module.py:50-68 | deploy/hubserving/kie_ser_re/module.py:50-68 | deploy/hubserving/ocr_cls/module.py:46-64 | deploy/hubserving/ocr_det/module.py:48-66 | deploy/hubserving/ocr_rec/module.py:46-64 | deploy/hubserving/ocr_system/module.py:49-67 | deploy/hubserving/structure_layout/module.py:48-65 | deploy/hubserving/structure_system/module.py:50-68 | deploy/hubserving/structure_table/module.py:50-67 — `deploy/hubserving/kie_ser/module.py` and `deploy/hubserving/kie_ser_re/module.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 64 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
Duplicated block (18–19 lines × 3) ppocr/data/imaug/unimernet_aug.py:489— ppocr/data/imaug/unimernet_aug.py:489-506 | ppocr/data/imaug/unimernet_aug.py:596-613 | ppocr/data/imaug/unimernet_aug.py:727-745 — 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 (17–19 lines × 3) ppocr/modeling/heads/rec_ppformulanet_head.py:496— ppocr/modeling/heads/rec_ppformulanet_head.py:496-514 | ppocr/modeling/heads/rec_unimernet_head.py:1072-1088 | ppocr/modeling/heads/rec_unimernet_head.py:1739-1755 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 `ppocr/modeling/heads/rec_ppformulanet_head.py:496` it begins part-way through the construct above it, so those 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, `ppocr/modeling/heads/rec_unimernet_head.py:1759` calls `counting_context_weight`, `unsqueeze` and `ppocr/modeling/heads/rec_ppformulanet_head.py:516` 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 (17–18 lines × 3) ppocr/modeling/heads/rec_ppformulanet_head.py:938— ppocr/modeling/heads/rec_ppformulanet_head.py:938-954 | ppocr/modeling/heads/rec_unimernet_head.py:2380-2397 | ppocr/modeling/heads/rec_unimernet_head.py:2615-2631 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (15–18 lines × 2) paddleocr/_doc2md/converters/docx.py:634— paddleocr/_doc2md/converters/docx.py:634-651 | paddleocr/_doc2md/converters/pptx.py:124-138 — 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 (4–18 lines × 3) ppocr/losses/rec_ce_loss.py:44— ppocr/losses/rec_ce_loss.py:44-61 | ppocr/losses/rec_cppd_loss.py:43-46 | ppocr/losses/rec_nrtr_loss.py:16-33 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 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. 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–17 lines × 3) ppocr/modeling/backbones/det_resnet.py:135— ppocr/modeling/backbones/det_resnet.py:135-149 | ppocr/modeling/backbones/det_resnet_vd.py:269-285 | ppocr/modeling/backbones/rec_resnet_vd.py:197-213 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet.py` and `ppocr/modeling/backbones/det_resnet_vd.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 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 × 3) ppocr/modeling/heads/det_east_head.py:39— ppocr/modeling/heads/det_east_head.py:39-55 | ppocr/modeling/heads/e2e_pg_head.py:39-55 | ppocr/modeling/necks/east_fpn.py:38-54 — before extracting anything, compare `ppocr/modeling/heads/det_east_head.py` and `ppocr/modeling/heads/e2e_pg_head.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 43 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 `ppocr/modeling/heads/det_east_head.py:39` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–17 lines × 2) ppocr/data/imaug/pg_process.py:806— ppocr/data/imaug/pg_process.py:806-820 | ppocr/data/imaug/sast_process.py:582-598 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (16 lines × 12) paddleocr/_pipelines/paddleocr_vl.py:140— paddleocr/_pipelines/paddleocr_vl.py:140-155 | paddleocr/_pipelines/paddleocr_vl.py:198-213 | paddleocr/_pipelines/pp_chatocrv4_doc.py:140-155 | paddleocr/_pipelines/pp_chatocrv4_doc.py:194-209 | paddleocr/_pipelines/pp_doctranslation.py:158-173 | paddleocr/_pipelines/pp_doctranslation.py:230-245 | paddleocr/_pipelines/pp_structurev3.py:206-221 | paddleocr/_pipelines/pp_structurev3.py:282-297 | paddleocr/_pipelines/seal_recognition.py:109-124 | paddleocr/_pipelines/seal_recognition.py:149-164 | paddleocr/_pipelines/table_recognition_v2.py:102-117 | paddleocr/_pipelines/table_recognition_v2.py:150-165 — before extracting anything, compare `paddleocr/_pipelines/paddleocr_vl.py` and `paddleocr/_pipelines/pp_chatocrv4_doc.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 224 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 `paddleocr/_pipelines/paddleocr_vl.py:140` it begins part-way through the construct above it, so those 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, `paddleocr/_pipelines/pp_structurev3.py:300` calls `concatenate_markdown_pages` and `paddleocr/_pipelines/seal_recognition.py:167` 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) ppocr/losses/distillation_loss.py:622— ppocr/losses/distillation_loss.py:622-637 | ppocr/losses/distillation_loss.py:652-667 | ppocr/losses/distillation_loss.py:687-702 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (4–16 lines × 3) ppocr/data/imaug/east_process.py:128— ppocr/data/imaug/east_process.py:128-131 | ppocr/data/imaug/pg_process.py:121-136 | ppocr/data/imaug/sast_process.py:100-115 — 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. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–15 lines × 4) ppocr/modeling/backbones/rec_resnet_32.py:109— ppocr/modeling/backbones/rec_resnet_32.py:109-123 | ppocr/modeling/backbones/rec_resnet_45.py:71-85 | ppocr/modeling/backbones/rec_resnet_aster.py:65-76 | ppocr/modeling/backbones/rec_resnet_rfl.py:70-84 — before extracting anything, compare `ppocr/modeling/backbones/rec_resnet_32.py` and `ppocr/modeling/backbones/rec_resnet_rfl.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 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 (4–15 lines × 5) ppocr/data/imaug/east_process.py:292— ppocr/data/imaug/east_process.py:292-306 | ppocr/data/imaug/fce_aug.py:213-216 | ppocr/data/imaug/pg_process.py:158-172 | ppocr/data/imaug/random_crop_data.py:420-423 | ppocr/data/imaug/sast_process.py:135-149 — 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 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, `ppocr/data/imaug/east_process.py:307` calls `round`, `astype`, `min` and `ppocr/data/imaug/fce_aug.py:216` 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–14 lines × 6) ppocr/postprocess/rec_postprocess.py:299— ppocr/postprocess/rec_postprocess.py:299-311 | ppocr/postprocess/rec_postprocess.py:377-389 | ppocr/postprocess/rec_postprocess.py:474-486 | ppocr/postprocess/rec_postprocess.py:556-569 | ppocr/postprocess/rec_postprocess.py:722-734 | ppocr/postprocess/rec_postprocess.py:797-809 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 5) ppocr/modeling/backbones/rec_lcnetv3.py:438— ppocr/modeling/backbones/rec_lcnetv3.py:438-451 | ppocr/modeling/backbones/rec_lcnetv3.py:454-467 | ppocr/modeling/backbones/rec_lcnetv3.py:470-483 | ppocr/modeling/backbones/rec_lcnetv3.py:486-499 | ppocr/modeling/backbones/rec_lcnetv3.py:502-515 — 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 `ppocr/modeling/backbones/rec_lcnetv3.py:438` it begins part-way through the construct above it, so those exact lines 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 × 5) ppocr/modeling/heads/det_east_head.py:43— ppocr/modeling/heads/det_east_head.py:43-56 | ppocr/modeling/heads/e2e_pg_head.py:43-56 | ppocr/modeling/necks/east_fpn.py:42-55 | ppocr/modeling/necks/east_fpn.py:84-96 | ppocr/modeling/necks/pg_fpn.py:91-103 — before extracting anything, compare `ppocr/modeling/heads/det_east_head.py` and `ppocr/modeling/heads/e2e_pg_head.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 43 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 `ppocr/modeling/heads/det_east_head.py:43` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 3) ppocr/modeling/heads/rec_ppformulanet_head.py:676— ppocr/modeling/heads/rec_ppformulanet_head.py:676-689 | ppocr/modeling/heads/rec_unimernet_head.py:841-855 | ppocr/modeling/heads/rec_unimernet_head.py:2009-2022 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 `ppocr/modeling/heads/rec_ppformulanet_head.py:676` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 3) ppocr/postprocess/locality_aware_nms.py:56— ppocr/postprocess/locality_aware_nms.py:56-67 | ppocr/postprocess/locality_aware_nms.py:73-86 | ppocr/postprocess/locality_aware_nms.py:90-103 — 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. 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–14 lines × 2) ppstructure/table/table_metric/table_metric.py:64— ppstructure/table/table_metric/table_metric.py:64-77 | ppstructure/table/table_metric/table_metric.py:88-98 — both copies are in the same file, so extract the 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–13 lines × 5) REDACTED:377— REDACTED:377-387 | REDACTED:405-417 | ppocr/utils/e2e_utils/visual.py:34-46 | ppocr/utils/e2e_utils/visual.py:59-70 | ppocr/utils/e2e_utils/visual.py:81-92 — before extracting anything, compare `REDACTED` and `ppocr/utils/e2e_utils/visual.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 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 `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 × 4) deploy/avh/convert_image.py:37— deploy/avh/convert_image.py:37-49 | REDACTED:640-652 | REDACTED:667-679 | tools/infer/predict_rec.py:441-453 — before extracting anything, compare `deploy/avh/convert_image.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12–13 lines × 4) ppocr/losses/distillation_loss.py:200— ppocr/losses/distillation_loss.py:200-211 | ppocr/losses/distillation_loss.py:309-321 | ppocr/losses/distillation_loss.py:454-465 | ppocr/losses/distillation_loss.py:563-575 — 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 `ppocr/losses/distillation_loss.py:200` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–13 lines × 3) ppocr/modeling/heads/rec_att_head.py:74— ppocr/modeling/heads/rec_att_head.py:74-84 | ppocr/modeling/heads/rec_att_head.py:170-182 | ppocr/modeling/heads/rec_spin_att_head.py:81-91 — before extracting anything, compare `ppocr/modeling/heads/rec_att_head.py` and `ppocr/modeling/heads/rec_spin_att_head.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 81 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (12–13 lines × 3) ppocr/modeling/heads/rec_ppformulanet_head.py:1133— ppocr/modeling/heads/rec_ppformulanet_head.py:1133-1145 | ppocr/modeling/heads/rec_ppformulanet_head.py:1251-1263 | ppocr/modeling/heads/rec_unimernet_head.py:2458-2469 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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, `ppocr/modeling/heads/rec_ppformulanet_head.py:1265` calls `concat` and `ppocr/modeling/heads/rec_unimernet_head.py:2470` 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–12 lines × 8) ppocr/modeling/heads/det_east_head.py:48— ppocr/modeling/heads/det_east_head.py:48-59 | ppocr/modeling/heads/det_sast_head.py:47-58 | ppocr/modeling/heads/e2e_pg_head.py:48-59 | ppocr/modeling/necks/east_fpn.py:47-58 | ppocr/modeling/necks/east_fpn.py:89-99 | ppocr/modeling/necks/pg_fpn.py:96-106 | ppocr/modeling/necks/sast_fpn.py:46-57 | ppocr/modeling/necks/sast_fpn.py:87-97 — before extracting anything, compare `ppocr/modeling/heads/det_east_head.py` and `ppocr/modeling/heads/e2e_pg_head.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 43 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 `ppocr/modeling/heads/det_east_head.py:48` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 5) ppocr/modeling/backbones/det_resnet.py:75— ppocr/modeling/backbones/det_resnet.py:75-86 | ppocr/modeling/backbones/det_resnet_vd.py:202-212 | ppocr/modeling/backbones/det_resnet_vd_sast.py:124-134 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:122-132 | ppocr/modeling/backbones/rec_resnet_vd.py:124-135 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet.py` and `ppocr/modeling/backbones/det_resnet_vd.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 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 (4–12 lines × 3) ppocr/data/imaug/pg_process.py:406— ppocr/data/imaug/pg_process.py:406-417 | ppocr/data/imaug/sast_process.py:210-221 | ppocr/postprocess/sast_postprocess.py:177-180 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/postprocess/sast_postprocess.py:177` 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–11 lines × 5) ppocr/losses/distillation_loss.py:206— ppocr/losses/distillation_loss.py:206-215 | ppocr/losses/distillation_loss.py:315-325 | ppocr/losses/distillation_loss.py:371-380 | ppocr/losses/distillation_loss.py:460-469 | ppocr/losses/distillation_loss.py:569-579 — 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 `ppocr/losses/distillation_loss.py:206` 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 (11 lines × 4) ppocr/modeling/backbones/det_resnet_vd.py:267— ppocr/modeling/backbones/det_resnet_vd.py:267-277 | ppocr/modeling/backbones/det_resnet_vd_sast.py:194-204 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:192-202 | ppocr/modeling/backbones/rec_resnet_vd.py:195-205 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet_vd.py` and `ppocr/modeling/backbones/det_resnet_vd_sast.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 76 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9–11 lines × 4) ppocr/modeling/heads/det_sast_head.py:72— ppocr/modeling/heads/det_sast_head.py:72-82 | ppocr/modeling/heads/det_sast_head.py:84-94 | ppocr/modeling/heads/det_sast_head.py:108-116 | ppocr/modeling/heads/det_sast_head.py:118-126 — 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 `ppocr/modeling/heads/det_sast_head.py:72` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 3) ppstructure/kie/predict_kie_token_ser.py:146— ppstructure/kie/predict_kie_token_ser.py:146-156 | ppstructure/kie/predict_kie_token_ser_re.py:90-100 | ppstructure/table/predict_structure.py:172-181 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (9–11 lines × 2) ppocr/modeling/heads/rec_ppformulanet_head.py:258— ppocr/modeling/heads/rec_ppformulanet_head.py:258-268 | ppocr/modeling/heads/rec_unimernet_head.py:381-389 — before extracting anything, compare `ppocr/modeling/heads/rec_ppformulanet_head.py` and `ppocr/modeling/heads/rec_unimernet_head.py` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 561 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 (9–10 lines × 6) deploy/avh/convert_image.py:41— deploy/avh/convert_image.py:41-49 | REDACTED:613-622 | REDACTED:644-652 | REDACTED:671-679 | tools/infer/predict_rec.py:376-385 | tools/infer/predict_rec.py:445-453 — before extracting anything, compare `deploy/avh/convert_image.py` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (8–10 lines × 2) ppocr/data/imaug/pg_process.py:421— ppocr/data/imaug/pg_process.py:421-428 | ppocr/data/imaug/sast_process.py:225-234 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 `ppocr/data/imaug/pg_process.py:421` 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 × 4) deploy/slim/quantization/export_model.py:75— deploy/slim/quantization/export_model.py:75-83 | deploy/slim/quantization/quant.py:109-117 | ppocr/utils/export_model.py:428-436 | tools/train.py:80-88 — before extracting anything, compare `deploy/slim/quantization/export_model.py` and `deploy/slim/quantization/quant.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (7–9 lines × 3) paddleocr/_doc2md/converters/docx.py:868— paddleocr/_doc2md/converters/docx.py:868-876 | paddleocr/_doc2md/converters/docx.py:1195-1203 | paddleocr/_doc2md/converters/docx.py:1372-1378 — 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. 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, `paddleocr/_doc2md/converters/docx.py:1371` calls `flush_code_buf` and `paddleocr/_doc2md/converters/docx.py:867` 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 × 6) REDACTED:337— REDACTED:337-344 | REDACTED:378-385 | REDACTED:407-414 | ppocr/utils/e2e_utils/visual.py:36-43 | ppocr/utils/e2e_utils/visual.py:61-68 | ppocr/utils/e2e_utils/visual.py:83-90 — before extracting anything, compare `REDACTED` and `ppocr/utils/e2e_utils/visual.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 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 (2–8 lines × 5) ppocr/modeling/necks/db_fpn.py:209— ppocr/modeling/necks/db_fpn.py:209-210 | ppocr/modeling/necks/db_fpn.py:293-300 | ppocr/modeling/necks/db_fpn.py:408-415 | ppocr/modeling/necks/db_fpn.py:540-547 | ppocr/modeling/necks/db_fpn.py:929-936 — 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 (6–8 lines × 3) ppocr/data/lmdb_dataset.py:167— ppocr/data/lmdb_dataset.py:167-174 | ppocr/data/lmdb_dataset.py:227-234 | ppocr/data/lmdb_dataset.py:322-327 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `ppocr/data/lmdb_dataset.py:177` calls `get_ext_data` and `ppocr/data/lmdb_dataset.py:328` 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 × 6) ppocr/losses/distillation_loss.py:102— ppocr/losses/distillation_loss.py:102-108 | ppocr/losses/distillation_loss.py:198-204 | ppocr/losses/distillation_loss.py:306-313 | ppocr/losses/distillation_loss.py:363-369 | ppocr/losses/distillation_loss.py:452-458 | ppocr/losses/distillation_loss.py:560-567 — 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 (2–7 lines × 3) ppocr/data/imaug/east_process.py:178— ppocr/data/imaug/east_process.py:178-179 | ppocr/data/imaug/pg_process.py:641-647 | ppocr/data/imaug/sast_process.py:426-432 — 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 (4–7 lines × 4) ppocr/modeling/necks/db_fpn.py:252— ppocr/modeling/necks/db_fpn.py:252-255 | ppocr/modeling/necks/db_fpn.py:343-346 | ppocr/modeling/necks/db_fpn.py:497-503 | ppocr/modeling/necks/db_fpn.py:886-892 — 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 `ppocr/modeling/necks/db_fpn.py:252` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (2–5 lines × 6) ppocr/data/imaug/pg_process.py:702— ppocr/data/imaug/pg_process.py:702-708 | ppocr/data/imaug/sast_process.py:487-493 | ppocr/postprocess/sast_postprocess.py:68-74 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:329-330 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:62-66 | ppocr/utils/e2e_utils/visual.py:119-123 — before extracting anything, compare `ppocr/data/imaug/pg_process.py` and `ppocr/data/imaug/sast_process.py` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 497 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 (4–5 lines × 8) ppocr/data/imaug/east_process.py:320— ppocr/data/imaug/east_process.py:320-324 | ppocr/data/imaug/east_process.py:326-329 | ppocr/data/imaug/fce_aug.py:111-114 | ppocr/data/imaug/fce_aug.py:116-119 | ppocr/data/imaug/pg_process.py:185-189 | ppocr/data/imaug/pg_process.py:191-194 | ppocr/data/imaug/sast_process.py:162-166 | ppocr/data/imaug/sast_process.py:168-171 — 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.
Duplicated block (3–5 lines × 3) ppocr/modeling/heads/rec_nrtr_head.py:509— ppocr/modeling/heads/rec_nrtr_head.py:509-513 | ppocr/modeling/heads/rec_nrtr_head.py:556-560 | ppocr/modeling/heads/sr_rensnet_transformer.py:224-226 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `ppocr/modeling/heads/rec_nrtr_head.py:509` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 7) ppocr/losses/distillation_loss.py:69— ppocr/losses/distillation_loss.py:69-76 | ppocr/losses/distillation_loss.py:165-172 | ppocr/losses/distillation_loss.py:273-280 | ppocr/losses/distillation_loss.py:419-426 | ppocr/losses/distillation_loss.py:527-534 | ppocr/losses/distillation_loss.py:1164-1171 | test_tipc/supplementary/loss.py:108-115 — there are 7 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot 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 × 5) ppocr/modeling/backbones/det_resnet.py:115— ppocr/modeling/backbones/det_resnet.py:115-124 | ppocr/modeling/backbones/det_resnet_vd.py:249-258 | ppocr/modeling/backbones/det_resnet_vd_sast.py:178-187 | ppocr/modeling/backbones/e2e_resnet_vd_pg.py:176-185 | ppocr/modeling/backbones/rec_resnet_vd.py:179-188 — before extracting anything, compare `ppocr/modeling/backbones/det_resnet.py` and `ppocr/modeling/backbones/det_resnet_vd.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 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.
D4 · Code Duplication· Near-duplicate member family (3 members, 55 shared lines) · ×1
Near-duplicate member family (3 members, 55 shared lines) REDACTED:88— REDACTED:88-196 | REDACTED:200-313 | REDACTED:317-446 — These 3 members are variants of one another: a block of 55 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
Near-duplicate member pair (121 shared lines) ppocr/utils/e2e_metric/Deteval.py:25— ppocr/utils/e2e_metric/Deteval.py:25-175 | ppocr/utils/e2e_metric/Deteval.py:179-306 — These two members are variants of one another: 121 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 (16 corresponding lines) · ×1
Edited copy of a member (16 corresponding lines) ppocr/utils/e2e_utils/pgnet_pp_utils.py:48— ppocr/utils/e2e_utils/pgnet_pp_utils.py:48-86 | ppocr/utils/e2e_utils/pgnet_pp_utils.py:89-179 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (46 lines × 2) ppocr/utils/e2e_metric/Deteval.py:78— ppocr/utils/e2e_metric/Deteval.py:78-123 | ppocr/utils/e2e_metric/Deteval.py:209-254 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (37 lines × 2) ppocr/utils/e2e_utils/extract_textpoint_fast.py:277— ppocr/utils/e2e_utils/extract_textpoint_fast.py:277-313 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:306-342 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 (25–27 lines × 4) ppocr/utils/e2e_utils/extract_textpoint_fast.py:170— ppocr/utils/e2e_utils/extract_textpoint_fast.py:170-194 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:497-523 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:197-221 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:560-586 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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. 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 (23–25 lines × 4) ppocr/utils/e2e_utils/extract_textpoint_fast.py:210— ppocr/utils/e2e_utils/extract_textpoint_fast.py:210-232 | ppocr/utils/e2e_utils/extract_textpoint_fast.py:258-281 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:237-260 | ppocr/utils/e2e_utils/extract_textpoint_slow.py:286-310 — before extracting anything, compare `ppocr/utils/e2e_utils/extract_textpoint_fast.py` and `ppocr/utils/e2e_utils/extract_textpoint_slow.py` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 288 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 `ppocr/utils/e2e_utils/extract_textpoint_fast.py:210` 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–24 lines × 2) REDACTED:154— REDACTED:154-175 | REDACTED:268-291 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift 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:268` it begins part-way through the construct above it, so those exact lines 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) ppocr/utils/e2e_metric/Deteval.py:153— ppocr/utils/e2e_metric/Deteval.py:153-175 | ppocr/utils/e2e_metric/Deteval.py:284-306 — both copies are in the same file, so extract the 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.
R10 · Code Duplication· Duplicated block with local edits (103 matched lines × 2 locations) · ×1
Duplicated block with local edits (103 matched lines × 2 locations) paddleocr-js/packages/core/src/models/det.ts:205— paddleocr-js/packages/core/src/models/det.ts:205 · paddleocr-js/packages/core/src/models/rec.ts:114 — the two spans are one implementation copied and then locally edited — 648 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 (25 matched lines × 2 locations) · ×1
Duplicated block with local edits (25 matched lines × 2 locations) paddleocr-js/packages/core/src/models/det.ts:119— paddleocr-js/packages/core/src/models/det.ts:119 · paddleocr-js/packages/core/src/models/rec.ts:68 — the two spans are one implementation copied and then locally edited — 153 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 (13 lines × 2 locations) api_sdk/typescript/src/client.ts:273— api_sdk/typescript/src/client.ts:273 · api_sdk/typescript/src/client.ts:298 — 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 (12 lines × 2 locations) paddleocr-js/packages/core/src/platform/browser.ts:81— paddleocr-js/packages/core/src/platform/browser.ts:81 · paddleocr-js/packages/core/src/platform/worker.ts:42 — 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) paddleocr-js/packages/core/src/models/common.ts:159— paddleocr-js/packages/core/src/models/common.ts:159 · paddleocr-js/packages/core/src/models/common.ts:168 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2 locations) api_sdk/typescript/src/client.ts:79— api_sdk/typescript/src/client.ts:79 · api_sdk/typescript/src/client.ts:85 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Complex function predict (cyclomatic 25, cognitive 37) paddleocr-js/packages/core/src/pipelines/ocr/core.ts:197— predict has cyclomatic complexity 25 and cognitive complexity 37; 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 normalizeOcrPipelineConfig (cyclomatic 25, cognitive 24) paddleocr-js/packages/core/src/pipelines/ocr/config.ts:133— normalizeOcrPipelineConfig has cyclomatic complexity 25 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 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 fetch (cyclomatic 21, cognitive 24) api_sdk/typescript/src/internal/http.ts:178— fetch has cyclomatic complexity 21 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 decodeDetOutput (cyclomatic 15, cognitive 25) paddleocr-js/packages/core/src/models/det.ts:468— decodeDetOutput has cyclomatic complexity 15 and cognitive complexity 25; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive 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 readExplicitPipelineRuntimeDefaults (cyclomatic 15, cognitive 20) paddleocr-js/packages/core/src/pipelines/ocr/shared.ts:210— readExplicitPipelineRuntimeDefaults has cyclomatic complexity 15 and cognitive complexity 20; 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 drawTextPanel (cyclomatic 12, cognitive 22) paddleocr-js/packages/core/src/viz/ocr/draw-text.ts:74— drawTextPanel has cyclomatic complexity 12 and cognitive complexity 22; 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.
R2 · Cyclomatic Complexity· Complex function similar (cyclomatic 11, cognitive 13) · ×1
Complex function similar (cyclomatic 11, cognitive 13) test_tipc/web/index.test.js:50— similar has cyclomatic complexity 11 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 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 parseDetModelConfigText (cyclomatic 11, cognitive 10) paddleocr-js/packages/core/src/models/det.ts:119— parseDetModelConfigText has cyclomatic complexity 11 and cognitive complexity 10; 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.
Third-party script without Subresource Integrity overrides/partials/comments.html:5— `https://giscus.app/client.js` is executed by this page with no Subresource Integrity. Whoever can answer that request — the CDN, anyone who compromises it, anyone on the network path — runs arbitrary script in this page's origin, with its session. The URL also names no version, so it resolves to whatever that origin serves at fetch time — the executed bytes can change with nobody touching this repository.
D34 · Knowledge Freshness· Most significant orphaned file · ×3
Most significant orphaned file REDACTED— One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
Most significant orphaned file ppocr/modeling/heads/rec_ppformulanet_head.py— One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
Most significant orphaned file ppocr/modeling/backbones/rec_donut_swin.py— One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
Documentation: no project overview README.md— The README is an English banner with no project description or purpose; the global heading 'Global Leading OCR Toolkit & Document AI Engine' alone does not convey what the project does. Add a one-paragraph overview stating the project's role as a unified OCR and document AI engine for text recognition, parsing, and structured output across images/PDFs.
Documentation: no installation or build instructions README.md— The README has no installation or build instructions. Add an Install section covering cloning the repo, pip install requirements.txt, and any setup steps for local development.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 2 significant file(s) lose their only recent owner: ppocr/data/latexocr_dataset.py, test_tipc/supplementary/config.py. Pair on, review, or document these before any departure.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 3 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 (5 single-owned of 433 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 433 of the 678 production source files in this repository met that bar). They are anonymized user #2 (1 file(s)), anonymized user #3 (1 file(s)), anonymized user #4 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above.
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/`.
Concentrated knowledge decay — 318 of 435 significant files have no living knowledge, while the repository is still being changed at a low rate (4 commit(s) in the last 90 days) — so this is one repo-wide knowledge-decay state, not 318 separate risks. Counted over 435 of the 678 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over. The code moved on without the people who understood these files: document them or schedule a read-through before the next change lands in them.
No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
No SAST — No static application security testing detected. For this repository's stack, add 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 18780 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.)
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 1 file(s) — `paddleocr-js/packages/core/src/runtime/ort.ts` — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
Run 01a0dc49-84b9-7c76-8f0d-82dc4e34b891 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 427 · Warnings: 947 · Recommendations: 39 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 26-09-2026 @ 05:56 UTC.
Downloadable artifacts
Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.