Public report — SwiftSoup, published 30 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.18 (frozen) · verify this surveyFiledcd_e6172960e77c44d9a1dabd3e8ee98859
Filed 30 September 2026, 19:57 UTC
Public
Medium · 35,931 LoC · 2 projects · rebuild ~0.5 person-years · weakest lens: Maturity (56%)
Findings by grade
6 critical654 serious44 minor45 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
30 September 2026, 19:53 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 ▸
683findings with an exact file:lineof 704 — the remainder are repo-wide signals (a dimension-level measurement, not a single line); open any file:line and verify
38/119dimensions across the health lenses35931 LoC · 2 projects — wide & deep
The system holds an adequate standing with a health score of 64%, indicating a workable asset that carries real operational risk. While the architecture is robust, the overall maturity is weak, creating a fragile foundation for future growth. This balance means the business can continue current operations, but scaling or major changes will encounter significant friction and cost.
The codebase is medium-sized, comprising roughly 36,000 lines of production code, with a rebuild effort estimated at half a person-year for approximately €67,000. This represents a substantial investment tied up in the current state. The value at stake is high because the system is central to delivery, yet its weakest areas threaten to erode that value through increased maintenance costs and slower feature delivery.
The primary risk is a velocity tax on every change. Code quality signals suggest that modifications in weaker areas cost 7–16% more than in clean code, acting as a hidden drag on the team’s annual output. This inefficiency compounds as the codebase grows, meaning the team pays a premium in engineer-days for every update, reducing overall delivery speed and increasing long-term costs.
A secondary concern is the concentration of value against weak maturity. With a maturity score of 56%, the system lacks the documentation and decision records needed for new teams to pick up work efficiently. This creates a knowledge bottleneck, where specific individuals become single points of failure, increasing the risk of delays and errors when key personnel are unavailable or when onboarding new engineers.
Genuinely good news is the strong architecture and performance scores, which ensure the system is stable and reliable under load. The code is well-structured, minimizing the risk of catastrophic failures or widespread ripple effects from changes. This solid foundation provides a safe base for remediation efforts, allowing the team to focus on improving maturity without fearing structural collapse.
The highest-leverage move is to record significant decisions in a centralized, discoverable format. This single action addresses the maturity gap, reduces the velocity tax by clarifying context, and pays for itself within months by preventing repeated mistakes. Focusing here first offers the most protection for the business, turning a fragile asset into a sustainable one with minimal upfront effort.
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.
105 finding(s) are new versus the previous scan (2026-09-14) — surfaced by this scheduled scan itself, no pull request required. Showing the first 100; the full set is in the report.
D22 · Inconsistent constructor naming and arity for string-based initialization. There are two constructors taking key/value pairs (one for UTF8 bytes, one for Strings), but a third constructor `init(String)` exists with no clear semantic mapping (is it a key? a serialized attribute?). This breaks the symmetry of the API.
D22 · Inconsistent naming convention for UTF-8 vs String accessors. The `Attribute` type uses `Key`/`Value` for String and `KeyUTF8`/`ValueUTF8` for bytes. However, `Element` uses `tagName()` for String and `tagNameUTF8()` for bytes, but `nodeName()` vs `nodeNameUTF8()`. While consistent within themselves, the mix of `Key`/`Value` (semantic) vs `Name` (structural) across types is confusing. More critically, `Attribute` lacks a `toString()` equivalent for the whole attribute in a unified way compared to `Element`.
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 64% quality) — the last 20% of quality is most of the work
Size & shape
Medium · effort split not classified (source measured from disk; the effort-tier breakdown is a C#-only syntax walk)
This codebase represents roughly ~0.5 person-years of build effort (about ~€67,000 to rebuild). Its weakest lens is Maturity at 56% — 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
Resolve the 1 No ADRs found finding(s) in ADR Quality.
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).
1 hotspot file(s) are also under-tested or single-owner — change there is riskier than the headline suggests.
Evidence: D15 hotspots: 8 churn×complexity hotspot file(s) · D8 coverage: 7 file(s) under 50% coverage · D16 ownership: 0 file(s) ≥90% owned by one author · intersection: incl. TokeniserState.swift
→ Prioritise tests + a second reviewer on the worst files (TokeniserState.swift).
The top fix pays for itself · High · Economics
The top-ranked fix costs roughly 1–3 engineer-days once. Not doing it costs about 15.9–95.3 engineer-days every year, paid as drag on the ~87,718 lines this team changes annually — a bill that arrives whether or not anyone books it. On those figures the fix breaks even in roughly 1–2 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 7–16% 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: 21,629 line(s) changed over a 90-day window ⇒ ~87,718/year · D1/D2/D4/D6 code quality: averaging 5.1/10 ⇒ a 7–16% drag on each change · top-ranked remediation: Low effort ⇒ about 1–3 engineer-day(s)
→ Do the top-ranked fix now if this code will still be yours in 2 months.
Value concentrated against a weak lens · Medium · Value at risk
This is a Medium asset (~0.5 person-years to rebuild), and its weakest lens is Maturity at 56%. The operational and business risk on an asset this size concentrates there — that's where remediation buys the most protection.
→ Direct remediation budget at Maturity 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: 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). The rest can wait behind it.
Evidence: priority ranking: top of 5 ranked by impact/effort
→ 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).
A velocity tax on every change · Medium · Economics
The code-quality signals (complexity, duplication, cohesion) average 5.1/10, which acts as a tax on every change in the weaker areas: modifications there plausibly cost on the order of 7–16% more than in clean code, and the tax compounds as the codebase grows. (A modelled estimate, not a measured fact.)
Evidence: D1/D2/D4/D6 code quality: averaging 5.1/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 graph
Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways — a layering smell or cycle. A clean layered graph has none.
At a glance — Code Health · 69% · Adequate · gated by D1, D2 ·
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A03:2021 — Injection
36
High / Critical
Roadmap
Begin by establishing a formal architecture decision record process to document significant design choices and their consequences, ensuring all decisions are captured in a discoverable location. Simultaneously, address the immediate gap in architectural documentation by resolving the missing ADRs and improving the overall quality of existing records. Next, enhance the root README by adding a clear section on how to run the test suite to improve onboarding and usability. Finally, tackle the eight high-churn and high-complexity code hotspots, prioritizing HtmlTreeBuilderState.swift, TokeniserState.swift, and Tokeniser.swift to reduce technical debt and improve system stability.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Resolve the 1 No ADRs found finding(s) in ADR Quality.
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).
Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Test Quality: Assertions commented out: testDataset
Tests/SwiftSoupTests/FormElementTest.swift
6.4
Mixed
Explicit Debt: TodoComment
Tests/SwiftSoupTests/CharacterReaderTest.swift
6.5
Mixed
Test Quality: Assertions commented out: testRangeEquals
Tests/SwiftSoupTests/DocumentTest.swift
6.6
Mixed
Explicit Debt: TodoComment
Sources/XmlTreeBuilder.swift
6.7
Mixed
Explicit Debt: TodoComment
How the grades work
Every finding carries one of four grades. Three say how serious it is. The fourth says this
survey could not settle it — and it is a grade, not a gap.
Critical — 6
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 — 654
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 — 44
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 45
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. 33 of 38 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 5 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 — 38 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, 683 of 704 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.
D14 License Compliance — scanner not present in this environment — The backing tool was not installed where this scan ran, so this dimension was not scored. Install the tool (or run in the hosted environment, where it is always present) for a graded result.
D30 Dependency Vulnerabilities — 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. Osv: the scanner produced no output at all, so no dependency was actually scanned. 'osv-scanner' exited 128 and produced no findings, and that exit code has no documented repo-side meaning — so this run measured nothing, and nothing here is a statement about the repository.
D32 Data Compliance (PII/GDPR) — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `Sources/HtmlTreeBuilderState.swift`, `Sources/Node.swift`, `Sources/StringBuilder.swift` 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.
D43 Malicious Dependencies — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Osv: the scanner produced no output at all, so no dependency was actually scanned. 'osv-scanner' exited 128 and produced no findings, and that exit code has no documented repo-side meaning — so this run measured nothing, and nothing here is a statement about the repository.
D44 Platform End-of-Life — 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 dimension reads a project's own statement about the platform it runs on: a TargetFramework in a .NET project file, a .nvmrc or .python-version, a capped requires-python, a Rust toolchain file or Cargo.toml rust-version, a .go-version, .java-version, .ruby-version, .tool-versions or .sdkmanrc, a go.mod go directive, a Maven or Gradle Java level or toolchain, a Gemfile's ruby directive, a mix.exs elixir requirement, a rebar.config minimum_otp_vsn, a pubspec.yaml SDK constraint, a build.sbt scalaVersion, or a framework major pinned by a dependency constraint. This repository carries none of them, so nothing about its platform was established. That is a gap in this analyzer's coverage, NOT a finding that the platform is supported — a language whose runtime is declared elsewhere (Package.swift, a Dockerfile) is simply not read here yet.
AX1 Captive dependencies — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and no container it models, or knows cannot hold a captive, was found in this repository's source, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
AX2 Stateful singletons — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads Microsoft.Extensions.DependencyInjection singletons in C#, Spring/JSR-330/CDI singletons in Java and Kotlin, and module state in Python request handlers only, and this repository's product is written in Swift, which was left unread, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
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.
AXB1 Runtime evidence locked — no reproducible boot — 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. Subject: a native UI project (Example/Example.xcodeproj/project.pbxproj). The Runtime Evidence tier boots an app only via docker-compose, an Aspire AppHost, a Dockerfile, or an npm dev script. None was found, so no live runtime a11y/egress/header evidence was collected. You can widen what we reach: add a docker-compose.yml (or an Aspire AppHost) that brings the app up with its dependencies. Watchdog then boots it in an isolated sandbox and gathers real runtime evidence — you change nothing in your pipeline (no CI step, no SDK).
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.
P5 DR & Backup — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. No backup/snapshot/replication config, RTO/RPO or restore-procedure documentation was found — and no production persistence was detected either (no data-access packages, no data-store services, no database resources), so there is nothing in this repository whose loss a DR control would recover. If this system's data lives in a platform or ops repo we can't see, that's where the DR evidence belongs.
PF3 Async & latency 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. Those languages colour their functions async, so blocking inside them is the same defect this card counts elsewhere, but their blocking vocabulary is not modelled yet. That is a gap in this analyzer's language reach — not a finding that the code is free of it.
S1 Web-Security Posture — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
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 reads C# syntax, and JavaScript/TypeScript source only, and no C# was loaded and no JavaScript/TypeScript was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
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.
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.
X7 Silent fallback defaults — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. X7 measured the part of this repository it reads (C#, Python, TypeScript/JavaScript, Rust and Go), and its Swift source is outside the check's reach, so the card covers only part of the product. That is a gap in this analyzer's language reach — not a finding that the unread source is free of silent defaults.
Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.
Limitations & what we did not check
Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.
Per-dimension blind spots
For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.
D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
D8 Code Coverage: Coverage is measured by building and running the test suite inside Watchdog's isolated image — the target repo is never modified, and nothing on your systems runs. So coverage exists only when the suite builds and runs within the inline time budget; one that needs external services, can't build, or exceeds the budget yields no coverage (D8 then degrades to not-measured, not a low score). Line coverage also says nothing about assertion quality.
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.
D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
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.
D22 Internal API Consistency: API-surface coherence is an LLM judgement over a sample of the public surface — consistency of intent across the whole API is approximated, not exhaustively verified.
D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
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.
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.
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 (5): D19, D21, D22, D26, 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.
73 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was HtmlTreeBuilderState.process at 706. A further 2 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being Encoding.displayName at 24 — they are counted neither in the figure above nor in this dimension's score. 1 file carries no cyclomatic complexity row at all for this reason — every one of its over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: Sources/String.swift (Encoding.displayName at 24). They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.
+ 68 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 HtmlTreeBuilderState.process (cyclomatic 706) finding(s) in Cyclomatic Complexity — start with HtmlTreeBuilderState.swift. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 TokeniserState.read (cyclomatic 411) finding(s) in Cyclomatic Complexity — start with TokeniserState.swift. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 main.swift.runWorkload (cyclomatic 159) finding(s) in Cyclomatic Complexity — start with main.swift. — 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.
+ 127 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 2 StringBuilder.write (cognitive 24) finding(s) in Cognitive Complexity — start with StringBuilder.swift (2). — One of this dimension's main actionable groups (2 warning-level).
Resolve the 2 Attribute.appendAttributeValue (cognitive 17) finding(s) in Cognitive Complexity — start with Attribute.swift (2). — One of this dimension's main actionable groups (2 warning-level).
Resolve the 1 HtmlTreeBuilderState.process (cognitive 1857) finding(s) in Cognitive Complexity — start with HtmlTreeBuilderState.swift. — 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 Classes7.0 / 10Adequate✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
Resolve the 18 TooManyMethods finding(s) in God Classes — start with Element.swift, HtmlTreeBuilder.swift, Node.swift. — One of this dimension's main actionable groups (18 warning-level).
Resolve the 16 FileTooLong finding(s) in God Classes — start with TokeniserState.swift, HtmlTreeBuilderState.swift, Element.swift. — One of this dimension's main actionable groups (16 warning-level).
Resolve the 14 ClassTooLong finding(s) in God Classes — start with TokeniserState.swift, Element.swift, Entities.swift. — One of this dimension's main actionable groups (14 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.
140 duplicated block group(s) detected. A further 7 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted.
+ 67 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 8 Duplicated block (11 lines × 2) finding(s) in Code Duplication — start with TokeniserState.swift (5), StringUtil.swift (2), Entities.swift. — One of this dimension's main actionable groups (8 warning-level).
Resolve the 7 Duplicated block (15 lines × 2) finding(s) in Code Duplication — start with HtmlTreeBuilderState.swift (2), TokeniserState.swift (2), CharacterReader.swift. — One of this dimension's main actionable groups (7 warning-level).
Resolve the 7 Duplicated block (13 lines × 2) finding(s) in Code Duplication — start with TokeniserState.swift (4), Element.swift, Entities.swift. — One of this dimension's main actionable groups (7 warning-level).
Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · Coupling6.0 / 10Adequate✓ Tool-verified
What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.
Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.
Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.
2 production modules (SwiftPM), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 1 module(s) off the main sequence.
Off the main sequence: SwiftSoup
What to do
Resolve the 1 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
Enforce Coupling in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
Low cohesion: Element (LCOM4 50) · ×10Sources/Element.swift:300
What to do
Resolve the 10 Low cohesion finding(s) in Cohesion (LCOM4) — start with Element.swift, String.swift, HtmlTreeBuilder.swift. — One of this dimension's main actionable groups (10 warning-level).
Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How much of the code is actually exercised by tests.
Method: Coverage from coverlet runs or committed reports (Cobertura/OpenCover/lcov), computed per-file with structured exclusions for generated, trivial, and glue code. When the suite can't be built/run in-image AND no report is committed, coverage is reported NOT-MEASURED (excluded from the score) with the precondition to make it measurable — never a LoC-ratio proxy folded in as if measured. Deterministic.
Resolve the 7 Low coverage finding(s) in Code Coverage — start with BinarySearch.swift, ParseError.swift, Profiler.swift. — One of this dimension's main actionable groups (7 warning-level).
Enforce Code Coverage in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d8_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.
1522 test methods: 1522 unit, 0 integration, 0 BDD, 0 e2e. The Python suite contributes 12 test function(s) across 1 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality8.5 / 10Adequategated by 2 critical findings✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
Resolve the 2 Assertions commented out finding(s) in Test Quality — start with CharacterReaderTest.swift, ElementTest.swift. — One of this dimension's main actionable groups (2 issue-level).
Resolve the 144 No assertions finding(s) in Test Quality — start with CleanerTest.swift (20), CssTest.swift (11), CssIdentifierEscapeTest.swift (8). — One of this dimension's main actionable groups (144 warning-level).
Resolve the 1 Skipped test finding(s) in Test Quality — start with HasAncestorCollectionTest.swift. — 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 Reliability8.0 / 10Adequategated by 1 critical finding✓ 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.
What it measures: Whether dependencies are current, secure, and not bloated.
Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.
2 outdated direct SwiftPM dependencies, 0 pinning defect(s). SwiftPM has no package registry: a dependency is a repository URL and its releases are that repository's semver tags, so currency is answered by listing tags rather than by querying an index. Only a newer tag on the SAME MAJOR is reported — a `from:` requirement admits everything below the next major and nothing above it, so a major crossing needs a Package.swift edit rather than an update, and naming the update as its remedy would be wrong. Whether any dependency is DEPRECATED or ABANDONED is not graded and cannot be: a repository publishes no such marker, and there is no registry that could carry one. Known CVEs in this dependency graph are D30's question.
Outdated: lrucache · ×2
✓ On the Gold path — maintain.
Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: 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.
Resolve the 8 Hotspot finding(s) in Churn × Complexity Hotspots — start with HtmlTreeBuilderState.swift, TokeniserState.swift, Tokeniser.swift. — One of this dimension's main actionable groups (8 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor9.0 / 10Exemplary✓ Tool-verified
What it measures: Whether knowledge is concentrated in too few people (the "bus factor").
Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.
7 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is Sources/Document.swift. Counted over 72 of the 88 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Off-boarding risk: anonymized user #1
Further sole-owners (lower concentration)
✓ 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.
60 deducted task-comment markers across 35931 LoC (0.2/KLoC) → score 9.7. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
TodoComment · ×60Sources/XmlTreeBuilder.swift:98
What to do
Resolve the 60 TodoComment finding(s) in Explicit Debt — start with HtmlTreeBuilderState.swift (19), FormElementTest.swift (7), HtmlTreeBuilder.swift (5). — One of this dimension's main actionable groups (60 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.
The repository's root README is a well-written, cohesive document that describes SwiftSoup as a pure Swift library for HTML parsing across macOS/iOS/tvOS/watchOS/Linux and its WHATWG-compliant API. It lists the supported platforms, SPM/Carthage compatibility, and a bulleted list of key features (parse/scrape from URL/file/string, find extract data with DOM or CSS selectors, modify elements, sanitize content to prevent XSS, generate clean HTML). The document is visually rich with Shields badges and an overview image. It also begins under the title with an opening paragraph that states what the project is for, so it qualifies as having an overview; however, the body is clipped mid-sentence inside '## Swi' before any installation, usage examples, or contribution guidance appear.
What to do
Improve Documentation Quality — currently 7.0/10. — The repository's root README is a well-written, cohesive document that describes SwiftSoup as a pure Swift library for HTML parsing across macOS/iOS/tvOS/watchOS/Linux and its WHATWG-compliant API. It lists the supported platforms, SPM/Carthage compatibility, and a bulleted list of key features (parse/scrape from URL/file/string, find extract data with DOM or CSS selectors, modify elements, sanitize content to prevent XSS, generate clean HTML). The document is visually rich with Shields badges and an overview image. It also begins under the title with an opening paragraph that states what the project is for, so it qualifies as having an overview; however, the body is clipped mid-sentence inside '## Swi' before any installation, usage examples, or contribution guidance appear.
Detailed fixes: d19_recommendation.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.
What it measures: Whether names — types, methods, variables — are clear and consistent.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic random symbol sample (fixed size, not exhaustive), with disclosed confidence band. Advisory, sampled.
0 naming inconsistencies across 0 sampled symbols.
✓ On the Gold path — maintain.
Detailed fixes: d21_recommendation.md.
Do you agree with this assessment?
D22 · Internal API ConsistencyWeak◐ Sampled · advisory
What it measures: Whether the internal API surface is consistent and coherent.
Method: Judged by language model at low temperature over a sample of the public API surface (IsPackable or .Contracts types). Sampled, advisory; confidence discounted by model uncertainty.
7 API inconsistencies across a 400-member sample of 112 exposed types.
Inconsistent constructor naming and arity for string-based initialization. There are two constructors taking key/value pairs (one for UTF8 bytes, one for Strings), but a third constructor `init(String)` exists with no clear semantic mapping (is it a key? a serialized attribute?). This breaks the symmetry of the API.
Inconsistent naming convention for UTF-8 vs String accessors. The `Attribute` type uses `Key`/`Value` for String and `KeyUTF8`/`ValueUTF8` for bytes. However, `Element` uses `tagName()` for String and `tagNameUTF8()` for bytes, but `nodeName()` vs `nodeNameUTF8()`. While consistent within themselves, the mix of `Key`/`Value` (semantic) vs `Name` (structural) across types is confusing. More critically, `Attribute` lacks a `toString()` equivalent for the whole attribute in a unified way compared to `Element`.
Redundant and confusingly named methods for tag names. `tagName()` and `tagNameNormal()` exist, as do their UTF8 counterparts. It is unclear what 'Normal' implies (lowercased? normalized whitespace?) without documentation. This creates 4 methods for essentially the same data point.
Duplicate intent between `nodeName` and `tagName`. In HTML DOM, these are often synonymous for elements, but the API exposes both with both String and UTF8 variants. This leads to 4 methods doing nearly the same thing.
Inconsistent return types for UTF-8 text. `textUTF8` returns `[UInt8]` (Array), while `textUTF8Slice` returns `ArraySlice<UInt8>`. This forces users to choose between copying data (Array) or managing lifetimes (Slice) without a clear pattern (e.g., `text()` vs `textSlice()`).
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 Inconsistent constructor naming and arity for string-based… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 Inconsistent naming convention for UTF-8 vs String accessors. The… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 Redundant and confusingly named methods for tag names. `tagName()` and… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d22_recommendation.md · top locations in Appendix A, every location in findings.md.
1 of 1 build units (SwiftPM) flagged as possibly oversized/incoherent.
Projects may be oversized for their cohesion
What to do
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: 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).
36 finding(s): 0 critical, 3 high, 0 medium, 33 low. 2 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 1 file(s) — `REDACTED` (line 379) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them.
REDACTED
REDACTED
REDACTED
What to do
Resolve the 33 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (20), REDACTED (8), REDACTED (5). — One of this dimension's main actionable groups (33 recommendation-level).
Resolve the 1 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
No action in Static Analysis (SAST) — all 2 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 (2 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 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.
2 of 72 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is Tests-macOS/ParserBenchmark.swift. Counted over 72 of the 88 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Orphaned files with no living knowledge
✓ On the Gold path — maintain.
Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.
Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.
Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.
What to do
The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.
Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.
Do you agree with this assessment?
AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified
Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.
Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.
Other · 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 an 'Architecture' / 'How it works' section to the root README — the high-level shape.
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.
No C4/Structurizr/PlantUML/Mermaid/Graphviz/D2 diagram, no drawn diagram named for the architecture, no file named `architecture` or `design` in any markup this check reads, and nothing in the README, docs or contributor guides that announces the shape — no `## Architecture` heading, no "architecture overview"/"high-level design" phrasing, no "the architecture is …" introduction, no guided code tour. A shape laid out in prose that never names itself as the architecture is not visible to this check, and neither is one kept outside the repository, so this row reports the absence of a re-findable shape document — not evidence that nobody wrote the shape down.
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).
Add a C4 context/container diagram (Structurizr, PlantUML or Mermaid) or an architecture.md overview.
Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).
Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).
Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.
No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 2433 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: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Enable Dependabot/Renovate or a dependency-review gate.
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Performance — Whether the code is written to minimise allocations so it doesn't pressure its host's memory manager — buffer/slice views over copies, object pooling, stack or value-type allocation, and buffer writers. Reward-only: credited where present, never penalised where a simpler style is fine.
Method: Production-source scan: density (per 1k LoC) of allocation-aware APIs — in .NET Span/Memory, ArrayPool/ObjectPool, stackalloc, ValueTask, value-type structs, IBufferWriter, string.Create, SkipLocalsInit; off .NET, with comments and strings blanked, Go's sync.Pool, preallocated slices/maps, Grow, strconv.Append* and buf[:0] reuse; the JVM's NIO buffer views, MemorySegment, primitive collections, pools and literal presizes (plus Kotlin primitive arrays and value classes, Scala AnyVal and @specialized); Swift's reserveCapacity, ContiguousArray, withUnsafe* access and ~Copyable. Activated off .NET on the same floor (400 lines, and benchmarks or 8 uses); Rust and garbage-collected scripting languages are not applicable. Reward-only. Deterministic, syntax/text detection.
What to do
Raise allocation-aware density on the hot paths — currently 168 use(s) across 37,627 production line(s) (~4.5/1k). More of the idioms below on the allocation-heavy paths climbs this toward 10.
Swift: on hot paths, reserveCapacity before appending, use ContiguousArray for class-element arrays, work in place with withUnsafeBufferPointer/withUnsafeTemporaryAllocation, and make large values ~Copyable with borrowing/consuming parameters.
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.
Not evidenced — 5 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.
P4 Deployment & Rollback — not evidenced — no deploy/rollback/approval signal in the repo; absence of evidence is not evidence of a manual release
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 76 check(s) not relevant to this codebase
These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.
AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
AC7 A11y enforcement — No web markup found — accessibility is not applicable to this repository.
AX1 Captive dependencies — not 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
AX2 Stateful singletons — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
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
AXB1 Runtime evidence locked — no reproducible boot — 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 — Package licences not graded — dependencies declared to CocoaPods
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.
D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout nor 2+ sibling source directories each declaring an aggregate root. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — No inline comments to assess — comment value is not applicable here.
D25 ADR Conformance — no ADRs to check
D27 Navigability — symbol resolution incomplete — navigability not assessed
D30 Dependency Vulnerabilities — Scanner failed to run — not a clean result
D31 IaC & Container Security — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
D32 Data Compliance (PII/GDPR) — 3 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D36 Supply-chain Provenance & Signing — The CI pipeline builds and tests but publishes no released artifact — no package publish, container push, GitHub release or deployment step. Supply-chain provenance, signing and SBOM attest RELEASED artifacts, so there is nothing to attest here. Add them to the release pipeline when this repo starts shipping artifacts (a published package, a container image, a deployed service or a tagged release). Build integrity and workflow-token hygiene are reported below: they describe what the CI runs and the token it runs with, neither of which is affected by whether the pipeline ships an artifact.
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.
D43 Malicious Dependencies — Scanner failed to run — not a clean result
D44 Platform End-of-Life — Platform end-of-life not assessed — this repository declares no platform this pass reads
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
DM1 Domain Modelling — not scored — this repository shows none of the 3 signals this lens looks for
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 — This repository's Swift source (1 module(s), 63 file(s) read) declares no entry point and bootstraps no server, and nothing here deploys a service — it is a library, run inside whatever hosts it, so production observability (structured logging, tracing/metrics, health checks) is N/A. If it grows a binary or a service, the dimension reactivates.
P7 Outbound HTTP resilience — not applicable — no HTTP server, API framework or worker entry point was found in the Python, Swift source, so there is no service whose uptime a failing dependency could take down
P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
P9 Domain vs controller coverage — coverage data present for 60 file(s), but no domain-layer files were identified: no covered file's path contains any of the markers this check keys on (/domain/, /aggregates/, /valueobjects/, /domainmodel/, .domain/, /entities/), which are matched case-insensitively anywhere in the path. With no domain partition there is nothing to compare the web/controller layer against — if this repository keeps its business rules under a folder named none of those, that naming is what the check cannot see, not the domain logic.
PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for `Benchmark("…")` in a file importing package-benchmark, or package-benchmark in Package.swift, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
PF3 Async & latency hygiene — Sync-over-async was not assessed: this repository's async code is written in Swift, whose blocking calls this check does not model yet. That is a gap in the analyzer's language reach, not a finding about your code.
S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
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
X10 Duplicated predicate — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
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 — 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
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 is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X7 Silent fallback defaults — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
Assertions commented out: testRangeEquals Tests/SwiftSoupTests/CharacterReaderTest.swift:477— The test body contains commented-out assertion calls and no live one — it runs, verifies nothing, and still passes. Restore the assertions or delete the test; a green test that checks nothing is worse than an absent one.
Assertions commented out: testDataset Tests/SwiftSoupTests/ElementTest.swift:602— The test body contains commented-out assertion calls and no live one — it runs, verifies nothing, and still passes. Restore the assertions or delete the test; a green test that checks nothing is worse than an absent one.
No assertions: testSharedCollectionNotifiesEveryElement Tests/SwiftSoupTests/AttributeOwnershipTest.swift:60— 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.
No assertions: testManySharedOwnersAndRemovalOrders Tests/SwiftSoupTests/AttributeOwnershipTest.swift:346— 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.
No assertions: testGenericDispatchAllRangesAndBackings Tests/SwiftSoupTests/ByteSliceContiguousStorageTest.swift:29— 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.
No assertions: testNonASCIIScalarsAndComposedGraphemes Tests/SwiftSoupTests/CharacterClassificationFastPathTest.swift:72— 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.
No assertions: testURLCrashRegression Tests/SwiftSoupTests/CharacterReaderTest.swift:528— 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.
No assertions: testLetterAndDigitTransitionsPreserveUTF8 Tests/SwiftSoupTests/CharacterReaderUnicodeCursorTest.swift:53— 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.
No assertions: testGeneratedScannersMatchIndependentScalarOracle Tests/SwiftSoupTests/CharacterReaderUnicodeCursorTest.swift:59— 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.
No assertions: testMixedNodeListsAgainstExplicitModel Tests/SwiftSoupTests/ChildIndexedReadTest.swift:54— 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.
No assertions: testStaleSiblingIndexesAreNotUsed Tests/SwiftSoupTests/ChildIndexedReadTest.swift:114— 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.
No assertions: testSeededMovesRemovalsAndEmpty Tests/SwiftSoupTests/ChildIndexedReadTest.swift:126— 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.
No assertions: testTrimModeTrimsWhitespaceFromHttpURL Tests/SwiftSoupTests/CleanerTest.swift:364— 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.
No assertions: testTrimModeTrimsWhitespaceFromImgSrc Tests/SwiftSoupTests/CleanerTest.swift:372— 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.
No assertions: testTrimModeTrimsWhitespaceFromMailtoURL Tests/SwiftSoupTests/CleanerTest.swift:380— 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.
No assertions: testTrimModeStripsWhitespaceOnlyHref Tests/SwiftSoupTests/CleanerTest.swift:388— 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.
No assertions: testTrimModeTrimsTabsAndNewlines Tests/SwiftSoupTests/CleanerTest.swift:396— 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.
No assertions: testTrimModePreservesInternalWhitespace Tests/SwiftSoupTests/CleanerTest.swift:404— 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.
No assertions: testStrictModeRejectsWhitespaceURLs Tests/SwiftSoupTests/CleanerTest.swift:414— 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.
No assertions: testStrictModeAllowsCleanURLs Tests/SwiftSoupTests/CleanerTest.swift:422— 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.
No assertions: testAllowModePreservesWhitespaceInOutput Tests/SwiftSoupTests/CleanerTest.swift:432— 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.
No assertions: testBaseURIResolvesAbsoluteWhitespaceURLInStrictMode Tests/SwiftSoupTests/CleanerTest.swift:442— 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.
No assertions: testBaseURIResolvesAbsoluteWhitespaceURLInTrimMode Tests/SwiftSoupTests/CleanerTest.swift:451— 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.
No assertions: testBaseURIResolvesAbsoluteWhitespaceURLInAllowMode Tests/SwiftSoupTests/CleanerTest.swift:460— 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.
No assertions: testBaseURIResolvesRelativeWhitespaceURLInStrictMode Tests/SwiftSoupTests/CleanerTest.swift:469— 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.
No assertions: testBaseURIResolvesRelativeWhitespaceURLInTrimMode Tests/SwiftSoupTests/CleanerTest.swift:478— 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.
No assertions: testBaseURIResolvesRelativeWhitespaceURLInAllowMode Tests/SwiftSoupTests/CleanerTest.swift:487— 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.
TodoComment Sources/XmlTreeBuilder.swift:98— // todo: wonder if for xml parsing, should treat all tags as unknown? because it's not html. — 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 Sources/TokeniserState.swift:1124— // todo: handle bogus comment starting from eof. when does that trigger? — 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 Sources/TokeniserState.swift:1130— // todo: replace nullChar with replaceChar — 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 Sources/TokeniserState.swift:1141— // todo: should actually check current namepspace, and only non-html allows cdata. until namespace — 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 Sources/Tokeniser.swift:1208— // todo: implement namespaces correctly — 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 Sources/TokenQueue.swift:243— // todo: method name. not good that consumeToSlice cares for case, and consume to any doesn't. And the only use for this — 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 Sources/Token.swift:465— // todo: check if attribute name exists; if so, drop and error — 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 Sources/Tag.swift:606— // todo: I think we just need submit tags, and can scrub listed — 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 Sources/SwiftSoup.swift:265— //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 Sources/SwiftSoup.swift:281— //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 Sources/SwiftSoup.swift:297— //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 Sources/FormElement.swift:70— //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 Sources/FormElement.swift:89— //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/SwiftSoupTests/XmlTreeBuilderTest.swift:223— //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/SwiftSoupTests/FormElementTest.swift:23— //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/SwiftSoupTests/FormElementTest.swift:46— //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/SwiftSoupTests/FormElementTest.swift:114— //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/SwiftSoupTests/FormElementTest.swift:119— //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/SwiftSoupTests/FormElementTest.swift:128— //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/SwiftSoupTests/DocumentTest.swift:137— //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/SwiftSoupTests/DocumentTest.swift:212— //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/SwiftSoupTests/DocumentTest.swift:443— //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 Sources/HtmlTreeBuilderState.swift:39— // TODO: Replace sets with byte masks for speed (easier done via single byte ASCII assumption, too) — 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 Sources/HtmlTreeBuilderState.swift:86— // todo: parse error check on expected doctypes — 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 Sources/HtmlTreeBuilderState.swift:87— // todo: quirk state check on doctype ids — 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.
TooManyMethods: Element Sources/Element.swift:300— TooManyMethods — 176 methods. The bar is 30 methods; this is 146 over it, 5.87× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: HtmlTreeBuilder Sources/HtmlTreeBuilder.swift:13— TooManyMethods — 104 methods. The bar is 30 methods; this is 74 over it, 3.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Node Sources/Node.swift:23— TooManyMethods — 99 methods. The bar is 30 methods; this is 69 over it, 3.30× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: CharacterReader Sources/CharacterReader.swift:10— TooManyMethods — 89 methods. The bar is 30 methods; this is 59 over it, 2.97× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Attributes Sources/Attributes.swift:31— TooManyMethods — 74 methods. The bar is 30 methods; this is 44 over it, 2.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Elements Sources/Elements.swift:13— TooManyMethods — 51 methods. The bar is 30 methods; this is 21 over it, 1.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Tokeniser Sources/Tokeniser.swift:10— TooManyMethods — 51 methods. The bar is 30 methods; this is 21 over it, 1.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Tag Sources/Token.swift:128— TooManyMethods — 49 methods. The bar is 30 methods; this is 19 over it, 1.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TokenQueue Sources/TokenQueue.swift:10— TooManyMethods — 48 methods. The bar is 30 methods; this is 18 over it, 1.60× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Document Sources/Document.swift:29— TooManyMethods — 46 methods. The bar is 30 methods; this is 16 over it, 1.53× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: StringUtil Sources/StringUtil.swift:19— TooManyMethods — 45 methods. The bar is 30 methods; this is 15 over it, 1.50× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TextNode Sources/TextNode.swift:18— TooManyMethods — 45 methods. The bar is 30 methods; this is 15 over it, 1.50× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Entities Sources/Entities.swift:20— TooManyMethods — 38 methods. The bar is 30 methods; this is 8 over it, 1.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Whitelist Sources/Whitelist.swift:52— TooManyMethods — 38 methods. The bar is 30 methods; this is 8 over it, 1.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Tag Sources/Tag.swift:10— TooManyMethods — 37 methods. The bar is 30 methods; this is 7 over it, 1.23× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Attribute Sources/Attribute.swift:10— TooManyMethods — 33 methods. The bar is 30 methods; this is 3 over it, 1.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Parser Sources/Parser.swift:14— TooManyMethods — 31 methods. The bar is 30 methods; this is 1 over it, 1.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: StringBuilder Sources/StringBuilder.swift:7— TooManyMethods — 31 methods. The bar is 30 methods; this is 1 over it, 1.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
FileTooLong: Sources/TokeniserState.swift Sources/TokeniserState.swift— FileTooLong — 2593 significant lines (blank, comment-only and punctuation-only lines excluded), about 96% of them inside a single declaration: TokeniserState (114-3002). The bar is 500 significant lines; this is 2093 over it, 5.19× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/HtmlTreeBuilderState.swift Sources/HtmlTreeBuilderState.swift— FileTooLong — 2109 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1609 over it, 4.22× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Sources/Element.swift Sources/Element.swift— FileTooLong — 1968 significant lines (blank, comment-only and punctuation-only lines excluded), about 64% of them inside a single declaration: Element (300-2769). The bar is 500 significant lines; this is 1468 over it, 3.94× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/CharacterReader.swift Sources/CharacterReader.swift— FileTooLong — 1297 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 797 over it, 2.59× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Sources/Entities.swift Sources/Entities.swift— FileTooLong — 1071 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: Entities (20-1498). The bar is 500 significant lines; this is 571 over it, 2.14× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/Token.swift Sources/Token.swift— FileTooLong — 1059 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: Token (10-1425). The bar is 500 significant lines; this is 559 over it, 2.12× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/HtmlTreeBuilder.swift Sources/HtmlTreeBuilder.swift— FileTooLong — 1004 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: HtmlTreeBuilder (13-1522). The bar is 500 significant lines; this is 504 over it, 2.01× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/Tokeniser.swift Sources/Tokeniser.swift— FileTooLong — 914 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: Tokeniser (10-1241). The bar is 500 significant lines; this is 414 over it, 1.83× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/Attributes.swift Sources/Attributes.swift— FileTooLong — 895 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: Attributes (31-1366). The bar is 500 significant lines; this is 395 over it, 1.79× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/StringUtil.swift Sources/StringUtil.swift— FileTooLong — 858 significant lines (blank, comment-only and punctuation-only lines excluded), about 99% of them inside a single declaration: StringUtil (19-1284). The bar is 500 significant lines; this is 358 over it, 1.72× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/CssSelector.swift Sources/CssSelector.swift— FileTooLong — 851 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: CssSelector (76-1245). The bar is 500 significant lines; this is 351 over it, 1.70× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/Node.swift Sources/Node.swift— FileTooLong — 730 significant lines (blank, comment-only and punctuation-only lines excluded), about 97% of them inside a single declaration: Node (23-1371). The bar is 500 significant lines; this is 230 over it, 1.46× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: SwiftSoupProfile/main.swift Tools/SwiftSoupProfile/main.swift— FileTooLong — 659 significant lines (blank, comment-only and punctuation-only lines excluded), about 71% of them inside a single declaration: runWorkload (189-768). The bar is 500 significant lines; this is 159 over it, 1.32× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/Evaluator.swift Sources/Evaluator.swift— FileTooLong — 573 significant lines (blank, comment-only and punctuation-only lines excluded), about 92% of them inside a single declaration: Evaluator (51-1018). The bar is 500 significant lines; this is 73 over it, 1.15× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: Sources/Whitelist.swift Sources/Whitelist.swift— FileTooLong — 551 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 51 over it, 1.10× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Sources/Document.swift Sources/Document.swift— FileTooLong — 523 significant lines (blank, comment-only and punctuation-only lines excluded), about 82% of them inside a single declaration: Document (29-829). The bar is 500 significant lines; this is 23 over it, 1.05× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
ClassTooLong: TokeniserState Sources/TokeniserState.swift:114— ClassTooLong — 2497 significant lines (blank, comment-only and punctuation-only lines excluded), 16 methods. The bar is 400 significant lines; this is 2097 over it, 6.24× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Element Sources/Element.swift:300— ClassTooLong — 1261 significant lines (blank, comment-only and punctuation-only lines excluded), 176 methods. The bar is 400 significant lines; this is 861 over it, 3.15× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Entities Sources/Entities.swift:20— ClassTooLong — 1065 significant lines (blank, comment-only and punctuation-only lines excluded), 38 methods. The bar is 400 significant lines; this is 665 over it, 2.66× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Token Sources/Token.swift:10— ClassTooLong — 1052 significant lines (blank, comment-only and punctuation-only lines excluded), 22 methods. The bar is 400 significant lines; this is 652 over it, 2.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: HtmlTreeBuilder Sources/HtmlTreeBuilder.swift:13— ClassTooLong — 1001 significant lines (blank, comment-only and punctuation-only lines excluded), 104 methods. The bar is 400 significant lines; this is 601 over it, 2.50× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Tokeniser Sources/Tokeniser.swift:10— ClassTooLong — 913 significant lines (blank, comment-only and punctuation-only lines excluded), 51 methods. The bar is 400 significant lines; this is 513 over it, 2.28× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Attributes Sources/Attributes.swift:31— ClassTooLong — 882 significant lines (blank, comment-only and punctuation-only lines excluded), 74 methods. The bar is 400 significant lines; this is 482 over it, 2.21× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: StringUtil Sources/StringUtil.swift:19— ClassTooLong — 852 significant lines (blank, comment-only and punctuation-only lines excluded), 45 methods. The bar is 400 significant lines; this is 452 over it, 2.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: CssSelector Sources/CssSelector.swift:76— ClassTooLong — 848 significant lines (blank, comment-only and punctuation-only lines excluded), 23 methods. The bar is 400 significant lines; this is 448 over it, 2.12× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Node Sources/Node.swift:23— ClassTooLong — 707 significant lines (blank, comment-only and punctuation-only lines excluded), 99 methods. The bar is 400 significant lines; this is 307 over it, 1.77× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Evaluator Sources/Evaluator.swift:51— ClassTooLong — 525 significant lines (blank, comment-only and punctuation-only lines excluded), 4 methods. The bar is 400 significant lines; this is 125 over it, 1.31× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Document Sources/Document.swift:29— ClassTooLong — 429 significant lines (blank, comment-only and punctuation-only lines excluded), 46 methods. The bar is 400 significant lines; this is 29 over it, 1.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Tag Sources/Tag.swift:10— ClassTooLong — 415 significant lines (blank, comment-only and punctuation-only lines excluded), 37 methods. The bar is 400 significant lines; this is 15 over it, 1.04× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: StringBuilder Sources/StringBuilder.swift:7— ClassTooLong — 405 significant lines (blank, comment-only and punctuation-only lines excluded), 31 methods. The bar is 400 significant lines; this is 5 over it, 1.01× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
MethodTooLong: TokeniserState.read Sources/TokeniserState.swift:185— MethodTooLong — read runs 1768 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 1668 over it, 17.68× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Attribute.observeMutations Sources/Attribute.swift:5— MethodTooLong — observeMutations runs 293 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 193 over it, 2.93× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: CssSelector.fastSimpleQueryPlan Sources/CssSelector.swift:730— MethodTooLong — fastSimpleQueryPlan runs 279 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 179 over it, 2.79× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Tokeniser.consumeCharacterReference Sources/Tokeniser.swift:768— MethodTooLong — consumeCharacterReference runs 217 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 117 over it, 2.17× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Entities.escape Sources/Entities.swift:586— MethodTooLong — escape runs 198 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 98 over it, 1.98× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Entities.escape Sources/Entities.swift:838— MethodTooLong — escape runs 197 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 97 over it, 1.97× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Entities.escape Sources/Entities.swift:1087— MethodTooLong — escape runs 169 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 69 over it, 1.69× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: FastQueryPlan.apply Sources/CssSelector.swift:306— MethodTooLong — apply runs 159 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 59 over it, 1.59× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: StringUtil.appendNormalisedWhitespaceBytes Sources/StringUtil.swift:1004— MethodTooLong — appendNormalisedWhitespaceBytes runs 148 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 48 over it, 1.48× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: StringUtil.appendNormalisedWhitespace Sources/StringUtil.swift:797— MethodTooLong — appendNormalisedWhitespace runs 146 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 46 over it, 1.46× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: TokeniserState.readTagNameFromTagOpen Sources/TokeniserState.swift:2334— MethodTooLong — readTagNameFromTagOpen runs 125 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 25 over it, 1.25× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: HtmlTreeBuilder.insert Sources/HtmlTreeBuilder.swift:448— MethodTooLong — insert runs 115 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 15 over it, 1.15× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
Low cohesion: Element (LCOM4 50) Sources/Element.swift:300— Element's methods fall into 50 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 50 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: String (LCOM4 17) Sources/String.swift:266— String's methods fall into 17 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 17 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: HtmlTreeBuilder (LCOM4 9) Sources/HtmlTreeBuilder.swift:13— HtmlTreeBuilder's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Node (LCOM4 7) Sources/Node.swift:23— Node's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Tag (LCOM4 7) Sources/Tag.swift:10— Tag's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Token (LCOM4 7) Sources/Token.swift:10— Token's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: AppDelegate (LCOM4 6) Example/Example/AppDelegate.swift:11— AppDelegate's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Document (LCOM4 5) Sources/Document.swift:29— Document's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: ParseSettings (LCOM4 4) Sources/ParseSettings.swift:10— ParseSettings's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: XmlTreeBuilder (LCOM4 4) Sources/XmlTreeBuilder.swift:19— XmlTreeBuilder's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Hotspot: Sources/HtmlTreeBuilderState.swift Sources/HtmlTreeBuilderState.swift:78— Sources/HtmlTreeBuilderState.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 706 in HtmlTreeBuilderState.process at line 78. 2 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-06-27..2026-09-25, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-27 21:44:28 -04:00' --until='2026-09-25 21:44:28 -04:00' --full-history --no-merges -- Sources/HtmlTreeBuilderState.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Sources/TokeniserState.swift Sources/TokeniserState.swift:185— Sources/TokeniserState.swift changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 411 in TokeniserState.read at line 185. 2 of those changes were fix/bug commits, and the other 2 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-06-27..2026-09-25, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-27 21:44:28 -04:00' --until='2026-09-25 21:44:28 -04:00' --full-history --no-merges -- Sources/TokeniserState.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Sources/Tokeniser.swift Sources/Tokeniser.swift:768— Sources/Tokeniser.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 122 in Tokeniser.consumeCharacterReference at line 768. 2 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-06-27..2026-09-25, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-27 21:44:28 -04:00' --until='2026-09-25 21:44:28 -04:00' --full-history --no-merges -- Sources/Tokeniser.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Sources/Entities.swift Sources/Entities.swift:838— Sources/Entities.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 119 in Entities.escape at line 838. 2 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-06-27..2026-09-25, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-27 21:44:28 -04:00' --until='2026-09-25 21:44:28 -04:00' --full-history --no-merges -- Sources/Entities.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Sources/Document.swift Sources/Document.swift:729— Sources/Document.swift changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 15 in Document.patchedOuterHtmlUTF8 at line 729. 6 of those changes were fix/bug commits, and the other 7 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-06-27..2026-09-25, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-27 21:44:28 -04:00' --until='2026-09-25 21:44:28 -04:00' --full-history --no-merges -- Sources/Document.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Sources/StringUtil.swift Sources/StringUtil.swift:1004— Sources/StringUtil.swift changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 64 in StringUtil.appendNormalisedWhitespaceBytes at line 1004. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-06-27..2026-09-25, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-27 21:44:28 -04:00' --until='2026-09-25 21:44:28 -04:00' --full-history --no-merges -- Sources/StringUtil.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Sources/TextNode.swift Sources/TextNode.swift:275— Sources/TextNode.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 25 in TextNode.outerHtmlHead at line 275. 2 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-06-27..2026-09-25, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-27 21:44:28 -04:00' --until='2026-09-25 21:44:28 -04:00' --full-history --no-merges -- Sources/TextNode.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: Sources/Collector.swift Sources/Collector.swift:194— Sources/Collector.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in Collector.seedCandidates at line 194. 1 of those changes was a fix/bug commit, and the other 2 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-06-27..2026-09-25, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-27 21:44:28 -04:00' --until='2026-09-25 21:44:28 -04:00' --full-history --no-merges -- Sources/Collector.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Duplicated block (11 lines × 2) Sources/Entities.swift:144— Sources/Entities.swift:144-154 | Sources/Entities.swift:158-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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (11 lines × 2) Sources/StringUtil.swift:98— Sources/StringUtil.swift:98-108 | Sources/StringUtil.swift:112-122 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (11 lines × 2) Sources/StringUtil.swift:126— Sources/StringUtil.swift:126-136 | Sources/StringUtil.swift:140-150 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (11 lines × 2) Sources/TokeniserState.swift:1019— Sources/TokeniserState.swift:1019-1029 | Sources/TokeniserState.swift:1072-1082 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1019` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) Sources/TokeniserState.swift:1717— Sources/TokeniserState.swift:1717-1727 | Sources/TokeniserState.swift:2045-2055 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1717` 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) Sources/TokeniserState.swift:1760— Sources/TokeniserState.swift:1760-1770 | Sources/TokeniserState.swift:2088-2098 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1760` 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) Sources/TokeniserState.swift:1859— Sources/TokeniserState.swift:1859-1869 | Sources/TokeniserState.swift:2127-2137 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1859` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) Sources/TokeniserState.swift:1879— Sources/TokeniserState.swift:1879-1889 | Sources/TokeniserState.swift:2140-2150 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1879` it begins part-way through the construct above it, so those 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) Sources/CharacterReader.swift:1258— Sources/CharacterReader.swift:1258-1272 | Sources/CharacterReader.swift:1355-1369 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/CharacterReader.swift:1258` it begins part-way through the construct above it, so those 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, `Sources/CharacterReader.swift:1371` calls `hasByte` and `Sources/CharacterReader.swift:1273` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 2) Sources/HtmlTreeBuilder.swift:501— Sources/HtmlTreeBuilder.swift:501-515 | Sources/HtmlTreeBuilder.swift:517-531 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) Sources/HtmlTreeBuilderState.swift:615— Sources/HtmlTreeBuilderState.swift:615-629 | Sources/HtmlTreeBuilderState.swift:962-976 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilderState.swift:615` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Sources/HtmlTreeBuilderState.swift:2484— Sources/HtmlTreeBuilderState.swift:2484-2498 | Sources/HtmlTreeBuilderState.swift:2506-2520 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilderState.swift:2484` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) Sources/StringUtil.swift:679— Sources/StringUtil.swift:679-693 | Sources/StringUtil.swift:919-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 `Sources/StringUtil.swift:679` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot 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) Sources/TokeniserState.swift:1711— Sources/TokeniserState.swift:1711-1725 | Sources/TokeniserState.swift:1754-1768 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1711` it begins part-way through the construct above it, so those exact lines 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) Sources/TokeniserState.swift:2039— Sources/TokeniserState.swift:2039-2053 | Sources/TokeniserState.swift:2082-2096 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:2039` it begins part-way through the construct above it, so those exact lines 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) Sources/Element.swift:1514— Sources/Element.swift:1514-1526 | Sources/Element.swift:1596-1608 — both copies are in the same file, so extract the block into 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) Sources/Entities.swift:595— Sources/Entities.swift:595-607 | Sources/Entities.swift:1096-1108 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Entities.swift:595` it begins part-way through the construct above it, so those exact lines 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) Sources/HtmlTreeBuilderState.swift:1511— Sources/HtmlTreeBuilderState.swift:1511-1523 | Sources/HtmlTreeBuilderState.swift:1565-1577 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) Sources/TokeniserState.swift:245— Sources/TokeniserState.swift:245-257 | Sources/TokeniserState.swift:376-388 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) Sources/TokeniserState.swift:404— Sources/TokeniserState.swift:404-416 | Sources/TokeniserState.swift:418-430 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) Sources/TokeniserState.swift:664— Sources/TokeniserState.swift:664-676 | Sources/TokeniserState.swift:709-721 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:664` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) Sources/TokeniserState.swift:834— Sources/TokeniserState.swift:834-846 | Sources/TokeniserState.swift:878-890 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:834` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) Sources/Element.swift:1282— Sources/Element.swift:1282-1290 | Sources/Element.swift:1336-1344 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Element.swift:1282` it begins part-way through the construct above it, so those exact lines 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) Sources/HtmlTreeBuilderState.swift:1328— Sources/HtmlTreeBuilderState.swift:1328-1336 | Sources/HtmlTreeBuilderState.swift:1382-1390 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilderState.swift:1328` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) Sources/TokeniserState.swift:660— Sources/TokeniserState.swift:660-668 | Sources/TokeniserState.swift:830-838 — both copies are in the same file, so extract the 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) Sources/TokeniserState.swift:705— Sources/TokeniserState.swift:705-713 | Sources/TokeniserState.swift:874-882 — both copies are in the same file, so extract the 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) Sources/TokeniserState.swift:2298— Sources/TokeniserState.swift:2298-2306 | Sources/TokeniserState.swift:2493-2501 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:2298` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Sources/TreeBuilder.swift:71— Sources/TreeBuilder.swift:71-79 | Sources/TreeBuilder.swift:94-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 `Sources/TreeBuilder.swift:71` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) Tools/SwiftSoupProfile/main.swift:259— Tools/SwiftSoupProfile/main.swift:259-267 | Tools/SwiftSoupProfile/main.swift:269-277 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Tools/SwiftSoupProfile/main.swift:280` calls `Data` and `Tools/SwiftSoupProfile/main.swift:270` 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 × 2) Sources/Evaluator.swift:895— Sources/Evaluator.swift:895-904 | Sources/Evaluator.swift:930-939 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) Sources/HtmlTreeBuilderState.swift:568— Sources/HtmlTreeBuilderState.swift:568-577 | Sources/HtmlTreeBuilderState.swift:612-621 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilderState.swift:568` it begins part-way through the construct above it, so those exact lines 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) Sources/StringUtil.swift:46— Sources/StringUtil.swift:46-55 | Sources/StringUtil.swift:59-68 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (10 lines × 2) Sources/StringUtil.swift:72— Sources/StringUtil.swift:72-81 | Sources/StringUtil.swift:85-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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (10 lines × 2) Tools/SwiftSoupProfile/main.swift:435— Tools/SwiftSoupProfile/main.swift:435-444 | Tools/SwiftSoupProfile/main.swift:618-627 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Tools/SwiftSoupProfile/main.swift:435` 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) Tools/benchmark_exclusion.swift:85— Tools/benchmark_exclusion.swift:85-94 | Tools/benchmark_ordered_insertion.swift:78-87 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single 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 `Tools/benchmark_exclusion.swift:85` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Sources/Attributes.swift:1098— Sources/Attributes.swift:1098-1109 | Sources/Attributes.swift:1114-1125 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (12 lines × 2) Sources/CharacterReader.swift:546— Sources/CharacterReader.swift:546-557 | Sources/CharacterReader.swift:561-572 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/CharacterReader.swift:546` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) Sources/HtmlTreeBuilderState.swift:1699— Sources/HtmlTreeBuilderState.swift:1699-1710 | Sources/HtmlTreeBuilderState.swift:1726-1737 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) Sources/HtmlTreeBuilderState.swift:2037— Sources/HtmlTreeBuilderState.swift:2037-2048 | Sources/HtmlTreeBuilderState.swift:2066-2077 — both copies are in the same file, so extract the block into 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) Sources/TokeniserState.swift:2356— Sources/TokeniserState.swift:2356-2367 | Sources/TokeniserState.swift:2378-2389 — both copies are in the same file, so extract the 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) Sources/Element.swift:1901— Sources/Element.swift:1901-1920 | Sources/Element.swift:1978-1997 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Element.swift:1901` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) Sources/Element.swift:3070— Sources/Element.swift:3070-3089 | Sources/Element.swift:3093-3112 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (20 lines × 2) Sources/StringUtil.swift:155— Sources/StringUtil.swift:155-174 | Sources/StringUtil.swift:179-198 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/StringUtil.swift:155` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20 lines × 2) Sources/StringUtil.swift:216— Sources/StringUtil.swift:216-235 | Sources/StringUtil.swift:240-259 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/StringUtil.swift:216` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 2) Sources/Entities.swift:1303— Sources/Entities.swift:1303-1320 | Sources/Entities.swift:1324-1341 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `bytes` to `ArraySlice<UInt8>` in one and `ByteSlice` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (18 lines × 2) Sources/StringUtil.swift:620— Sources/StringUtil.swift:620-637 | Sources/StringUtil.swift:852-869 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/StringUtil.swift:620` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) Sources/Tokeniser.swift:460— Sources/Tokeniser.swift:460-477 | Sources/Tokeniser.swift:549-566 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Tokeniser.swift:460` it begins part-way through the construct above it, so those exact lines 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) Sources/String.swift:50— Sources/String.swift:50-67 | Sources/String.swift:148-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.
Duplicated block (17 lines × 2) Sources/CharacterReader.swift:1279— Sources/CharacterReader.swift:1279-1295 | Sources/CharacterReader.swift:1379-1395 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/CharacterReader.swift:1279` it begins part-way through the construct above it, so those 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, `Sources/CharacterReader.swift:1397` calls `memchr`, `Int32` and `Sources/CharacterReader.swift:1297` 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 (17 lines × 2) Sources/CssSelector.swift:849— Sources/CssSelector.swift:849-865 | Sources/CssSelector.swift:1003-1019 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/CssSelector.swift:849` 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) Sources/Tokeniser.swift:494— Sources/Tokeniser.swift:494-510 | Sources/Tokeniser.swift:580-596 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Tokeniser.swift:494` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/Tokeniser.swift:493` calls `clearTagStart` and `Sources/Tokeniser.swift:579` 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 (17 lines × 2) Sources/TokeniserState.swift:1807— Sources/TokeniserState.swift:1807-1823 | Sources/TokeniserState.swift:1867-1883 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1807` it begins part-way through the construct above it, so those 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, `Sources/TokeniserState.swift:1825` calls `transition` and `Sources/TokeniserState.swift:1885` 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 (16 lines × 2) Sources/Element.swift:2325— Sources/Element.swift:2325-2340 | Sources/Element.swift:2360-2375 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Element.swift:2325` 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) Sources/HtmlTreeBuilder.swift:938— Sources/HtmlTreeBuilder.swift:938-953 | Sources/HtmlTreeBuilder.swift:965-980 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilder.swift:938` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) Sources/ParsingStrings.swift:198— Sources/ParsingStrings.swift:198-213 | Sources/ParsingStrings.swift:220-235 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/ParsingStrings.swift:198` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) Sources/StringUtil.swift:551— Sources/StringUtil.swift:551-566 | Sources/StringUtil.swift:599-614 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/StringUtil.swift:551` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 3) Sources/StringBuilder.swift:405— Sources/StringBuilder.swift:405-417 | Sources/StringBuilder.swift:492-504 | Sources/StringBuilder.swift:542-554 — 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 `Sources/StringBuilder.swift:405` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) Sources/StringUtil.swift:550— Sources/StringUtil.swift:550-562 | Sources/StringUtil.swift:574-586 | Sources/StringUtil.swift:598-610 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13 lines × 3) Sources/TokeniserState.swift:941— Sources/TokeniserState.swift:941-953 | Sources/TokeniserState.swift:986-998 | Sources/TokeniserState.swift:1029-1041 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 3) Sources/TokeniserState.swift:1604— Sources/TokeniserState.swift:1604-1616 | Sources/TokeniserState.swift:1666-1678 | Sources/TokeniserState.swift:1994-2006 — 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 `Sources/TokeniserState.swift:1604` it begins part-way through the construct above it, so those exact lines 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) Sources/Element.swift:3185— Sources/Element.swift:3185-3189 | Sources/Element.swift:3341-3345 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Element.swift:3185` 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) Sources/Whitelist.swift:526— Sources/Whitelist.swift:526-530 | Sources/Whitelist.swift:571-575 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) Tools/benchmark_exclusion.swift:4— Tools/benchmark_exclusion.swift:4-8 | Tools/benchmark_ordered_insertion.swift:4-8 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (5 lines × 2) Sources/DataNode.swift:230— Sources/DataNode.swift:230-234 | Sources/TextNode.swift:338-342 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (24 lines × 2) Sources/HtmlTreeBuilderState.swift:571— Sources/HtmlTreeBuilderState.swift:571-594 | Sources/HtmlTreeBuilderState.swift:758-781 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (24 lines × 2) Sources/TokeniserState.swift:1727— Sources/TokeniserState.swift:1727-1750 | Sources/TokeniserState.swift:1770-1793 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1727` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (24 lines × 2) Sources/TokeniserState.swift:2055— Sources/TokeniserState.swift:2055-2078 | Sources/TokeniserState.swift:2098-2121 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:2055` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) Sources/Attributes.swift:460— Sources/Attributes.swift:460-467 | Sources/Attributes.swift:503-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. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Attributes.swift:460` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) Sources/HtmlTreeBuilderState.swift:2235— Sources/HtmlTreeBuilderState.swift:2235-2242 | Sources/HtmlTreeBuilderState.swift:2266-2273 — both copies are in the same file, so extract the block into 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) Sources/HtmlTreeBuilderState.swift:2346— Sources/HtmlTreeBuilderState.swift:2346-2353 | Sources/HtmlTreeBuilderState.swift:2417-2424 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilderState.swift:2346` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 3) Sources/Evaluator.swift:358— Sources/Evaluator.swift:358-364 | Sources/Evaluator.swift:396-402 | Sources/Evaluator.swift:434-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 `Sources/Evaluator.swift:358` 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 × 3) Tools/SwiftSoupProfile/main.swift:391— Tools/SwiftSoupProfile/main.swift:391-397 | Tools/SwiftSoupProfile/main.swift:608-614 | Tools/SwiftSoupProfile/main.swift:624-630 — 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/SwiftSoupProfile/main.swift:391` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 3) Tools/benchmark_exclusion.swift:45— Tools/benchmark_exclusion.swift:45-51 | Tools/benchmark_independent_hotspots.swift:81-87 | Tools/benchmark_ordered_insertion.swift:34-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 all 3 call sites, so a change lands once.
Duplicated block (7 lines × 2) Sources/CharacterReader.swift:916— Sources/CharacterReader.swift:916-922 | Sources/CharacterReader.swift:955-963 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, 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 (7 lines × 2) Sources/Evaluator.swift:906— Sources/Evaluator.swift:906-912 | Sources/Evaluator.swift:941-947 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Evaluator.swift:906` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Sources/HtmlTreeBuilderState.swift:2373— Sources/HtmlTreeBuilderState.swift:2373-2379 | Sources/HtmlTreeBuilderState.swift:2415-2421 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilderState.swift:2373` 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 × 3) Sources/CharacterReader.swift:1119— Sources/CharacterReader.swift:1119-1124 | Sources/CharacterReader.swift:1251-1256 | Sources/CharacterReader.swift:1348-1353 — 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 `Sources/CharacterReader.swift:1119` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/CharacterReader.swift:1250` calls `UInt64` and `Sources/CharacterReader.swift:1118` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 3) Sources/HtmlTreeBuilderState.swift:263— Sources/HtmlTreeBuilderState.swift:263-268 | Sources/HtmlTreeBuilderState.swift:2373-2378 | Sources/HtmlTreeBuilderState.swift:2415-2420 — 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 `Sources/HtmlTreeBuilderState.swift:263` 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/SwiftSoupProfile/main.swift:439— Tools/SwiftSoupProfile/main.swift:439-444 | Tools/SwiftSoupProfile/main.swift:577-584 | Tools/SwiftSoupProfile/main.swift:622-627 — 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/SwiftSoupProfile/main.swift:439` 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.
StringBuilder.write (cognitive 24) Sources/StringBuilder.swift:480— StringBuilder.write has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 1 (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (StringBuilder.write) 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.
StringBuilder.write (cognitive 24) Sources/StringBuilder.swift:530— StringBuilder.write has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 1 (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (StringBuilder.write) 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.
Attribute.appendAttributeValue (cognitive 17) Sources/Attribute.swift:222— Attribute.appendAttributeValue has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 5, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Attribute.appendAttributeValue) 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.
Attribute.appendAttributeValue (cognitive 17) Sources/Attribute.swift:264— Attribute.appendAttributeValue has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 5, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Attribute.appendAttributeValue) 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.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×2
Members sharing a duplicated core (4 members, 50+ identical tokens) Sources/Attributes.swift:1076— Sources/Attributes.swift:1076-1093 | Sources/HtmlTreeBuilderState.swift:78-2467 | Sources/Token.swift:557-610 | Sources/Token.swift:798-814 — 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) Sources/StringUtil.swift:152— Sources/StringUtil.swift:152-174 | Sources/StringUtil.swift:176-198 | Sources/StringUtil.swift:213-235 | Sources/StringUtil.swift:237-259 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Duplicated block (22 lines × 2) Sources/StringUtil.swift:719— Sources/StringUtil.swift:719-740 | Sources/StringUtil.swift:961-982 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/StringUtil.swift:719` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) Sources/StringUtil.swift:810— Sources/StringUtil.swift:810-831 | Sources/StringUtil.swift:1017-1038 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/StringUtil.swift:810` 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 × 3) Sources/CharacterReader.swift:1098— Sources/CharacterReader.swift:1098-1111 | Sources/CharacterReader.swift:1303-1316 | Sources/CharacterReader.swift:1408-1421 — 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 `Sources/CharacterReader.swift:1098` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 3) Sources/StringBuilder.swift:420— Sources/StringBuilder.swift:420-433 | Sources/StringBuilder.swift:515-528 | Sources/StringBuilder.swift:565-578 — 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 `Sources/StringBuilder.swift:420` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Sources/HtmlTreeBuilderState.swift:1659— Sources/HtmlTreeBuilderState.swift:1659-1672 | Sources/HtmlTreeBuilderState.swift:1673-1686 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilderState.swift:1659` it begins part-way through the construct above it, so those exact lines 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) Sources/TokeniserState.swift:2284— Sources/TokeniserState.swift:2284-2297 | Sources/TokeniserState.swift:2340-2353 — both copies are in the same file, so extract the block into 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) Sources/CharacterReader.swift:1126— Sources/CharacterReader.swift:1126-1137 | Sources/CharacterReader.swift:1258-1269 | Sources/CharacterReader.swift:1355-1366 — 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 `Sources/CharacterReader.swift:1126` it begins part-way through the construct above it, so those 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, `Sources/CharacterReader.swift:1271` calls `hasByte` and `Sources/CharacterReader.swift:1138` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) Sources/CharacterReader.swift:1167— Sources/CharacterReader.swift:1167-1178 | Sources/CharacterReader.swift:1234-1245 | Sources/CharacterReader.swift:1330-1341 — 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 `Sources/CharacterReader.swift:1167` 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) Sources/CharacterReader.swift:1246— Sources/CharacterReader.swift:1246-1256 | Sources/CharacterReader.swift:1342-1353 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/CharacterReader.swift:1246` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11–12 lines × 2) Sources/HtmlTreeBuilderState.swift:775— Sources/HtmlTreeBuilderState.swift:775-786 | Sources/HtmlTreeBuilderState.swift:979-989 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/HtmlTreeBuilderState.swift:775` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11 lines × 4) Sources/CharacterReader.swift:1080— Sources/CharacterReader.swift:1080-1090 | Sources/CharacterReader.swift:1167-1177 | Sources/CharacterReader.swift:1234-1244 | Sources/CharacterReader.swift:1330-1340 — 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 `Sources/CharacterReader.swift:1080` 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 × 4) Sources/CharacterReader.swift:1172— Sources/CharacterReader.swift:1172-1182 | Sources/CharacterReader.swift:1239-1249 | Sources/CharacterReader.swift:1335-1345 | Sources/CharacterReader.swift:1467-1477 — 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 `Sources/CharacterReader.swift:1172` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/CharacterReader.swift:1251` calls `UInt64` and `Sources/CharacterReader.swift:1184` 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 × 3) Sources/Element.swift:1904— Sources/Element.swift:1904-1914 | Sources/Element.swift:1947-1957 | Sources/Element.swift:1981-1991 — 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 `Sources/Element.swift:1904` it begins part-way through the construct above it, so those exact lines 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) Sources/TokeniserState.swift:1808— Sources/TokeniserState.swift:1808-1818 | Sources/TokeniserState.swift:1868-1878 | Sources/TokeniserState.swift:1929-1939 — 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, `Sources/TokeniserState.swift:1927` calls `error` and `Sources/TokeniserState.swift:1807` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 4) Sources/CharacterReader.swift:1097— Sources/CharacterReader.swift:1097-1104 | Sources/CharacterReader.swift:1298-1305 | Sources/CharacterReader.swift:1399-1406 | Sources/CharacterReader.swift:1522-1529 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/CharacterReader.swift:1296` calls `memchr`, `Int32` and `Sources/CharacterReader.swift:1095` 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 × 4) Sources/TokeniserState.swift:1179— Sources/TokeniserState.swift:1179-1186 | Sources/TokeniserState.swift:1222-1229 | Sources/TokeniserState.swift:1282-1289 | Sources/TokeniserState.swift:1375-1382 — 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 `Sources/TokeniserState.swift:1179` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Sources/DocumentType.swift:147— Sources/DocumentType.swift:147-151 | Sources/DocumentType.swift:158-162 | Sources/DocumentType.swift:169-173 — 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 `Sources/DocumentType.swift:147` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) Sources/Element.swift:599— Sources/Element.swift:599-603 | Sources/Element.swift:1522-1526 | Sources/Element.swift:1604-1608 — 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 `Sources/Element.swift:599` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 8) Tools/compare_blank_text.py:65— Tools/compare_blank_text.py:65-71 | Tools/compare_character_classification.py:109-115 | Tools/compare_child_reads.py:70-76 | Tools/compare_cursor_moves.py:69-75 | Tools/compare_exclusion.py:65-71 | Tools/compare_independent_hotspots.py:65-71 | Tools/compare_ordered_insertion.py:65-71 | Tools/compare_tokenqueue_search.py:64-70 — before extracting anything, compare `Tools/compare_blank_text.py` and `Tools/compare_character_classification.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Tools/compare_exclusion.py:63` calls `max`, `min`, `ceil` and `Tools/compare_blank_text.py:63` 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 × 8) Tools/compare_blank_text.py:76— Tools/compare_blank_text.py:76-82 | Tools/compare_character_classification.py:119-125 | Tools/compare_child_reads.py:81-87 | Tools/compare_cursor_moves.py:80-86 | Tools/compare_exclusion.py:76-82 | Tools/compare_independent_hotspots.py:76-82 | Tools/compare_ordered_insertion.py:76-82 | Tools/compare_tokenqueue_search.py:75-81 — before extracting anything, compare `Tools/compare_blank_text.py` and `Tools/compare_character_classification.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 8) Tools/compare_blank_text.py:25— Tools/compare_blank_text.py:25-30 | Tools/compare_character_classification.py:60-65 | Tools/compare_child_reads.py:30-35 | Tools/compare_cursor_moves.py:29-34 | Tools/compare_exclusion.py:25-30 | Tools/compare_independent_hotspots.py:25-30 | Tools/compare_ordered_insertion.py:25-30 | Tools/compare_tokenqueue_search.py:22-27 — before extracting anything, compare `Tools/compare_blank_text.py` and `Tools/compare_character_classification.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Tools/compare_character_classification.py:68` calls `validate_workloads` and `Tools/compare_blank_text.py:31` 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 × 8) Tools/compare_blank_text.py:33— Tools/compare_blank_text.py:33-38 | Tools/compare_character_classification.py:71-76 | Tools/compare_child_reads.py:38-43 | Tools/compare_cursor_moves.py:37-42 | Tools/compare_exclusion.py:33-38 | Tools/compare_independent_hotspots.py:33-38 | Tools/compare_ordered_insertion.py:33-38 | Tools/compare_tokenqueue_search.py:30-35 — before extracting anything, compare `Tools/compare_blank_text.py` and `Tools/compare_character_classification.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 4) Tools/compare_exclusion.py:55— Tools/compare_exclusion.py:55-60 | Tools/compare_independent_hotspots.py:55-60 | Tools/compare_ordered_insertion.py:55-60 | Tools/compare_tokenqueue_search.py:52-57 — before extracting anything, compare `Tools/compare_exclusion.py` and `Tools/compare_independent_hotspots.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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/compare_tokenqueue_search.py:58` calls `max`, `min`, `ceil` and `Tools/compare_exclusion.py:61` 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 × 4) Tools/compare_blank_text.py:17— Tools/compare_blank_text.py:17-22 | Tools/compare_character_classification.py:52-57 | Tools/compare_child_reads.py:22-27 | Tools/compare_cursor_moves.py:21-26 — before extracting anything, compare `Tools/compare_blank_text.py` and `Tools/compare_character_classification.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
HtmlTreeBuilderState.process (cyclomatic 706) Sources/HtmlTreeBuilderState.swift:78— HtmlTreeBuilderState.process has cyclomatic complexity 706 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TokeniserState.read (cyclomatic 411) Sources/TokeniserState.swift:185— TokeniserState.read has cyclomatic complexity 411 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
main.swift.runWorkload (cyclomatic 159) Tools/SwiftSoupProfile/main.swift:189— main.swift.runWorkload has cyclomatic complexity 159 (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.
CssSelector.fastSimpleQueryPlan (cyclomatic 135) Sources/CssSelector.swift:730— CssSelector.fastSimpleQueryPlan has cyclomatic complexity 135 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Tokeniser.consumeCharacterReference (cyclomatic 122) Sources/Tokeniser.swift:768— Tokeniser.consumeCharacterReference has cyclomatic complexity 122 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Entities.escape (cyclomatic 119) Sources/Entities.swift:838— Entities.escape has cyclomatic complexity 119 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Entities.escape (cyclomatic 118) Sources/Entities.swift:586— Entities.escape has cyclomatic complexity 118 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Entities.escape (cyclomatic 98) Sources/Entities.swift:1087— Entities.escape has cyclomatic complexity 98 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HtmlTreeBuilder.insert (cyclomatic 65) Sources/HtmlTreeBuilder.swift:448— HtmlTreeBuilder.insert has cyclomatic complexity 65 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StringUtil.appendNormalisedWhitespaceBytes (cyclomatic 64) Sources/StringUtil.swift:1004— StringUtil.appendNormalisedWhitespaceBytes has cyclomatic complexity 64 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FastQueryPlan.apply (cyclomatic 63) Sources/CssSelector.swift:306— FastQueryPlan.apply has cyclomatic complexity 63 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StringUtil.appendNormalisedWhitespace (cyclomatic 63) Sources/StringUtil.swift:797— StringUtil.appendNormalisedWhitespace has cyclomatic complexity 63 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Tokeniser.consumeBasicNamedEntityIfPresent (cyclomatic 51) Sources/Tokeniser.swift:76— Tokeniser.consumeBasicNamedEntityIfPresent has cyclomatic complexity 51 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
CharacterReader.consumeToAnyOfFourSlice (cyclomatic 49) Sources/CharacterReader.swift:1328— CharacterReader.consumeToAnyOfFourSlice has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Evaluator.supportsIndexedCandidateFiltering (cyclomatic 44) Sources/Evaluator.swift:73— Evaluator.supportsIndexedCandidateFiltering has cyclomatic complexity 44 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
StringUtil.appendNormalisedWhitespace (cyclomatic 44) Sources/StringUtil.swift:618— StringUtil.appendNormalisedWhitespace has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TokeniserState.readTagNameFromTagOpen (cyclomatic 42) Sources/TokeniserState.swift:2334— TokeniserState.readTagNameFromTagOpen has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CharacterReader.consumeToAnyOfThreeSlice (cyclomatic 37) Sources/CharacterReader.swift:1232— CharacterReader.consumeToAnyOfThreeSlice 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.
CharacterReader.consumeDataSlice (cyclomatic 36) Sources/CharacterReader.swift:1442— CharacterReader.consumeDataSlice has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
compare_character_classification.main (cyclomatic 33) Tools/compare_character_classification.py:51— compare_character_classification.main 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.
compare_blank_text.main (cyclomatic 32) Tools/compare_blank_text.py:16— compare_blank_text.main 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.
compare_child_reads.main (cyclomatic 32) Tools/compare_child_reads.py:21— compare_child_reads.main 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.
compare_cursor_moves.main (cyclomatic 32) Tools/compare_cursor_moves.py:20— compare_cursor_moves.main 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.
compare_exclusion.main (cyclomatic 31) Tools/compare_exclusion.py:17— compare_exclusion.main 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.
compare_independent_hotspots.main (cyclomatic 31) Tools/compare_independent_hotspots.py:17— compare_independent_hotspots.main 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.
compare_ordered_insertion.main (cyclomatic 31) Tools/compare_ordered_insertion.py:17— compare_ordered_insertion.main 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.
compare_tokenqueue_search.main (cyclomatic 31) Tools/compare_tokenqueue_search.py:14— compare_tokenqueue_search.main 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.
Element.rebuildQueryIndexesCombined (cyclomatic 29) Sources/Element.swift:3144— Element.rebuildQueryIndexesCombined 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.
QueryParser.findElements (cyclomatic 29) Sources/QueryParser.swift:168— QueryParser.findElements has cyclomatic complexity 29 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CharacterReader.consumeToAnyOfTwoSlice (cyclomatic 27) Sources/CharacterReader.swift:1076— CharacterReader.consumeToAnyOfTwoSlice has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Element.hasClass (cyclomatic 27) Sources/Element.swift:2440— Element.hasClass has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
compare_sibling_endpoints.main (cyclomatic 27) Tools/compare_sibling_endpoints.py:8— compare_sibling_endpoints.main has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TextNode.outerHtmlHead (cyclomatic 25) Sources/TextNode.swift:275— TextNode.outerHtmlHead 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.
Collector.collect (cyclomatic 24) Sources/Collector.swift:26— Collector.collect 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.
CharacterReader.consumeLetterThenDigitSequenceSlice (cyclomatic 23) Sources/CharacterReader.swift:471— CharacterReader.consumeLetterThenDigitSequenceSlice 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.
CharacterReader.matches (cyclomatic 23) Sources/CharacterReader.swift:637— CharacterReader.matches 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.
Collector.seedCandidates (cyclomatic 23) Sources/Collector.swift:194— Collector.seedCandidates 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.
TokeniserState.consumeAttributesFast (cyclomatic 23) Sources/TokeniserState.swift:2540— TokeniserState.consumeAttributesFast 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.
benchmark_independent_hotspots.swift.run (cyclomatic 23) Tools/benchmark_independent_hotspots.swift:80— benchmark_independent_hotspots.swift.run has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Entities.escapeFastAscii (cyclomatic 22) Sources/Entities.swift:515— Entities.escapeFastAscii 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.
main.swift.parseOptions (cyclomatic 22) Tools/SwiftSoupProfile/main.swift:74— main.swift.parseOptions has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CharacterReader.containsAsciiTransformed (cyclomatic 21) Sources/CharacterReader.swift:932— CharacterReader.containsAsciiTransformed 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.
benchmark_blank_text.swift.workload (cyclomatic 21) Tools/benchmark_blank_text.swift:44— benchmark_blank_text.swift.workload 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.
compare_whitespace_runs.main (cyclomatic 21) Tools/compare_whitespace_runs.py:21— compare_whitespace_runs.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.
Document.sourcePatches (cyclomatic 20) Sources/Document.swift:631— Document.sourcePatches has cyclomatic complexity 20 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Tokeniser.read (cyclomatic 20) Sources/Tokeniser.swift:279— Tokeniser.read 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.
CharacterReader.consumeHexSequenceSlice (cyclomatic 19) Sources/CharacterReader.swift:544— CharacterReader.consumeHexSequenceSlice has cyclomatic complexity 19 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
CharacterReader.containsAsciiTransformed (cyclomatic 19) Sources/CharacterReader.swift:894— CharacterReader.containsAsciiTransformed 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.
HtmlTreeBuilder.process (cyclomatic 19) Sources/HtmlTreeBuilder.swift:170— HtmlTreeBuilder.process 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.
HtmlTreeBuilder.resetInsertionMode (cyclomatic 19) Sources/HtmlTreeBuilder.swift:1041— HtmlTreeBuilder.resetInsertionMode 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.
TokenQueue.consumeCssSelectorList (cyclomatic 19) Sources/TokenQueue.swift:583— TokenQueue.consumeCssSelectorList 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.
benchmark_child_reads.swift.operation (cyclomatic 19) Tools/benchmark_child_reads.swift:66— benchmark_child_reads.swift.operation 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.
benchmark_exclusion.swift.main (cyclomatic 19) Tools/benchmark_exclusion.swift:44— benchmark_exclusion.swift.main has cyclomatic complexity 19 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
compare_entity_benchmarks.main (cyclomatic 19) Tools/compare_entity_benchmarks.py:24— compare_entity_benchmarks.main 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.
Attributes.ensureMaterialized (cyclomatic 18) Sources/Attributes.swift:229— Attributes.ensureMaterialized 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.
CharacterReader.nextIndexOf (cyclomatic 18) Sources/CharacterReader.swift:1014— CharacterReader.nextIndexOf 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.
CssSelector.splitDescendantTokens (cyclomatic 18) Sources/CssSelector.swift:672— CssSelector.splitDescendantTokens 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.
Element.getElementsByAttributeValue (cyclomatic 18) Sources/Element.swift:1594— Element.getElementsByAttributeValue has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CharacterReader.consumeToAnyOfOneSlice (cyclomatic 17) Sources/CharacterReader.swift:1165— CharacterReader.consumeToAnyOfOneSlice 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.
CssSelector.select (cyclomatic 17) Sources/CssSelector.swift:163— CssSelector.select 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.
benchmark_ordered_insertion.swift.main (cyclomatic 17) Tools/benchmark_ordered_insertion.swift:33— benchmark_ordered_insertion.swift.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.
Attributes.getIgnoreCaseSlice (cyclomatic 16) Sources/Attributes.swift:490— Attributes.getIgnoreCaseSlice 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.
Attributes.compactAndMutate (cyclomatic 16) Sources/Attributes.swift:696— Attributes.compactAndMutate 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.
Attributes.hasKeyIgnoreCase (cyclomatic 16) Sources/Attributes.swift:861— Attributes.hasKeyIgnoreCase 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.
Attributes.appendPendingHtml (cyclomatic 16) Sources/Attributes.swift:1205— Attributes.appendPendingHtml has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
DocumentType.outerHtmlHead (cyclomatic 16) Sources/DocumentType.swift:97— DocumentType.outerHtmlHead 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.
Element.cssEscapeIdentifier (cyclomatic 16) Sources/Element.swift:1160— Element.cssEscapeIdentifier has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
StringUtil.appendNormalisedWhitespace (cyclomatic 16) Sources/StringUtil.swift:495— StringUtil.appendNormalisedWhitespace 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.
Tag.appendAttributeName (cyclomatic 16) Sources/Token.swift:958— Tag.appendAttributeName 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.
TokenQueue.chompBalanced (cyclomatic 16) Sources/TokenQueue.swift:325— TokenQueue.chompBalanced 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.
TokeniserState.handleDataEndTag (cyclomatic 16) Sources/TokeniserState.swift:2194— TokeniserState.handleDataEndTag 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.
Whitelist.stripCSSComments (cyclomatic 16) Sources/Whitelist.swift:832— Whitelist.stripCSSComments 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.
benchmark_character_classification.swift.workload (cyclomatic 16) Tools/benchmark_character_classification.swift:35— benchmark_character_classification.swift.workload 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.
HtmlTreeBuilderState.process (cognitive 1857) Sources/HtmlTreeBuilderState.swift:78— HtmlTreeBuilderState.process has cognitive complexity 1857 (threshold 15). Drivers by points: if/else 560 (1596 pts), boolean chains 115, match/switch 25 (80 pts), loops 16 (66 pts) (nesting depth added 1141). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
TokeniserState.read (cognitive 627) Sources/TokeniserState.swift:185— TokeniserState.read has cognitive complexity 627 (threshold 15). Drivers by points: if/else 262 (471 pts), match/switch 50 (127 pts), boolean chains 29 (nesting depth added 286). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
main.swift.runWorkload (cognitive 326) Tools/SwiftSoupProfile/main.swift:189— main.swift.runWorkload has cognitive complexity 326 (threshold 15). Drivers by points: loops 80 (208 pts), if/else 30 (86 pts), error handling 7 (28 pts), boolean chains 3, match/switch 1 (nesting depth added 205). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
CssSelector.fastSimpleQueryPlan (cognitive 277) Sources/CssSelector.swift:730— CssSelector.fastSimpleQueryPlan has cognitive complexity 277 (threshold 15). Drivers by points: if/else 74 (167 pts), ternaries 16 (49 pts), boolean chains 36, loops 9 (17 pts), match/switch 3 (8 pts) (nesting depth added 139). 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.
Tokeniser.consumeCharacterReference (cognitive 267) Sources/Tokeniser.swift:768— Tokeniser.consumeCharacterReference has cognitive complexity 267 (threshold 15). Drivers by points: if/else 73 (202 pts), boolean chains 45, loops 5 (13 pts), ternaries 2 (4 pts), match/switch 1 (3 pts) (nesting depth added 141). 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.
Entities.escape (cognitive 208) Sources/Entities.swift:838— Entities.escape has cognitive complexity 208 (threshold 15). Drivers by points: if/else 55 (127 pts), boolean chains 61, loops 4 (10 pts), ternaries 2 (7 pts), match/switch 1 (3 pts) (nesting depth added 85). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Entities.escape (cognitive 207) Sources/Entities.swift:586— Entities.escape has cognitive complexity 207 (threshold 15). Drivers by points: if/else 55 (127 pts), boolean chains 60, loops 4 (10 pts), ternaries 2 (7 pts), match/switch 1 (3 pts) (nesting depth added 85). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Entities.escape (cognitive 177) Sources/Entities.swift:1087— Entities.escape has cognitive complexity 177 (threshold 15). Drivers by points: if/else 49 (112 pts), boolean chains 47, loops 3 (8 pts), ternaries 2 (7 pts), match/switch 1 (3 pts) (nesting depth added 75). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FastQueryPlan.apply (cognitive 145) Sources/CssSelector.swift:306— FastQueryPlan.apply has cognitive complexity 145 (threshold 15). Drivers by points: if/else 27 (82 pts), loops 19 (60 pts), boolean chains 2, match/switch 1 (nesting depth added 96). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
StringUtil.appendNormalisedWhitespace (cognitive 131) Sources/StringUtil.swift:797— StringUtil.appendNormalisedWhitespace has cognitive complexity 131 (threshold 15). Drivers by points: if/else 37 (98 pts), boolean chains 22, loops 5 (11 pts) (nesting depth added 67). 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.
StringUtil.appendNormalisedWhitespaceBytes (cognitive 112) Sources/StringUtil.swift:1004— StringUtil.appendNormalisedWhitespaceBytes has cognitive complexity 112 (threshold 15). Drivers by points: if/else 33 (72 pts), boolean chains 24, loops 6 (10 pts), ternaries 2 (6 pts) (nesting depth added 47). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HtmlTreeBuilder.insert (cognitive 99) Sources/HtmlTreeBuilder.swift:448— HtmlTreeBuilder.insert has cognitive complexity 99 (threshold 15). Drivers by points: if/else 34 (61 pts), boolean chains 38 (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.
StringUtil.appendNormalisedWhitespace (cognitive 85) Sources/StringUtil.swift:618— StringUtil.appendNormalisedWhitespace has cognitive complexity 85 (threshold 15). Drivers by points: if/else 23 (59 pts), boolean chains 17, loops 4 (9 pts) (nesting depth added 41). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.consumeToAnyOfFourSlice (cognitive 82) Sources/CharacterReader.swift:1328— CharacterReader.consumeToAnyOfFourSlice has cognitive complexity 82 (threshold 15). Drivers by points: if/else 21 (49 pts), boolean chains 20, loops 4 (7 pts), ternaries 3 (6 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokeniserState.readTagNameFromTagOpen (cognitive 77) Sources/TokeniserState.swift:2334— TokeniserState.readTagNameFromTagOpen has cognitive complexity 77 (threshold 15). Drivers by points: if/else 24 (54 pts), boolean chains 11, loops 3 (8 pts), match/switch 2 (4 pts) (nesting depth added 37). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
CharacterReader.consumeToAnyOfThreeSlice (cognitive 64) Sources/CharacterReader.swift:1232— CharacterReader.consumeToAnyOfThreeSlice has cognitive complexity 64 (threshold 15). Drivers by points: if/else 18 (41 pts), boolean chains 12, loops 4 (7 pts), ternaries 2 (4 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.consumeDataSlice (cognitive 58) Sources/CharacterReader.swift:1442— CharacterReader.consumeDataSlice has cognitive complexity 58 (threshold 15). Drivers by points: if/else 18 (38 pts), boolean chains 12, loops 5 (8 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_character_classification.main (cognitive 57) Tools/compare_character_classification.py:51— compare_character_classification.main has cognitive complexity 57 (threshold 15). Drivers by points: if/else 8 (21 pts), loops 12 (21 pts), ternaries 7 (10 pts), boolean chains 5 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.consumeToAnyOfTwoSlice (cognitive 55) Sources/CharacterReader.swift:1076— CharacterReader.consumeToAnyOfTwoSlice has cognitive complexity 55 (threshold 15). Drivers by points: if/else 15 (37 pts), loops 4 (10 pts), boolean chains 6, ternaries 1 (2 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tokeniser.consumeBasicNamedEntityIfPresent (cognitive 53) Sources/Tokeniser.swift:76— Tokeniser.consumeBasicNamedEntityIfPresent has cognitive complexity 53 (threshold 15). Drivers by points: boolean chains 32, if/else 11 (20 pts), match/switch 1 (nesting depth added 9). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
Tokeniser.read (cognitive 53) Sources/Tokeniser.swift:279— Tokeniser.read has cognitive complexity 53 (threshold 15). Drivers by points: if/else 16 (34 pts), loops 5 (17 pts), boolean chains 2 (nesting depth added 30). 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.
compare_blank_text.main (cognitive 49) Tools/compare_blank_text.py:16— compare_blank_text.main has cognitive complexity 49 (threshold 15). Drivers by points: loops 11 (18 pts), if/else 8 (16 pts), ternaries 7 (10 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_child_reads.main (cognitive 49) Tools/compare_child_reads.py:21— compare_child_reads.main has cognitive complexity 49 (threshold 15). Drivers by points: loops 11 (18 pts), if/else 8 (16 pts), ternaries 7 (10 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_cursor_moves.main (cognitive 49) Tools/compare_cursor_moves.py:20— compare_cursor_moves.main has cognitive complexity 49 (threshold 15). Drivers by points: loops 11 (18 pts), if/else 8 (16 pts), ternaries 7 (10 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_exclusion.main (cognitive 48) Tools/compare_exclusion.py:17— compare_exclusion.main has cognitive complexity 48 (threshold 15). Drivers by points: loops 11 (18 pts), if/else 8 (16 pts), ternaries 6 (9 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_independent_hotspots.main (cognitive 48) Tools/compare_independent_hotspots.py:17— compare_independent_hotspots.main has cognitive complexity 48 (threshold 15). Drivers by points: loops 11 (18 pts), if/else 8 (16 pts), ternaries 6 (9 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_ordered_insertion.main (cognitive 48) Tools/compare_ordered_insertion.py:17— compare_ordered_insertion.main has cognitive complexity 48 (threshold 15). Drivers by points: loops 11 (18 pts), if/else 8 (16 pts), ternaries 6 (9 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_tokenqueue_search.main (cognitive 48) Tools/compare_tokenqueue_search.py:14— compare_tokenqueue_search.main has cognitive complexity 48 (threshold 15). Drivers by points: loops 11 (18 pts), if/else 8 (16 pts), ternaries 6 (9 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TextNode.outerHtmlHead (cognitive 47) Sources/TextNode.swift:275— TextNode.outerHtmlHead has cognitive complexity 47 (threshold 15). Drivers by points: if/else 14 (33 pts), boolean chains 10, loops 1 (4 pts) (nesting depth added 22). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
TokeniserState.consumeAttributesFast (cognitive 47) Sources/TokeniserState.swift:2540— TokeniserState.consumeAttributesFast has cognitive complexity 47 (threshold 15). Drivers by points: if/else 15 (39 pts), boolean chains 5, match/switch 1 (2 pts), loops 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.containsAsciiTransformed (cognitive 46) Sources/CharacterReader.swift:932— CharacterReader.containsAsciiTransformed has cognitive complexity 46 (threshold 15). Drivers by points: if/else 10 (19 pts), ternaries 6 (19 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Collector.collect (cognitive 45) Sources/Collector.swift:26— Collector.collect has cognitive complexity 45 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 6 (13 pts), boolean chains 6 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Entities.escapeFastAscii (cognitive 43) Sources/Entities.swift:515— Entities.escapeFastAscii has cognitive complexity 43 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 3 (8 pts), boolean chains 5, ternaries 3 (5 pts), match/switch 1 (3 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Evaluator.supportsIndexedCandidateFiltering (cognitive 43) Sources/Evaluator.swift:73— Evaluator.supportsIndexedCandidateFiltering has cognitive complexity 43 (threshold 15). Drivers by points: boolean chains 41, if/else 2. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
compare_sibling_endpoints.main (cognitive 43) Tools/compare_sibling_endpoints.py:8— compare_sibling_endpoints.main has cognitive complexity 43 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 10 (17 pts), boolean chains 5, ternaries 2 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.containsAsciiTransformed (cognitive 41) Sources/CharacterReader.swift:894— CharacterReader.containsAsciiTransformed has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (19 pts), ternaries 4 (14 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Element.hasClass (cognitive 39) Sources/Element.swift:2440— Element.hasClass has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (22 pts), boolean chains 9, loops 3 (4 pts), ternaries 2 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Element.rebuildQueryIndexesCombined (cognitive 39) Sources/Element.swift:3144— Element.rebuildQueryIndexesCombined has cognitive complexity 39 (threshold 15). Drivers by points: if/else 20 (29 pts), boolean chains 7, ternaries 1 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.consumeLetterThenDigitSequenceSlice (cognitive 38) Sources/CharacterReader.swift:471— CharacterReader.consumeLetterThenDigitSequenceSlice has cognitive complexity 38 (threshold 15). Drivers by points: if/else 10 (22 pts), boolean chains 8, loops 4, match/switch 2 (4 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.matches (cognitive 38) Sources/CharacterReader.swift:637— CharacterReader.matches has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (23 pts), ternaries 2 (6 pts), loops 3 (4 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_whitespace_runs.main (cognitive 36) Tools/compare_whitespace_runs.py:21— compare_whitespace_runs.main has cognitive complexity 36 (threshold 15). Drivers by points: loops 8 (15 pts), if/else 5 (13 pts), ternaries 4 (5 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Collector.seedCandidates (cognitive 35) Sources/Collector.swift:194— Collector.seedCandidates has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (24 pts), loops 7, boolean chains 4 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
benchmark_blank_text.swift.workload (cognitive 33) Tools/benchmark_blank_text.swift:44— benchmark_blank_text.swift.workload has cognitive complexity 33 (threshold 15). Drivers by points: ternaries 12 (25 pts), if/else 3 (5 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Attributes.ensureMaterialized (cognitive 32) Sources/Attributes.swift:229— Attributes.ensureMaterialized has cognitive complexity 32 (threshold 15). Drivers by points: if/else 17 (26 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.nextIndexOf (cognitive 32) Sources/CharacterReader.swift:1014— CharacterReader.nextIndexOf has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (24 pts), loops 4 (7 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tag.appendAttributeName (cognitive 32) Sources/Token.swift:958— Tag.appendAttributeName has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 2 (5 pts), boolean chains 3, ternaries 1 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenQueue.consumeCssSelectorList (cognitive 31) Sources/TokenQueue.swift:583— TokenQueue.consumeCssSelectorList has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 7, ternaries 2 (6 pts), loops 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CssSelector.splitDescendantTokens (cognitive 30) Sources/CssSelector.swift:672— CssSelector.splitDescendantTokens has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare_pattern_reuse.main (cognitive 30) Tools/compare_pattern_reuse.py:20— compare_pattern_reuse.main has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 4 (12 pts), loops 5 (11 pts), if/else 3 (7 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.
Attributes.ensureCanonicalPendingNames (cognitive 29) Sources/Attributes.swift:913— Attributes.ensureCanonicalPendingNames has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (20 pts), loops 3 (7 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.consumeToAnyOfOneSlice (cognitive 29) Sources/CharacterReader.swift:1165— CharacterReader.consumeToAnyOfOneSlice has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 4 (7 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.
QueryParser.findElements (cognitive 29) Sources/QueryParser.swift:168— QueryParser.findElements has cognitive complexity 29 (threshold 15). Drivers by points: if/else 28, 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.
benchmark_child_reads.swift.operation (cognitive 29) Tools/benchmark_child_reads.swift:66— benchmark_child_reads.swift.operation has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 4 (7 pts), ternaries 2 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StringUtil.appendNormalisedWhitespace (cognitive 28) Sources/StringUtil.swift:495— StringUtil.appendNormalisedWhitespace has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 6, 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.
Has.matches (cognitive 28) Sources/StructuralEvaluator.swift:41— Has.matches has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 4 (9 pts), error handling 1 (2 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokeniserState.consumeQuotedAttributeValueFast (cognitive 28) Sources/TokeniserState.swift:2730— TokeniserState.consumeQuotedAttributeValueFast has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (19 pts), ternaries 2 (5 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
benchmark_independent_hotspots.swift.run (cognitive 28) Tools/benchmark_independent_hotspots.swift:80— benchmark_independent_hotspots.swift.run has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 5 (8 pts), boolean chains 3, ternaries 1 (2 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HtmlTreeBuilder.process (cognitive 27) Sources/HtmlTreeBuilder.swift:170— HtmlTreeBuilder.process has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 8, ternaries 1 (3 pts), match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ParsingStrings.init (cognitive 27) Sources/ParsingStrings.swift:78— ParsingStrings.init has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (20 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.
benchmark_exclusion.swift.verification (cognitive 27) Tools/benchmark_exclusion.swift:17— benchmark_exclusion.swift.verification has cognitive complexity 27 (threshold 15). Drivers by points: if/else 3 (14 pts), loops 3 (6 pts), ternaries 1 (5 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Attributes.compactAndMutate (cognitive 26) Sources/Attributes.swift:696— Attributes.compactAndMutate has cognitive complexity 26 (threshold 15). Drivers by points: if/else 15 (25 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.
CssSelector.fastQueryPlan (cognitive 26) Sources/CssSelector.swift:605— CssSelector.fastQueryPlan has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (18 pts), match/switch 2 (5 pts), loops 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Document.ensureMetaCharsetElement (cognitive 26) Sources/Document.swift:558— Document.ensureMetaCharsetElement has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (26 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
compare_entity_benchmarks.main (cognitive 26) Tools/compare_entity_benchmarks.py:24— compare_entity_benchmarks.main has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 4 (7 pts), ternaries 5 (7 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.
Attributes.removeAll (cognitive 25) Sources/Attributes.swift:641— Attributes.removeAll has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (20 pts), loops 3 (5 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CssSelector.select (cognitive 25) Sources/CssSelector.swift:163— CssSelector.select has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 6, loops 2 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
QueryParser.cssNthChild (cognitive 25) Sources/QueryParser.swift:269— QueryParser.cssNthChild has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (20 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Whitelist.stripCSSComments (cognitive 25) Sources/Whitelist.swift:832— Whitelist.stripCSSComments has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 5, 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.
Attributes.getIgnoreCaseSlice (cognitive 24) Sources/Attributes.swift:490— Attributes.getIgnoreCaseSlice has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (19 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.consumeHexSequenceSlice (cognitive 24) Sources/CharacterReader.swift:544— CharacterReader.consumeHexSequenceSlice has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 10, if/else 4 (10 pts), loops 2, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Element.collectTextFast (cognitive 24) Sources/Element.swift:1884— Element.collectTextFast has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HtmlTreeBuilder.inSpecificScope (cognitive 24) Sources/HtmlTreeBuilder.swift:1091— HtmlTreeBuilder.inSpecificScope has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (20 pts), boolean chains 3, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tag.newAttribute (cognitive 24) Sources/Token.swift:410— Tag.newAttribute has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 4, ternaries 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
String.trimAsciiWhitespaceFast (cognitive 24) Sources/String.swift:383— String.trimAsciiWhitespaceFast has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.swift.parseOptions (cognitive 24) Tools/SwiftSoupProfile/main.swift:74— main.swift.parseOptions has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 8, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
Document.sourcePatches (cognitive 23) Sources/Document.swift:631— Document.sourcePatches has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 10, if/else 8 (9 pts), loops 2 (4 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Element.collectTextFastTrimmed (cognitive 23) Sources/Element.swift:1922— Element.collectTextFastTrimmed has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 6, 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.
TokeniserState.consumeUnquotedAttributeValueFast (cognitive 23) Sources/TokeniserState.swift:2778— TokeniserState.consumeUnquotedAttributeValueFast has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (20 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Attributes.getIgnoreCase (cognitive 22) Sources/Attributes.swift:453— Attributes.getIgnoreCase has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (17 pts), ternaries 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.
Attributes.hasKeyIgnoreCase (cognitive 22) Sources/Attributes.swift:861— Attributes.hasKeyIgnoreCase has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenQueue.chompBalanced (cognitive 22) Sources/TokenQueue.swift:325— TokenQueue.chompBalanced has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 3, loops 1, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
benchmark_character_classification.swift.workload (cognitive 22) Tools/benchmark_character_classification.swift:35— benchmark_character_classification.swift.workload has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 6 (14 pts), if/else 4 (5 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
benchmark_ordered_insertion.swift.main (cognitive 22) Tools/benchmark_ordered_insertion.swift:33— benchmark_ordered_insertion.swift.main has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 6, ternaries 2 (4 pts), loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CharacterReader.containsAsciiCaseInsensitive (cognitive 21) Sources/CharacterReader.swift:857— CharacterReader.containsAsciiCaseInsensitive has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (11 pts), ternaries 2 (5 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AttributeStarting.matches (cognitive 21) Sources/Evaluator.swift:264— AttributeStarting.matches has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 2 (5 pts), ternaries 1 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HtmlTreeBuilder.generateImpliedEndTags (cognitive 21) Sources/HtmlTreeBuilder.swift:1333— HtmlTreeBuilder.generateImpliedEndTags has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (19 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenQueue.consumeCssIdentifier (cognitive 21) Sources/TokenQueue.swift:455— TokenQueue.consumeCssIdentifier has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 8, if/else 5 (8 pts), loops 2 (5 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokeniserState.handleDataEndTag (cognitive 21) Sources/TokeniserState.swift:2194— TokeniserState.handleDataEndTag has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (12 pts), match/switch 2 (6 pts), boolean chains 3 (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.
CharacterReader.consumeLetterSequenceSlice (cognitive 20) Sources/CharacterReader.swift:433— CharacterReader.consumeLetterSequenceSlice has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (10 pts), boolean chains 6, loops 2, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CssSelector.fastSelectAnd (cognitive 20) Sources/CssSelector.swift:1159— CssSelector.fastSelectAnd has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Document.outerHtmlUTF8ReusingSourceOutsideBody (cognitive 20) Sources/Document.swift:398— Document.outerHtmlUTF8ReusingSourceOutsideBody has cognitive complexity 20 (threshold 15). Drivers by points: loops 4 (9 pts), if/else 3 (6 pts), match/switch 2 (3 pts), boolean chains 1, ternaries 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
DocumentType.outerHtmlHead (cognitive 20) Sources/DocumentType.swift:97— DocumentType.outerHtmlHead has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 6 (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.
HtmlTreeBuilder.insertEmpty (cognitive 20) Sources/HtmlTreeBuilder.swift:366— HtmlTreeBuilder.insertEmpty has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 6 (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.
HtmlTreeBuilder.resetInsertionMode (cognitive 20) Sources/HtmlTreeBuilder.swift:1041— HtmlTreeBuilder.resetInsertionMode has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 4, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
HtmlTreeBuilder.inSpecificScope (cognitive 20) Sources/HtmlTreeBuilder.swift:1147— HtmlTreeBuilder.inSpecificScope has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (17 pts), boolean chains 2, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tag.normalNameSlice (cognitive 20) Sources/Token.swift:516— Tag.normalNameSlice has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 4 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tag.normalNameEquals (cognitive 20) Sources/Token.swift:557— Tag.normalNameEquals has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenQueue.trimCssQuery (cognitive 20) Sources/TokenQueue.swift:489— TokenQueue.trimCssQuery has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenQueue.cssEscape (cognitive 20) Sources/TokenQueue.swift:631— TokenQueue.cssEscape has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 6, 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.
Tokeniser.emit (cognitive 20) Sources/Tokeniser.swift:372— Tokeniser.emit has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (20 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.
Tokeniser.handleDataStateDelimiterTracked (cognitive 20) Sources/Tokeniser.swift:446— Tokeniser.handleDataStateDelimiterTracked has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (17 pts), match/switch 2 (3 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (Tokeniser.handleDataStateDelimiter) 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.
Tokeniser.handleDataStateDelimiter (cognitive 20) Sources/Tokeniser.swift:537— Tokeniser.handleDataStateDelimiter has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (17 pts), match/switch 2 (3 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (Tokeniser.handleDataStateDelimiterTracked) 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.
Collector.collectHas (cognitive 19) Sources/Collector.swift:116— Collector.collectHas has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Element.firstElementSibling (cognitive 19) Sources/Element.swift:1274— Element.firstElementSibling has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), boolean chains 3, loops 1 (3 pts), ternaries 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (Element.lastElementSibling) 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.
Element.elementSiblingIndex (cognitive 19) Sources/Element.swift:1300— Element.elementSiblingIndex has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 1 (3 pts), boolean chains 2, ternaries 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
Element.lastElementSibling (cognitive 19) Sources/Element.swift:1328— Element.lastElementSibling has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), boolean chains 3, loops 1 (3 pts), ternaries 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (Element.firstElementSibling) 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.
Element.collectTextFastRaw (cognitive 19) Sources/Element.swift:1965— Element.collectTextFastRaw has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 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.
IsEmpty.matches (cognitive 19) Sources/Evaluator.swift:854— IsEmpty.matches has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 2 (6 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HtmlTreeBuilder.parseFragment (cognitive 19) Sources/HtmlTreeBuilder.swift:108— HtmlTreeBuilder.parseFragment has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (13 pts), match/switch 1 (3 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Node.copy (cognitive 19) Sources/Node.swift:1219— Node.copy has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Whitelist.removeAttributes (cognitive 19) Sources/Whitelist.swift:373— Whitelist.removeAttributes has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 4 (9 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.
benchmark_child_reads.swift.verification (cognitive 19) Tools/benchmark_child_reads.swift:34— benchmark_child_reads.swift.verification has cognitive complexity 19 (threshold 15). Drivers by points: loops 5 (15 pts), if/else 1 (4 pts) (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Element.getElementsByAttributeValue (cognitive 18) Sources/Element.swift:1594— Element.getElementsByAttributeValue has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 8, if/else 5 (6 pts), ternaries 4 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HtmlTreeBuilder.insert (cognitive 18) Sources/HtmlTreeBuilder.swift:295— HtmlTreeBuilder.insert has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 4 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
Tag.normalName (cognitive 18) Sources/Token.swift:480— Tag.normalName has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (6 pts), boolean chains 4 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tag.ensureAttributeName (cognitive 18) Sources/Token.swift:1118— Tag.ensureAttributeName has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 1 (5 pts), loops 1 (4 pts), boolean chains 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
Whitelist.removeCSSProperties (cognitive 18) Sources/Whitelist.swift:280— Whitelist.removeCSSProperties has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
benchmark_independent_hotspots.swift.verification (cognitive 18) Tools/benchmark_independent_hotspots.swift:30— benchmark_independent_hotspots.swift.verification has cognitive complexity 18 (threshold 15). Drivers by points: loops 7 (14 pts), ternaries 2 (4 pts) (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Element.cssEscapeIdentifier (cognitive 17) Sources/Element.swift:1160— Element.cssEscapeIdentifier has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 11, if/else 4 (5 pts), loops 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
HtmlTreeBuilder.inSelectScope (cognitive 17) Sources/HtmlTreeBuilder.swift:1249— HtmlTreeBuilder.inSelectScope has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OrderedSet.moveObject (cognitive 17) Sources/OrderedSet.swift:211— OrderedSet.moveObject has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 2 (6 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.
StringBuilder.write (cognitive 17) Sources/StringBuilder.swift:396— StringBuilder.write has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TokenQueue.consumeCssSubQuery (cognitive 17) Sources/TokenQueue.swift:537— TokenQueue.consumeCssSubQuery has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 2 (6 pts), if/else 4 (5 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tokeniser.unescapeEntities (cognitive 17) Sources/Tokeniser.swift:1219— Tokeniser.unescapeEntities has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
Whitelist.parseStyleDeclaration (cognitive 17) Sources/Whitelist.swift:904— Whitelist.parseStyleDeclaration has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), match/switch 1 (3 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.
Array.regionMatches (cognitive 17) Sources/String.swift:407— Array.regionMatches has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 5, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
benchmark_exclusion.swift.main (cognitive 17) Tools/benchmark_exclusion.swift:44— benchmark_exclusion.swift.main has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5, boolean chains 4, loops 3 (4 pts), match/switch 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Document.patchedOuterHtmlUTF8 (cognitive 16) Sources/Document.swift:729— Document.patchedOuterHtmlUTF8 has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 5, loops 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
QueryParser.combinator (cognitive 16) Sources/QueryParser.swift:117— QueryParser.combinator has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (15 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.
StringBuilder.write (cognitive 16) Sources/StringBuilder.swift:435— StringBuilder.write has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 3 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D22 · Internal API Consistency· Inconsistent constructor naming and arity for string-based initialization. There are two constructors taking key/value pairs (one for UTF8 bytes, one for Strings), but a third constructor `init(String)` exists with no clear semantic mapping (is it a key? a serialized attribute?). This breaks the symmetry of the API. · ×1
Inconsistent constructor naming and arity for string-based initialization. There are two constructors taking key/value pairs (one for UTF8 bytes, one for Strings), but a third constructor `init(String)` exists with no clear semantic mapping (is it a key? a serialized attribute?). This breaks the symmetry of the API. — Remove `init(String)` or rename it to `init(serialized: String)` if it parses a full attribute string. Ensure key/value constructors are clearly distinguished or unified via a single `init(key: StringOrBytes, value: StringOrBytes)` if possible, or at least document the single-arg init clearly. (signatures: Attribute.init(key: [UInt8], value: [UInt8]) | Attribute.init(key: String, value: String) | Attribute.init(String))
D22 · Internal API Consistency· Inconsistent naming convention for UTF-8 vs String accessors. The `Attribute` type uses `Key`/`Value` for String and `KeyUTF8`/`ValueUTF8` for bytes. However, `Element` uses `tagName()` for String and `tagNameUTF8()` for bytes, but `nodeName()` vs `nodeNameUTF8()`. While consistent within themselves, the mix of `Key`/`Value` (semantic) vs `Name` (structural) across types is confusing. More critically, `Attribute` lacks a `toString()` equivalent for the whole attribute in a unified way compared to `Element`. · ×1
Inconsistent naming convention for UTF-8 vs String accessors. The `Attribute` type uses `Key`/`Value` for String and `KeyUTF8`/`ValueUTF8` for bytes. However, `Element` uses `tagName()` for String and `tagNameUTF8()` for bytes, but `nodeName()` vs `nodeNameUTF8()`. While consistent within themselves, the mix of `Key`/`Value` (semantic) vs `Name` (structural) across types is confusing. More critically, `Attribute` lacks a `toString()` equivalent for the whole attribute in a unified way compared to `Element`. — Standardize on `name`/`nameUTF8` or `key`/`keyUTF8` across all attribute-related types. `Attribute` should probably use `name` to align with `Element.tagName`/`nodeName` concepts if it represents an HTML attribute name. (signatures: Attribute.getKey(): String | Attribute.getKeyUTF8(): [UInt8] | Attribute.getValue(): String | Attribute.getValueUTF8(): [UInt8])
D22 · Internal API Consistency· Redundant and confusingly named methods for tag names. `tagName()` and `tagNameNormal()` exist, as do their UTF8 counterparts. It is unclear what 'Normal' implies (lowercased? normalized whitespace?) without documentation. This creates 4 methods for essentially the same data point. · ×1
Redundant and confusingly named methods for tag names. `tagName()` and `tagNameNormal()` exist, as do their UTF8 counterparts. It is unclear what 'Normal' implies (lowercased? normalized whitespace?) without documentation. This creates 4 methods for essentially the same data point. — Consolidate into `tagName()` (normalized) and `tagNameRaw()` (as-is). Or remove `Normal` variants if the default is always normalized. (signatures: Element.tagName(): String | Element.tagNameNormal(): String | Element.tagNameUTF8(): [UInt8] | Element.tagNameNormalUTF8(): [UInt8])
D22 · Internal API Consistency· Duplicate intent between `nodeName` and `tagName`. In HTML DOM, these are often synonymous for elements, but the API exposes both with both String and UTF8 variants. This leads to 4 methods doing nearly the same thing. · ×1
Duplicate intent between `nodeName` and `tagName`. In HTML DOM, these are often synonymous for elements, but the API exposes both with both String and UTF8 variants. This leads to 4 methods doing nearly the same thing. — Remove `nodeName` and `nodeNameUTF8` from `Element` if they are identical to `tagName`/`tagNameUTF8`. Keep only one pair. (signatures: Element.nodeName(): String | Element.tagName(): String | Element.nodeNameUTF8(): [UInt8] | Element.tagNameUTF8(): [UInt8])
D22 · Internal API Consistency· Inconsistent return types for UTF-8 text. `textUTF8` returns `[UInt8]` (Array), while `textUTF8Slice` returns `ArraySlice<UInt8>`. This forces users to choose between copying data (Array) or managing lifetimes (Slice) without a clear pattern (e.g., `text()` vs `textSlice()`). · ×1
Inconsistent return types for UTF-8 text. `textUTF8` returns `[UInt8]` (Array), while `textUTF8Slice` returns `ArraySlice<UInt8>`. This forces users to choose between copying data (Array) or managing lifetimes (Slice) without a clear pattern (e.g., `text()` vs `textSlice()`). — Standardize on `text()` (String) and `textUTF8()` ([UInt8]). If slicing is needed for performance, use a consistent suffix like `textSlice()` for all types, or remove the slice variant if not strictly necessary. (signatures: Element.text(trimAndNormaliseWhitespace: Bool): String | Element.textUTF8(trimAndNormaliseWhitespace: Bool): [UInt8] | Element.textUTF8Slice(trimAndNormaliseWhitespace: Bool): ArraySlice<UInt8>)
Inconsistent copy semantics. `copy(with:)` returns `Any` (NSZone style, likely ObjC interop), while `copy(parent:)` returns `Node`. This suggests two different copying mechanisms (shallow vs deep, or ObjC vs native) mixed in the same API surface. — Unify copying. If `copy(parent:)` is the primary native method, remove `copy(with:)` or ensure it returns a strongly typed `Element`/`Node` and not `Any`. (signatures: Element.copy(with: NSZone?): Any | Element.copy(parent: Node?): Node | Element.copy(clone: Node, parent: Node?): Node)
D22 · Internal API Consistency· Proliferation of getter variants. There are 4 variants of `get` based on case sensitivity and encoding. This is repetitive and increases API surface unnecessarily. · ×1
Proliferation of getter variants. There are 4 variants of `get` based on case sensitivity and encoding. This is repetitive and increases API surface unnecessarily. — Provide a single `get(key: StringOrBytes, ignoreCase: Bool = false)` method, or rely on the caller to normalize keys before calling a single `get(key: String)` method. (signatures: Attributes.get(key: String): String | Attributes.get(key: [UInt8]): [UInt8] | Attributes.getIgnoreCase(key: String): String | Attributes.getIgnoreCase(key: [UInt8]): [UInt8])
FunctionTooLong: main.swift.runWorkload Tools/SwiftSoupProfile/main.swift:189— FunctionTooLong — runWorkload runs 469 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 369 over it, 4.69× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
D4 · Code Duplication· Near-duplicate member family (8 members, 26 shared lines) · ×1
Near-duplicate member family (8 members, 26 shared lines) Tools/compare_blank_text.py:17— Tools/compare_blank_text.py:17-94 | Tools/compare_character_classification.py:52-137 | Tools/compare_child_reads.py:22-99 | Tools/compare_cursor_moves.py:21-98 | Tools/compare_exclusion.py:18-94 | Tools/compare_independent_hotspots.py:18-94 | Tools/compare_ordered_insertion.py:18-94 | Tools/compare_tokenqueue_search.py:15-93 — These 8 members are variants of one another: a block of 26 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 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· Near-duplicate member family (4 members, 24 shared lines) · ×1
Near-duplicate member family (4 members, 24 shared lines) Sources/CharacterReader.swift:1165— Sources/CharacterReader.swift:1165-1230 | Sources/CharacterReader.swift:1232-1326 | Sources/CharacterReader.swift:1328-1431 | Sources/CharacterReader.swift:1442-1552 — These 4 members are variants of one another: a block of 24 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, 14 shared lines) · ×1
Near-duplicate member family (4 members, 14 shared lines) Sources/CharacterReader.swift:1076— Sources/CharacterReader.swift:1076-1163 | Sources/CharacterReader.swift:1232-1326 | Sources/CharacterReader.swift:1328-1431 | Sources/CharacterReader.swift:1442-1552 — These 4 members are variants of one another: a block of 14 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· Edited copy of a member (22 corresponding lines) · ×1
Edited copy of a member (22 corresponding lines) Sources/HtmlTreeBuilder.swift:295— Sources/HtmlTreeBuilder.swift:295-339 | Sources/HtmlTreeBuilder.swift:366-404 — 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· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (6 members, 50+ identical tokens) Sources/Entities.swift:586— Sources/Entities.swift:586-835 | Sources/Entities.swift:838-1085 | Sources/Entities.swift:1087-1299 | Sources/StringUtil.swift:618-740 | Sources/StringUtil.swift:797-982 | Sources/StringUtil.swift:1004-1186 — 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 (79 lines × 3) Sources/Entities.swift:737— Sources/Entities.swift:737-815 | Sources/Entities.swift:988-1066 | Sources/Entities.swift:1205-1283 — 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 `Sources/Entities.swift:737` 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–42 lines × 3) Sources/TokeniserState.swift:1151— Sources/TokeniserState.swift:1151-1192 | Sources/TokeniserState.swift:1194-1235 | Sources/TokeniserState.swift:1236-1247 — 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 `Sources/TokeniserState.swift:1236` it begins part-way through the construct above it, so those 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/TokeniserState.swift:1151` calls `isEmpty` and `Sources/TokeniserState.swift:1236` 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 (41 lines × 2) Sources/StringBuilder.swift:483— Sources/StringBuilder.swift:483-523 | Sources/StringBuilder.swift:533-573 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/StringBuilder.swift:483` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (30 lines × 2) Sources/Attribute.swift:233— Sources/Attribute.swift:233-262 | Sources/Attribute.swift:275-304 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Attribute.swift:233` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29 lines × 2) Sources/TokeniserState.swift:939— Sources/TokeniserState.swift:939-967 | Sources/TokeniserState.swift:984-1012 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:939` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (28 lines × 2) Sources/TokeniserState.swift:1826— Sources/TokeniserState.swift:1826-1853 | Sources/TokeniserState.swift:1885-1912 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1826` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/TokeniserState.swift:1825` calls `transition` and `Sources/TokeniserState.swift:1884` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (27 lines × 6) Sources/Entities.swift:627— Sources/Entities.swift:627-653 | Sources/Entities.swift:661-687 | Sources/Entities.swift:878-904 | Sources/Entities.swift:912-938 | Sources/Entities.swift:1128-1154 | Sources/Entities.swift:1162-1188 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Entities.swift:627` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (27 lines × 3) Sources/StringUtil.swift:693— Sources/StringUtil.swift:693-719 | Sources/StringUtil.swift:934-960 | Sources/StringUtil.swift:1128-1154 — 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 `Sources/StringUtil.swift:693` it begins part-way through the construct above it, so those exact lines 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) Sources/TokeniserState.swift:1828— Sources/TokeniserState.swift:1828-1849 | Sources/TokeniserState.swift:1887-1908 | Sources/TokeniserState.swift:1951-1972 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/TokeniserState.swift:1825` calls `transition` and `Sources/TokeniserState.swift:1884` 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 (20 lines × 3) Sources/TokeniserState.swift:1629— Sources/TokeniserState.swift:1629-1648 | Sources/TokeniserState.swift:1688-1707 | Sources/TokeniserState.swift:2016-2035 — 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 `Sources/TokeniserState.swift:1629` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/TokeniserState.swift:1626` calls `error` and `Sources/TokeniserState.swift:1685` 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 (17–20 lines × 3) Tools/SwiftSoupProfile/main.swift:481— Tools/SwiftSoupProfile/main.swift:481-500 | Tools/SwiftSoupProfile/main.swift:511-527 | Tools/SwiftSoupProfile/main.swift:534-553 — 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/SwiftSoupProfile/main.swift:481` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (19 lines × 2) Sources/HtmlTreeBuilder.swift:315— Sources/HtmlTreeBuilder.swift:315-333 | Sources/HtmlTreeBuilder.swift:376-394 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (4–16 lines × 3) Sources/Entities.swift:604— Sources/Entities.swift:604-619 | Sources/Entities.swift:855-870 | Sources/Entities.swift:1118-1121 — 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 `Sources/Entities.swift:604` it begins part-way through the construct above it, so those 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/Entities.swift:619` calls `memchr`, `Int32` and `Sources/Entities.swift:1121` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 6) Sources/Attributes.swift:1079— Sources/Attributes.swift:1079-1093 | Sources/HtmlTreeBuilderState.swift:306-320 | Sources/HtmlTreeBuilderState.swift:323-337 | Sources/Token.swift:561-575 | Sources/Token.swift:594-608 | Sources/Token.swift:800-814 — there are 6 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Token.swift:594` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, 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, `Sources/HtmlTreeBuilderState.swift:322` calls `equalsSlice` and `Sources/Token.swift:609` 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 (2–15 lines × 6) Sources/Entities.swift:620— Sources/Entities.swift:620-621 | Sources/Entities.swift:871-872 | Sources/Entities.swift:1121-1122 | Sources/StringUtil.swift:638-652 | Sources/StringUtil.swift:873-887 | Sources/StringUtil.swift:1085-1086 — there are 6 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/StringUtil.swift:638` it begins part-way through the construct above it, so those exact lines 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 × 5) Sources/TokeniserState.swift:1635— Sources/TokeniserState.swift:1635-1648 | Sources/TokeniserState.swift:1694-1707 | Sources/TokeniserState.swift:1840-1853 | Sources/TokeniserState.swift:1899-1912 | Sources/TokeniserState.swift:2022-2035 — 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 `Sources/TokeniserState.swift:1635` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/TokeniserState.swift:1633` calls `emitDoctypePending` and `Sources/TokeniserState.swift:1837` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14 lines × 4) Sources/TokeniserState.swift:1733— Sources/TokeniserState.swift:1733-1746 | Sources/TokeniserState.swift:1776-1789 | Sources/TokeniserState.swift:2061-2074 | Sources/TokeniserState.swift:2104-2117 — 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 `Sources/TokeniserState.swift:1733` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (4–14 lines × 3) Sources/Entities.swift:817— Sources/Entities.swift:817-830 | Sources/Entities.swift:1067-1080 | Sources/Entities.swift:1284-1287 — 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 `Sources/Entities.swift:817` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13 lines × 4) Sources/CharacterReader.swift:1201— Sources/CharacterReader.swift:1201-1213 | Sources/CharacterReader.swift:1279-1291 | Sources/CharacterReader.swift:1379-1391 | Sources/CharacterReader.swift:1504-1516 — 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 `Sources/CharacterReader.swift:1201` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 3) Sources/HtmlTreeBuilderState.swift:344— Sources/HtmlTreeBuilderState.swift:344-355 | Sources/HtmlTreeBuilderState.swift:382-394 | Sources/HtmlTreeBuilderState.swift:431-442 — 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 `Sources/HtmlTreeBuilderState.swift:344` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–13 lines × 2) Tools/SwiftSoupProfile/main.swift:450— Tools/SwiftSoupProfile/main.swift:450-462 | Tools/SwiftSoupProfile/main.swift:469-478 — both copies are in the same file, so extract the 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) Tools/SwiftSoupProfile/main.swift:390— Tools/SwiftSoupProfile/main.swift:390-399 | Tools/SwiftSoupProfile/main.swift:606-616 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 8) Sources/TokeniserState.swift:1509— Sources/TokeniserState.swift:1509-1518 | Sources/TokeniserState.swift:1586-1595 | Sources/TokeniserState.swift:1650-1659 | Sources/TokeniserState.swift:1795-1804 | Sources/TokeniserState.swift:1855-1864 | Sources/TokeniserState.swift:1914-1923 | Sources/TokeniserState.swift:1978-1987 | Sources/TokeniserState.swift:2123-2132 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1509` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/TokeniserState.swift:1520` calls `emitDoctypePending`, `transition` and `Sources/TokeniserState.swift:1596` 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 × 3) Sources/Entities.swift:591— Sources/Entities.swift:591-600 | Sources/Entities.swift:843-852 | Sources/Entities.swift:1092-1101 — 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 `Sources/Entities.swift:591` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9–10 lines × 3) Sources/HtmlTreeBuilderState.swift:357— Sources/HtmlTreeBuilderState.swift:357-365 | Sources/HtmlTreeBuilderState.swift:396-405 | Sources/HtmlTreeBuilderState.swift:445-454 — 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 `Sources/HtmlTreeBuilderState.swift:396` it begins part-way through the construct above it, so those 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 lines × 9) Sources/TokeniserState.swift:1394— Sources/TokeniserState.swift:1394-1402 | Sources/TokeniserState.swift:1452-1460 | Sources/TokeniserState.swift:1588-1596 | Sources/TokeniserState.swift:1652-1660 | Sources/TokeniserState.swift:1797-1805 | Sources/TokeniserState.swift:1857-1865 | Sources/TokeniserState.swift:1916-1924 | Sources/TokeniserState.swift:1980-1988 | Sources/TokeniserState.swift:2125-2133 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/TokeniserState.swift:1394` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/TokeniserState.swift:1392` calls `error` and `Sources/TokeniserState.swift:1450` 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 lines × 5) Sources/TokeniserState.swift:1609— Sources/TokeniserState.swift:1609-1617 | Sources/TokeniserState.swift:1671-1679 | Sources/TokeniserState.swift:1816-1824 | Sources/TokeniserState.swift:1876-1884 | Sources/TokeniserState.swift:1999-2007 — 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 `Sources/TokeniserState.swift:1609` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/TokeniserState.swift:1607` calls `emitDoctypePending` and `Sources/TokeniserState.swift:1814` 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 lines × 4) Sources/StringUtil.swift:154— Sources/StringUtil.swift:154-162 | Sources/StringUtil.swift:178-186 | Sources/StringUtil.swift:215-223 | Sources/StringUtil.swift:239-247 — 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 `Sources/StringUtil.swift:154` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 3) Sources/Entities.swift:603— Sources/Entities.swift:603-611 | Sources/Entities.swift:854-862 | Sources/Entities.swift:1104-1112 — 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 `Sources/Entities.swift:603` it begins part-way through the construct above it, so those exact lines 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 × 3) Sources/TokeniserState.swift:2546— Sources/TokeniserState.swift:2546-2552 | Sources/TokeniserState.swift:2634-2641 | Sources/TokeniserState.swift:2685-2691 — 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 `Sources/TokeniserState.swift:2546` it begins part-way through the construct above it, so those exact lines 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–7 lines × 2) Sources/Document.swift:592— Sources/Document.swift:592-597 | Sources/Document.swift:600-606 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Document.swift:592` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (4–7 lines × 3) Sources/StringUtil.swift:653— Sources/StringUtil.swift:653-659 | Sources/StringUtil.swift:888-894 | Sources/StringUtil.swift:1087-1090 — 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 `Sources/StringUtil.swift:653` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 5) Sources/CharacterReader.swift:1113— Sources/CharacterReader.swift:1113-1118 | Sources/CharacterReader.swift:1177-1182 | Sources/CharacterReader.swift:1244-1249 | Sources/CharacterReader.swift:1340-1345 | Sources/CharacterReader.swift:1472-1477 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/CharacterReader.swift:1251` calls `UInt64` and `Sources/CharacterReader.swift:1184` 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 (2–9 lines × 7) Tools/compare_blank_text.py:51— Tools/compare_blank_text.py:51-52 | Tools/compare_child_reads.py:56-57 | Tools/compare_cursor_moves.py:55-56 | Tools/compare_exclusion.py:52-60 | Tools/compare_independent_hotspots.py:52-60 | Tools/compare_ordered_insertion.py:52-60 | Tools/compare_tokenqueue_search.py:48-49 — before extracting anything, compare `Tools/compare_blank_text.py` and `Tools/compare_child_reads.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (2–8 lines × 4) Tools/compare_blank_text.py:53— Tools/compare_blank_text.py:53-60 | Tools/compare_character_classification.py:104-105 | Tools/compare_child_reads.py:58-65 | Tools/compare_cursor_moves.py:57-64 — before extracting anything, compare `Tools/compare_blank_text.py` and `Tools/compare_character_classification.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 7) Tools/compare_blank_text.py:41— Tools/compare_blank_text.py:41-47 | Tools/compare_child_reads.py:46-52 | Tools/compare_cursor_moves.py:45-51 | Tools/compare_exclusion.py:41-47 | Tools/compare_independent_hotspots.py:41-47 | Tools/compare_ordered_insertion.py:41-47 | Tools/compare_tokenqueue_search.py:38-44 — before extracting anything, compare `Tools/compare_blank_text.py` and `Tools/compare_child_reads.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Tools/compare_blank_text.py:41` 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) Tools/compare_exclusion.py:18— Tools/compare_exclusion.py:18-22 | Tools/compare_independent_hotspots.py:18-22 | Tools/compare_ordered_insertion.py:18-22 | Tools/compare_tokenqueue_search.py:15-19 — before extracting anything, compare `Tools/compare_exclusion.py` and `Tools/compare_independent_hotspots.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Off the main sequence: SwiftSoup — SwiftSoup: abstractness 0.03, instability 0.00, distance 0.97 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 6 significant file(s) lose their only recent owner: Sources/Document.swift, Tools/SwiftSoupProfile/main.swift, Sources/StringBuilder.swift, Sources/TreeBuilder.swift, Sources/ByteSlice.swift, Sources/CharacterExt.swift. Pair on, review, or document these before any departure.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 1 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 (7 single-owned of 72 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; 72 of the 88 production source files in this repository met that bar). They are anonymized user #2 (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/`.
D26 · Project Cohesion· Projects may be oversized for their cohesion · ×1
Projects may be oversized for their cohesion — 1 of 1 project(s) overshoot their size bounds, lowering Project Cohesion to 0.0/10. The most over is `(repository root)` (34788 LoC, 127 public types across 3 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D34 · Knowledge Freshness· Orphaned files with no living knowledge · ×1
Orphaned files with no living knowledge — 2 of 72 analysed file(s) have no living knowledge left — their last meaningful change has decayed away, so if one breaks, no one currently understands it (counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 72 of the 88 production source files in this repository met that bar). None is large enough to earn a read-through of its own, so this row stands in for the per-file rows rather than raising one each — most significant first: Tests-macOS/ParserBenchmark.swift, Sources/StreamReader.swift. Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
M2 · Architecture documentation· No architecture diagram/doc · ×1
No architecture diagram/doc — No C4/Structurizr/PlantUML/Mermaid/Graphviz/D2 diagram, no drawn diagram named for the architecture, no file named `architecture` or `design` in any markup this check reads, and nothing in the README, docs or contributor guides that announces the shape — no `## Architecture` heading, no "architecture overview"/"high-level design" phrasing, no "the architecture is …" introduction, no guided code tour. A shape laid out in prose that never names itself as the architecture is not visible to this check, and neither is one kept outside the repository, so this row reports the absence of a re-findable shape document — not evidence that nobody wrote the shape down.
No SAST — No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 2433 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.
Outdated: lrucache — `lrucache` is resolved at 1.1.2, but 1.3.0 is the newest release tagged on https://github.com/nicklockwood/LRUCache within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update lrucache` reaches this one with no change to Package.swift.
Outdated: swift-atomics — `swift-atomics` is resolved at 1.3.0, but 1.3.1 is the newest release tagged on https://github.com/apple/swift-atomics.git within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-atomics` reaches this one with no change to Package.swift.
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.
trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
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 3 file(s) — `Sources/HtmlTreeBuilderState.swift`, `Sources/Node.swift`, `Sources/StringBuilder.swift` — 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 01a0f3e0-f432-7d1e-851f-09b5d1e78f97 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 6 · Warnings: 654 · Recommendations: 42 · Info: 2 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 30-09-2026 @ 19:53 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.