Public report of VincentGourbin/flux-2-swift-mlx, published 16 November 2026. It has the same score, grades and number of
findings as the full report. The details of security findings (where they are in the code, which known
vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive reportMeasured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.11.4). Assert signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey →
Signed and filed in the standard's public register, 16 November 2026, 19:13 UTC · Survey ID cd_3e1f3397a8a24b45a0f67c1454821399
VincentGourbin/flux-2-swift-mlx
Measured 16 November 2026, 19:13 UTC, at code version 315c27e
First survey, so nothing to compare with yet
CAI scoreAdequate
CriticalWeakAdequateStrongExemplary
The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.
A medium codebase: 43,699 lines of product code in 7 projects, tests not counted · Estimated rebuild effort: about 0.4 person-years · Weakest lens: Production Readiness, 27.0
Findings by how serious they are
0 critical451 serious15 minor
30 dimensions are left out of the score. For each one, we either couldn't measure it in this code, or found no evidence of the safeguard we look for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.
This survey was produced by
Canine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
16 November 2026, 19:13 UTC
A measurement, not a certificate. The Code Assurance Index records a number
together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee
the code. The standard was written by Canine Development, which also builds the Canine Code Analyzer. It is open to any tool that
implements it, and today the Canine Code Analyzer is the only one that does.
The score is deterministic, which means the same code always gets the same score. We work it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸
38of 38 dimensions measured by tools.
460of 466 findings point to an exact file and line, so you can open each one in the code. The other 6 concern the repository as a whole, such as missing documentation.
38dimensions across 6 lenses, read from 43,699 lines of product code in 7 projects.
VincentGourbin/flux-2-swift-mlx falls short of our standard for production because we found no working pipeline that builds or tests changes to the code and no logging, tracing or health checks in the code. It scores 58.5 out of 100 and is rated Adequate, and it has no critical findings.
Production Readiness, at 27.0, is the weakest lens and counts most in the score. The best first steps are adding an automated build and test pipeline and adding a diagnostic log, each worth about 6.5 points. Raising Production Readiness to 70 would lift the score to about 78.4.
Most of the 451 serious findings are in Code Health.
The product code is 43,699 lines, about €55,000 to rebuild.
A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.
How the score is built: what each lens counts forThe lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
If Production Readiness rose from 27.0 to 70, the lowest score rated Strong, the score would rise from 58.5 to about 78.4.
Code composition: what the lines of code are
Product code 83%Tests 17%
Rebuild cost: about €55,000 · Estimate
Cost to rebuild
€18,000 to €92,000, for 305 to 969 hours of work, about 0.4 person-years for one engineer
Difficulty of the problem
Standard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor
×0.8 at a score of 58. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
Size
Medium: 43,699 lines of product code
What it is not
Not a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.
How the estimate is made: We price the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Add a CI workflow that builds and runs the test suite on every push/PR.
Raises the score by about 6.5 points · Medium effort · CI/CD gates
2
Write a diagnostic trail the user can hand back with a bug report: log through `os.Logger` (one per subsystem), which the unified log keeps and a sysdiagnose carries to you.
Start with the error paths that emit nothing — a discarded error is the failure the user cannot describe and you cannot reproduce.
Raises the score by about 6.5 points · Medium effort · Observability
3
Keep a changelog (e.g.
Keep-a-Changelog) recording what shipped in each release.
Raises the score by about 2.8 points · Medium effort · Release Hygiene
Diagnosis: what the measurements show together
Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.
Where the investment is most exposed · Value at risk
This code would cost about €55,000 to build again, about 0.4 person-years of work. Its weakest lens is Production Readiness, at 27.0 (Weak). Production Readiness is about whether the product is ready to run in production and to change without breaking. Because the weakest lens counts most in the score, work on Production Readiness also moves the score most.
Based on: the rebuild estimate · the Production Readiness grade · how much each lens counts
What to do: Start with the Production Readiness actions in Top priorities.
If you do one thing first · First action
Add a CI workflow that builds and runs the test suite on every push/PR. Of all the actions in this report, it raises the score most for the work it takes: about 6.5 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 5.3 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 7% to 15% on every change. The history of the code shows how much it changes: about 10,931 lines over the last 90 days, which is about 44,331 lines a year. At that pace, the extra work comes to an estimated 7.6 to 45.5 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of our own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change, never less than 2% to 5% and never more than 40% to 60% in all; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.
Architecture — module dependency graph
Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways, which only happens where the projects form a dependency cycle. A graph without cycles has none.
Architecture: which parts of the code depend on which
The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.
8 modules, with 18 dependencies between them. One loop runs through 4 of the modules, marked above the diagonal.
Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
70 pairs of types, where a type in FluxTextEncoders uses a type in Flux2CLI. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
96 pairs of types, where a type in Flux2Core uses a type in Flux2CLI. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
FluxEncodersCLI uses FluxTextEncoders, so a change to FluxTextEncoders can break FluxEncodersCLI, while a change to FluxEncodersCLI can't break FluxTextEncoders.
Position
Below the diagonal: FluxEncodersCLI uses a module listed above it, which is the healthy direction.
FluxGemma4VLM uses FluxTextEncoders, so a change to FluxTextEncoders can break FluxGemma4VLM, while a change to FluxGemma4VLM can't break FluxTextEncoders.
Position
Below the diagonal: FluxGemma4VLM uses a module listed above it, which is the healthy direction.
Top priorities: Add a CI workflow that builds and runs the test suite on every push/PR; Write a diagnostic trail the user can hand back with a bug report: log through `os.Logger` (one per subsystem), which the unified log keeps and a sysdiagnose carries to you. Start with the error paths that emit nothing — a discarded error is the failure the user cannot describe and you cannot reproduce; Keep a changelog (e.g. Keep-a-Changelog) recording what shipped in each release.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Add a CI workflow that builds and runs the test suite on every push/PR.
Write a diagnostic trail the user can hand back with a bug report: log through `os.Logger` (one per subsystem), which the unified log keeps and a sysdiagnose carries to you. Start with the error paths that emit nothing — a discarded error is the failure the user cannot describe and you cannot reproduce.
Bring the 4 bodies over 60 down to 60 or less in Cognitive Complexity — start with Flux2Pipeline.generateWithResult (cognitive 194), SimpleLoRATrainer.train (cognitive 176), ImageToImage.run (cognitive 107).
Resolve the 6 No assertions finding(s) in Test Quality — start with FluxTextEncodersTests.swift (2), Flux2CoreTests.swift, LoRATrainingSetupTests.swift.
Bring the 6 bodies over 30 down to 30 or less in Cyclomatic Complexity — start with SimpleLoRATrainer.train (cyclomatic 95), Flux2Pipeline.generateWithResult (cyclomatic 93), ImageToImage.run (cyclomatic 67).
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 — 0
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 — 451
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 — 15
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 30
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
This survey 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. All 38 evaluated dimensions are computed by tools and static analysis; no language model sets or judges any of them. Overall confidence is 0.9, the weighted average across measured dimensions.
Every figure here is one of two 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. 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.
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, 460 of 466 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 or a scanner, not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D8 Code Coverage — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: the Swift half could not be measured — the Swift suite in . produced no coverage export. Coverage is excluded from the score rather than counted as a near-zero. This is OUR limitation, not a defect in the repo.
D11 Test Reliability — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test source is present (.swift) and this repository declares a SwiftPM test suite (Flux2Swift), but it was not re-run: no test result was produced. Not scored — this is a gap in the analyzer's language coverage, not a finding about this repository.
D12 Dependency Hygiene — not measured this run — We 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. Not scored — 6 SwiftPM declaration(s) across 1 `Package.swift` and 0 committed pin(s) were read for PINNING discipline (0 defect(s) reported), but the outdated signal comes from listing each declared repository's release tags rather than from a registry, and none of them resolved to a version to compare, so this dimension's own question is only partly answered. NOT a finding that these dependencies are current or healthy.
D14 License Compliance — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 2 of this repository's SwiftPM dependencies could not be fetched at a pinned revision and are repositories api.deps.dev has not indexed, so their licences were not read and the verdict does not cover them: gemma-4-swift-mlx, swift-mlx-profiler.
D16 Bus Factor — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. Single-maintainer repository — bus factor is not applicable (2 contributor(s) across 250 commit(s) sampled, automation and bot accounts excluded). One of them holds 99% of the history; the other 1 hold 1% each on average, below the 5% at which there is somebody to hand the work to. That is a single maintainer with drive-by contributors, not a team whose knowledge has concentrated — so the bus factor is not applicable and there is nothing here for the owner to act on.
D21 Naming Consistency — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
D22 Internal API Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated per language (docs/plans/deterministic-engine.md, P5; C# and each NeutralApiArms arm pass): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
D24 Comment Value — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover the language this repository's product is written in, so it had nothing of the product to read. That is a gap in this analyzer's language reach — not a finding about this repository.
D26 Project Cohesion — not measured this run — We 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. `(repository root)` (43699 LoC, 443 module-visible types across 38 directories) is over its size bounds, and whether one unit is a coherent whole or a grab-bag is read from its type references: the parts of it that reach the rest only through its shared core. Those are read over the C#/VB code model, which this unit's source did not supply. Its size alone is no verdict on its cohesion, so none is published.
D32 Data Compliance (PII/GDPR) — not measured this run — We 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/Flux2App/Views/ContentView.swift`, `Sources/Flux2App/Views/ImageToImageView.swift`, `Sources/Flux2App/Views/TextToImageView.swift`, `Sources/Flux2Core/Loading/ModelDownloader.swift`, `Sources/Flux2Core/Transformer/Flux2FeedForward.swift`, … (+6 more) 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.
D44 Platform End-of-Life — not measured this run — We 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.
C1 Data Protection — not measured this run — We 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 — We 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 — We 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.
GD1 Unfinished & placeholder code — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby, Scala, Rust and Java source only, and no C#, F#, JavaScript/TypeScript, Dart, Ruby, Scala, Rust or Java was found, and this repository's Swift is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
IC1 Incompleteness & stubs — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby, Scala and Rust source only, and no C#, JavaScript/TypeScript, Java, Dart, Ruby, Scala or Rust was found, and this repository's Swift is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
M4 Documentation accuracy — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9), and artefact counts an order of magnitude off. Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
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.
S1 Web-Security Posture — not measured this run — We 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 — We 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, Python, Dart, Ruby, Scala, Rust and Kotlin source only, and no C# was loaded and no JavaScript/TypeScript, Python, Dart, Ruby, Scala, Rust or Kotlin 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.
X12 Unreachable branch — not measured this run — We 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, Python, Dart, Ruby, Scala, Kotlin and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Python, Dart, Ruby, Scala, Kotlin or Rust 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.
X13 Undrained process stream — not measured this run — We 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, Python, Dart, Ruby, Scala, Kotlin, Rust and Java source only, and no C# was loaded and no JavaScript/TypeScript, Python, Dart, Ruby, Scala, Kotlin, Rust or Java 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.
X15 Unvalidated length from an untrusted reader — not measured this run — We 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, Java, Kotlin, Scala, PHP, Ruby, Python, Go, Rust, Dart, F# and Elixir source only, and no C# was loaded and no JavaScript/TypeScript, Java, Kotlin, Scala, PHP, Ruby, Python, Go, Rust, Dart, F# or Elixir 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.
X16 Unfloored truncation loop — not measured this run — We 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, Java, PHP, Dart, Ruby, Scala, Kotlin and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Java, PHP, Dart, Ruby, Scala, Kotlin or Rust 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.
X17 Uncapped recursion over a caller-supplied document — not measured this run — We 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, Python, Dart, Ruby, Scala, Kotlin and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Python, Dart, Ruby, Scala, Kotlin or Rust 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.
X18 Disposal-pattern correctness — not measured this run — We 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, Java, Kotlin, Dart, Ruby, Scala, PHP and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Java, Kotlin, Dart, Ruby, Scala, PHP or Rust 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.
X2 Cancellation propagation — not measured this run — We 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, Go, PHP, Dart, Kotlin, Ruby, Scala, Java, Python and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Go, PHP, Dart, Kotlin, Ruby, Scala, Java, Python or Rust 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.
X22 Contradicted release guard — not measured this run — We 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# and Visual Basic syntax, and Java, TypeScript/JavaScript, Python, Dart, Ruby, Scala, Kotlin, PHP, F# and Visual Basic source only, and no C# was loaded, and this repository's Swift is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X23 Unguarded diagnostic materialisation — not measured this run — We 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, Java, F#, Python, Dart, Ruby, Scala, Kotlin, PHP and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Java, F#, Python, Dart, Ruby, Scala, Kotlin, PHP or Rust 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.
X24 Document value interpolated into markup unescaped — not measured this run — We 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, Java, Scala, Ruby and Python source only, and no C# was loaded and no JavaScript/TypeScript, Java, Scala, Ruby or Python 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.
X25 Inert configuration knob — not measured this run — We 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, Java, Kotlin, Scala, PHP, Erlang, Python, Dart, Ruby and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Java, Kotlin, Scala, PHP, Erlang, Python, Dart, Ruby or Rust 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.
X29 Per-element action decided by a fixed element — not measured this run — We 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 (Vue and Svelte components included), Java, Rust, Dart, Ruby, Scala and Kotlin source only, and no C# was loaded and no JavaScript/TypeScript, Java, Rust, Dart, Ruby, Scala or Kotlin 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.
X30 Support guard that admits what it rejects — not measured this run — We 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 Scala, JavaScript/TypeScript, Java, Kotlin, Python, PHP, Go, Rust, Dart, Ruby and Erlang source only, and no C# was loaded and no Scala, JavaScript, TypeScript, Java, Kotlin, Python, PHP, Go, Rust, Dart, Ruby or Erlang 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.
X5 Nullable reference types — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax and MSBuild project configuration, TypeScript source and its tsconfig files, Java source and its package and module declarations, PHP source and its PHPStan and Psalm configuration, Dart source and its pubspec language version, Ruby source and its Sorbet and Steep configuration, Scala source and its build's explicit-nulls, WartRemover and Scalafix settings, Kotlin source, and Rust source only, and no C# was loaded, no TypeScript was found, and this repository's Swift is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.
Limitations & what we did not check
We assess the repository exactly as committed, and only the repository. By design we do 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.
D7 Architectural Integrity: Layering is checked against detected/declared rules — an architecture whose boundaries live in convention or in code review, not in a rule a scanner can read, is not enforced here.
D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D20 ADR Quality: ADR quality checks the structure of the decision records present: it cannot know about decisions made and never recorded, and it does not judge how well a record argues its case. Records in a language the section lexicon does not cover are not evaluated.
D21 Naming Consistency: Naming consistency compares each name with the convention its structural peers follow in this repository: it cannot tell whether a consistently used name is a good one, and languages other than C# and TypeScript are not measured.
D27 Navigability: Indirection/navigability is structural — it measures hops to follow a call, not whether that indirection buys real flexibility or just ceremony.
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: Documentation accuracy checks links, versions and artefact counts against the tree: other claims (paths, commands, settings, routes) are read but not checked, and it cannot run the onboarding or measure how long a real new joiner takes.
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
What it measures: How tangled the control flow is — methods with many branches are hard to test and change.
Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.
38 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was SimpleLoRATrainer.train at 95. A further 1 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being Training.recommendedMemoryGB at 16 — 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/Flux2Core/Training/Training.swift (Training.recommendedMemoryGB at 16). 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.
+ 33 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 6 bodies over 30 down to 30 or less in Cyclomatic Complexity — start with SimpleLoRATrainer.train (cyclomatic 95), Flux2Pipeline.generateWithResult (cyclomatic 93), ImageToImage.run (cyclomatic 67). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 6 together lifts Cyclomatic Complexity from 6.1 to about 7.3/10, projected with the scoring formula itself and assuming each lands exactly at 30; a cleaner split scores higher.
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.
+ 65 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 4 bodies over 60 down to 60 or less in Cognitive Complexity — start with Flux2Pipeline.generateWithResult (cognitive 194), SimpleLoRATrainer.train (cognitive 176), ImageToImage.run (cognitive 107). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 4 together lifts Cognitive Complexity from 3.1 to about 5.3/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes8.5 / 10Strong✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
Resolve the 18 MethodTooLong finding(s) in God Classes — start with SimpleLoRATrainer.swift (4), ContentView.swift (3), TrainLoRACommand.swift (2). — One of this dimension's main actionable groups (18 warning-level).
Resolve the 8 FileTooLong finding(s) in God Classes — start with ContentView.swift, SimpleLoRATrainer.swift, Flux2Pipeline.swift. — One of this dimension's main actionable groups (8 warning-level).
Resolve the 5 ClassTooLong finding(s) in God Classes — start with SimpleLoRATrainer.swift, Flux2Pipeline.swift, FluxTextEncoders.swift. — One of this dimension's main actionable groups (5 warning-level).
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D4 · Code Duplication3.0 / 10Weak✓ Tool-verified
What it measures: How much of the production code is copy-pasted: the share of production lines inside a reported copy (every copy of a duplicated block or of an edited member, each line once), 10 at none and 0 at a quarter of the lines.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), scored on the share of production lines inside a reported copy (each line once; 10 at none, 0 at a quarter). Deterministic.
180 duplicated block group(s) detected. 17.5 % of the production lines (7,644 of 43,699) are in a reported copy. A further 102 rows report members as variants of one another; the share counts each copied line once, however many rows cite it. 3 of the 282 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.
+ 151 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 10 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with InpaintCommand.swift, LatentUtils.swift, LoRATrainingHelper.swift. — One of this dimension's main actionable groups (10 warning-level).
Resolve the 8 Members sharing a duplicated core (4 members, 50+ identical tokens) finding(s) in Code Duplication — start with MistralModel.swift (2), WeightLoader.swift, Flux2Pipeline.swift. — One of this dimension's main actionable groups (8 warning-level).
Resolve the 8 Duplicated block (10 lines × 2) finding(s) in Code Duplication — start with MistralModel.swift (2), ContentView.swift, WeightLoader.swift. — One of this dimension's main actionable groups (8 warning-level).
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · Coupling7.7 / 10Strong✓ Tool-verified
What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.
Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.
Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.
7 production modules (SwiftPM), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 2 module(s) off the main sequence.
Off the main sequence: FluxTextEncoders · ×2
What to do
Resolve the 2 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (2 warning-level).
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.
Resolve the 6 Low cohesion finding(s) in Cohesion (LCOM4) — start with FluxTextEncoders.swift, FlowMatchEulerScheduler.swift, AutoencoderKL.swift. — One of this dimension's main actionable groups (6 warning-level).
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the code respects its intended layering / architecture rules.
Method: Enforcement rung (Prevented/Verified/Documented) per checkable ADR via Roslyn, plus dependency cycles via the engine shared with D5/AX3. Deterministic, exact.
No mechanizable ADR was identified, so enforcement is not measured. Dependency cycles not checked (no project-reference graph; where this repository's language has an import-cycle lens, cycles are reported there).
Detailed fixes: d7_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality9.8 / 10Stronggated by 9 serious findings✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
Resolve the 6 No assertions finding(s) in Test Quality — start with FluxTextEncodersTests.swift (2), Flux2CoreTests.swift, LoRATrainingSetupTests.swift. — One of this dimension's main actionable groups (6 warning-level).
Resolve the 3 Skipped test finding(s) in Test Quality — start with ModelDownloaderSizeTests.swift, ModelPathOverrideTests.swift, Gemma4VLMProviderTests.swift. — One of this dimension's main actionable groups (3 warning-level).
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: Whether the licenses of third-party packages are compatible with your policy.
Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.
0 of 4 SwiftPM package(s) use a banned license. SwiftPM has no package registry, so each package's licence is the one its repository declares: 0 of them read from the licence file the repository carries at the revision Package.resolved pins, and 4 — unpinned, or whose licence file could not be read or named — from api.deps.dev, which reports the licence the repository declares today. Graded: every package a committed Package.resolved pins, direct and transitive, and every declared dependency none pins. 6 of them are declared by a manifest that commits no Package.resolved (a library, whose resolution is its consumer's), so their own dependencies are resolved by whoever builds it and are not in this verdict. ★ 2 package(s) could not be read at a pinned revision and are not known to the index, and were NOT graded — this verdict does not cover them: `gemma-4-swift-mlx`, `swift-mlx-profiler`.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
Top hotspots: Sources/Flux2Core/Pipeline/Flux2Pipeline.swift (14×93=1302); Sources/Flux2CLI/Flux2CLI.swift (10×67=670); Sources/Flux2CLI/InpaintCommand.swift (7×18=126) Repeated repair below the complexity floor: Sources/Flux2Core/Loading/ModelDownloader.swift (7 of 8 changes were fixes); Sources/Flux2Core/Configuration/ModelRegistry.swift (5 of 7 changes were fixes); Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift (5 of 5 changes were fixes)
Resolve the 3 Hotspot finding(s) in Churn × Complexity Hotspots — start with Flux2Pipeline.swift, Flux2CLI.swift, InpaintCommand.swift. — One of this dimension's main actionable groups (3 warning-level).
Resolve the 3 Repeated repair finding(s) in Churn × Complexity Hotspots — start with ModelDownloader.swift, ModelRegistry.swift, TextEncoderModelDownloader.swift. — One of this dimension's main actionable groups (3 warning-level).
Detailed fixes: d15_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.
1 deducted task-comment markers across 43699 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
Resolve the 1 TodoComment finding(s) in Explicit Debt — start with LoRAAdapter.swift. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Every ADR read by its section structure: nine located rules (a missing Decision, Context or Consequences section, a stale status, two records deciding the same question, a dangling supersede link, a number-only title, a single option, no named cost, no status where the log uses one, no enforcement field where the log adopted one), each a fixed deduction from 10; the score is the mean over evaluated records. Deterministic, no model. Advisory.
0 of 3 evaluated ADRs have a defect readable from the log itself (a missing or empty section, no title, a single option, consequences with no cost, no status, a missing enforcement field, a status the log contradicts, a dangling link, an unlinked second decision on one question, a date that is no calendar day). How well each record argues its case is not measured.
What it measures: Whether names — types, methods, variables — are clear and consistent.
Method: Seven vocabulary-free rules (N1-N7) mine each naming convention from the repository and flag a name that breaks a convention its structural peers in the same unit follow; production C# and TypeScript, each its own population. Deterministic, no model, no sample. Advisory.
1 naming inconsistencies among 59 declarations measured against a convention their peers follow.
`runtimeID` spells `ID` where 58 names in the project spell it `Id`Sources/Flux2Core/Utils/RuntimeBeacon.swift:55
What to do
Resolve the 1 `runtimeID` spells `ID` where 58 names in the project spell it `Id` finding(s) in Naming Consistency — start with RuntimeBeacon.swift. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d21_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How far you must trace to follow a call — low indirection and co-located slices read easier.
Method: Call indirection (interface hops, cross-namespace calls, slice-locality scaled) over a sampled set of method invocations, size-aware baseline. Sampled; confidence discounted by symbol-resolution gaps. C# also names each pass-through layer (a class whose every public method only forwards its own parameters to one collaborator) as a located finding; the score is not affected.
Coverage: Slice locality from the first namespace segments, SAMPLED (≤400 methods) — not exhaustive.
17 % of calls cross a namespace and 0 % go through an interface, but 100 % of collaborators are co-located — so a call's collaborators sit together and tracing stays easy. Baseline: small — navigation cost is tolerated.
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).
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.
Every significant source file has living knowledge — recently and meaningfully worked. Counted over 129 of the 148 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
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.
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.
Other · Architecture — Whether interfaces stay focused rather than fat — the Interface-Segregation principle (SOLID 'I').
Method: Roslyn scan: public interface declared-member counts (accessors fold into their property/event); fat-interface threshold (over 15 declared members) flagged per type. Each finding also reports the distinct-OPERATION count — members counted by name, so an overload group counts once — which decides whether it states the caller-side ISP harm or the implementer-side burden of an overload set. TypeScript: exported interfaces that declare behaviour, counted over their REQUIRED operations (method signatures and function-typed properties with no `?`, once per signature) — data-shape interfaces and ambient .d.ts declarations are outside the population; JavaScript declares no interfaces and is not applicable. Deterministic, type-level.
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 repository and its projects have a README, and whether it is substantive.
Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.
Maturity · Maturity — Whether the repository is organised deliberately: production code and tests are set apart in a way its ecosystem or the repository itself declares.
Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.
Maturity · Maturity — Whether the project's current-state documentation describes the code that exists.
Method: Every current-state document's checkable claims looked up in the tree (links, versions, and artefact counts an order of magnitude off), plus two README checks: an advertised infrastructure product with no footprint, and a module the CHANGELOG records as removed. Deterministic, no model. Advisory.
Do you agree with this assessment?
P1 · CI/CD gates0.0 / 10Critical✓ Tool-verified
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
No CI workflow found (.github/workflows, azure-pipelines.yml, .gitlab-ci.yml, …) — changes aren't gated by an automated build/test.
What to do
Add a CI workflow that builds and runs the test suite on every push/PR.
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's code 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.
Do you agree with this assessment?
P2 · Observability0.0 / 10Critical✓ Tool-verified
Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.
No logging or diagnostics emission found. This repository ships a binary its users launch rather than a service you operate, so there is no operator to page — but when a run fails on a user's machine, neither they nor you have anything to read.
What to do
Write a diagnostic trail the user can hand back with a bug report: log through `os.Logger` (one per subsystem), which the unified log keeps and a sysdiagnose carries to you. Start with the error paths that emit nothing — a discarded error is the failure the user cannot describe and you cannot reproduce.
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) — this repository has no CI pipeline yet, so run it locally to clear the existing findings, then make it a step of the first workflow you add so a regression fails the build. What was searched, so you can tell an absence from a miss: the 0 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
Run what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — locally for now, since there is no CI pipeline here yet, and as a step of the first workflow you add so a security regression fails the build instead of landing.
Enable Dependabot/Renovate or a dependency-review gate.
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.
Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.
No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
What to do
Keep a changelog (e.g. Keep-a-Changelog) recording what shipped in each release.
Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.
Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from each language's code model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.
Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.
Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.
Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.
Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.
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.
Unscored — 2 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
X10 Duplicated predicate — 9 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 3 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 3 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
C3 Audit Trail — Not assessed: 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.
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 — 73 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.
AX1 Captive dependencies — Not applicable: this repository's Swift imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. No Swift request handler (a Vapor, Hummingbird, Kitura, Swifter or Perfect route handler, as a method or a registered closure) is declared, so no state is shared between request threads.
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AXB1 Runtime evidence locked — no reproducible boot — This repository has nothing the runtime tiers could boot or serve — no markup, no UI framework or web-server dependency, no UI component source, no native UI project and no API definition — nothing here is a surface to boot — so runtime a11y/egress/header evidence has no subject here. Not applicable: this is neither a gap in the scan nor a finding about your code.
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.
C4 Data Retention — No personal data detected in a persisted data model — no PII-named property (email, firstName, dateOfBirth, phoneNumber, …) or stored credential on a SwiftData @Model, a Core Data, Realm, GRDB or Fluent type, a GRDB or SQLite.swift column, or in a SQL CREATE TABLE or ALTER TABLE — and no database or data-store client (CoreData, SwiftData, GRDB, RealmSwift, SQLite, Firebase, …) imported either, so this repository keeps no personal data whose lifetime a retention limit would bound.
C5 Data-Subject Rights — No personal data detected in a persisted data model — no PII-named property (email, firstName, dateOfBirth, phoneNumber, …) or stored credential on a SwiftData @Model, a Core Data, Realm, GRDB or Fluent type, a GRDB or SQLite.swift column, or in a SQL CREATE TABLE or ALTER TABLE — and no database or data-store client (CoreData, SwiftData, GRDB, RealmSwift, SQLite, Firebase, …) imported either, so this repository keeps no personal data for a data subject to erase, export or consent over.
D11 Test Reliability — Test reliability not included — the .swift suite was found but not re-run
D12 Dependency Hygiene — Not scored — 6 SwiftPM declaration(s) across 1 `Package.swift` and 0 committed pin(s) were read for PINNING discipline (0 defect(s) reported), but the outdated signal comes from listing each declared repository's release tags rather than from a registry, and none of them resolved to a version to compare, so this dimension's own question is only partly answered. NOT a finding that these dependencies are current or healthy.
D16 Bus Factor — single-maintainer repository — bus factor is not applicable
D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
D19 Documentation Quality — No runnable or published unit to look for an example in, and no multi-project root README to look for a map in; the other documentation kinds are withheld (see the gaps), so documentation quality is not applicable here.
D22 Internal API Consistency — API consistency is measured on C#, TypeScript, Go only; the exposed Swift surface was not measured.
D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ sibling projects each declaring an entity of their own or taking another project's integration events. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — D24 reads C#, Visual Basic, TypeScript and JavaScript comments only — this repository's production source is .py, .swift, which was left unread. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D25 ADR Conformance — None of 0 binding record(s) states a rule in checkable form (a backticked element with a prohibition, or an `adr-rules` block), so conformance cannot be read from the code. Write the rule as an `adr-rules` block (`forbid:` a symbol, a package or a dependency) to make it checkable.
D26 Project Cohesion — D26 could not read how the parts of this repository's one build unit reference each other, so its cohesion was not measured. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D30 Dependency Vulnerabilities — Not scored — no dependency manifest in a supported ecosystem was read for this repository. A gap in the analyzer's language coverage, NOT a finding that the repository is free of vulnerable dependencies (a Swift Package.swift/Package.resolved — not scanned yet).
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) — 11 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D36 Supply-chain Provenance & Signing — No CI/build pipeline found (.github/.forgejo/.gitea workflows, .circleci, .buildkite, .woodpecker, .teamcity, .gitlab-ci.yml, .travis.yml, bitbucket-pipelines.yml, .drone.yml, .cirrus.yml, .woodpecker.yml, appveyor.yml, azure-pipelines*.yml, .pipelines/, .vsts-ci/, .azuredevops/, Jenkinsfile); there is no build to attest provenance for.
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.
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 — Not scored — no dependency manifest in a supported ecosystem was read for this repository. A gap in the analyzer's language coverage, NOT a finding that the repository is free of vulnerable dependencies (a Swift Package.swift/Package.resolved — not scanned yet).
D44 Platform End-of-Life — Platform end-of-life not assessed — this repository declares no platform this pass reads
D8 Code Coverage — Coverage not measured — Swift suite
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 — no mutating command handlers or message consumers detected — idempotency check not applicable
ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby, Scala, Rust and Java, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
P12 CI test-gate honesty — no CI workflow found
P7 Outbound HTTP resilience — not applicable — no HTTP server, API framework or worker entry point was found in the 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 not measured: this check compares the coverage of the analyzer's own test run across the domain and web layers, and that run measured none here — Test coverage (D8) says why
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.
PF2 Allocation hygiene — Not scored: this check counted allocation-aware idioms (Span, pools, stackalloc) per line, which describes what kind of code a repository is rather than whether it has an allocation problem, so it was withdrawn. Nothing here is 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
X12 Unreachable branch — 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
X13 Undrained process stream — 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
X14 Bypassable address classification — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X15 Unvalidated length from an untrusted reader — 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
X16 Unfloored truncation loop — 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
X17 Uncapped recursion over a caller-supplied document — 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
X18 Disposal-pattern 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
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 asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X21 Side-effecting pattern guard — Not applicable: this check looks for a pattern guard or `case` label that increments, decrements or assigns while the switch is deciding whether it matches, and in this repository's languages none can. Swift has no `++` or `--`, and an assignment yields `()`, which cannot be an operand of `&&`, `||` or `?:` nor the Bool a `case … where` clause needs. Not a gap in the analyzer and not a finding about your code.
X22 Contradicted release guard — 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
X23 Unguarded diagnostic materialisation — 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
X24 Document value interpolated into markup unescaped — 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
X25 Inert configuration knob — 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
X26 Unsynchronised callback handoff — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X27 Collection changed while being enumerated — Not applicable: this check looks for a loop whose body adds to or removes from the very collection the loop is walking, invalidating the enumerator it holds, and in this repository's languages that cannot happen. Swift's `Array`, `Dictionary` and `Set` are values: `for x in items` walks the copy taken when the loop starts, so a body that adds to or removes from `items` changes a different value, nothing is invalidated, and every original element is still visited. This repository's Swift names no Foundation mutable collection (`NSMutableArray` and kin), the one kind a Swift loop can walk by reference. Not a gap in the analyzer and 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
X30 Support guard that admits what it rejects — 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
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 — This check asks whether log calls keep a message's values apart from its text, which needs a logger that can carry them as fields. This repository's Swift was read, and it logs through none: `print` and `NSLog` take one finished line, and os's `Logger` keeps each interpolated value as its own argument, so an assembled message there loses nothing the API could have kept (as with log4net in C#). Calls through swift-log (`import Logging`) and `os_log` calls would be judged.
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.
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.
MethodTooLong: Flux2Pipeline.generateWithResult Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1215— MethodTooLong — generateWithResult runs 590 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 490 over it, 5.90× 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: SimpleLoRATrainer.train Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:244— MethodTooLong — train runs 412 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 312 over it, 4.12× 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: TrainLoRA.runSimpleTrainer Sources/Flux2CLI/TrainLoRACommand.swift:638— MethodTooLong — runSimpleTrainer runs 212 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 112 over it, 2.12× 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: ImageToImage.run Sources/Flux2CLI/Flux2CLI.swift:486— MethodTooLong — run runs 196 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 96 over it, 1.96× 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: YAMLConfigParser.toLoRATrainingConfig Sources/Flux2CLI/TrainingConfigYAML.swift:347— MethodTooLong — toLoRATrainingConfig runs 196 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 96 over it, 1.96× 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: ModelsManagementView.body Sources/Flux2App/Views/ContentView.swift:1724— MethodTooLong — body runs 176 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 76 over it, 1.76× 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: SimpleLoRATrainer.trainStep Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:902— MethodTooLong — trainStep runs 160 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 60 over it, 1.60× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: FluxToolsView.processAction Sources/Flux2App/Views/ContentView.swift:1456— MethodTooLong — processAction runs 158 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 58 over it, 1.58× 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: TextToImage.run Sources/Flux2CLI/Flux2CLI.swift:125— MethodTooLong — run runs 154 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 54 over it, 1.54× 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: Flux2WeightLoader.mapBFLTransformerWeights Sources/Flux2Core/Loading/WeightLoader.swift:87— MethodTooLong — mapBFLTransformerWeights runs 154 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 54 over it, 1.54× 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: TrainLoRA.run Sources/Flux2CLI/TrainLoRACommand.swift:220— MethodTooLong — run runs 138 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 38 over it, 1.38× 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: FluxToolsView.body Sources/Flux2App/Views/ContentView.swift:1231— MethodTooLong — body runs 136 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 36 over it, 1.36× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Flux2Transformer2DModel.callAsFunction Sources/Flux2Core/Transformer/Flux2Transformer.swift:123— MethodTooLong — callAsFunction runs 127 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 27 over it, 1.27× 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: CompareEncoders.run Sources/Flux2CLI/CompareEncoders.swift:57— MethodTooLong — run runs 110 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 10 over it, 1.10× 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: Embed.run Sources/FluxEncodersCLI/FluxEncodersCLI.swift:288— MethodTooLong — run runs 108 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 8 over it, 1.08× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: SimpleLoRATrainer.generateLearningCurveSVG Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2424— MethodTooLong — generateLearningCurveSVG runs 106 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 6 over it, 1.06× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Flux2MaskedInpaintingChain.run Sources/Flux2Chains/Flux2MaskedInpaintingChain.swift:301— MethodTooLong — run runs 104 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 4 over it, 1.04× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: SimpleLoRATrainer.scoreValidationImagesWithVLM Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2072— MethodTooLong — scoreValidationImagesWithVLM runs 103 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 3 over it, 1.03× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
Duplicated block (6 lines × 2) Sources/Flux2CLI/InpaintCommand.swift:235— Sources/Flux2CLI/InpaintCommand.swift:235-240 | Sources/Flux2Core/Utils/MemoryManager.swift:108-114 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) Sources/Flux2Core/Pipeline/LatentUtils.swift:293— Sources/Flux2Core/Pipeline/LatentUtils.swift:293-298 | Sources/Flux2Core/Transformer/Flux2RoPE.swift:278-285 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. 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 (6 lines × 2) Sources/Flux2Core/Training/LoRATrainingHelper.swift:148— Sources/Flux2Core/Training/LoRATrainingHelper.swift:148-153 | Sources/Flux2Core/Training/LoRATrainingHelper.swift:680-685 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Training/LoRATrainingHelper.swift:148` 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 (6 lines × 2) Sources/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:89— Sources/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:89-94 | Sources/FluxTextEncoders/Embeddings/KleinConfig.swift:150-155 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (6 lines × 2) Sources/FluxTextEncoders/FluxTextEncoders.swift:455— Sources/FluxTextEncoders/FluxTextEncoders.swift:455-460 | Sources/FluxTextEncoders/FluxTextEncoders.swift:568-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/FluxTextEncoders/FluxTextEncoders.swift:455` 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 (6 lines × 2) Sources/Flux2Core/Loading/ModelDownloader.swift:472— Sources/Flux2Core/Loading/ModelDownloader.swift:472-477 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:712-717 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) Sources/Flux2Core/LoRA/LoRAConfig.swift:79— Sources/Flux2Core/LoRA/LoRAConfig.swift:79-84 | Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:143-148 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:228— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:228-237 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:217-222 — before extracting anything, compare `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` and `Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 195 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `Qwen3TextConfig` in one and `Qwen3VLTextConfig` 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 (6 lines × 2) Sources/Flux2CLI/ProfileCommand.swift:124— Sources/Flux2CLI/ProfileCommand.swift:124-129 | Sources/Flux2CLI/ProfileCommand.swift:237-242 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1423— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1423-1428 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1479-1484 — both copies are in the same file, so extract the 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1423` 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.
FileTooLong: Views/ContentView.swift Sources/Flux2App/Views/ContentView.swift— FileTooLong — 1807 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1307 over it, 3.61× 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: Loop/SimpleLoRATrainer.swift Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift— FileTooLong — 1598 significant lines (blank, comment-only and punctuation-only lines excluded), about 93% of them inside a single declaration: SimpleLoRATrainer (172-2591). The bar is 500 significant lines; this is 1098 over it, 3.20× 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: Pipeline/Flux2Pipeline.swift Sources/Flux2Core/Pipeline/Flux2Pipeline.swift— FileTooLong — 1420 significant lines (blank, comment-only and punctuation-only lines excluded), about 96% of them inside a single declaration: Flux2Pipeline (99-2526). The bar is 500 significant lines; this is 920 over it, 2.84× 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: FluxTextEncoders/FluxTextEncoders.swift Sources/FluxTextEncoders/FluxTextEncoders.swift— FileTooLong — 773 significant lines (blank, comment-only and punctuation-only lines excluded), about 96% of them inside a single declaration: FluxTextEncoders (33-1363). The bar is 500 significant lines; this is 273 over it, 1.55× 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: Flux2CLI/TrainLoRACommand.swift Sources/Flux2CLI/TrainLoRACommand.swift— FileTooLong — 643 significant lines (blank, comment-only and punctuation-only lines excluded), about 95% of them inside a single declaration: TrainLoRA (13-949). The bar is 500 significant lines; this is 143 over it, 1.29× 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: Flux2CLI/Flux2CLI.swift Sources/Flux2CLI/Flux2CLI.swift— FileTooLong — 631 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 131 over it, 1.26× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Configuration/LoRATrainingConfig.swift Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift— FileTooLong — 549 significant lines (blank, comment-only and punctuation-only lines excluded), about 68% of them inside a single declaration: LoRATrainingConfig (215-887). The bar is 500 significant lines; this is 49 over it, 1.10× 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: FluxEncodersCLI/FluxEncodersCLI.swift Sources/FluxEncodersCLI/FluxEncodersCLI.swift— FileTooLong — 511 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 11 over it, 1.02× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×8
Members sharing a duplicated core (4 members, 50+ identical tokens) Sources/Flux2Core/Loading/WeightLoader.swift:15— Sources/Flux2Core/Loading/WeightLoader.swift:15-45 | Sources/FluxTextEncoders/Loading/TextEncoderWeightLoader.swift:14-42 | Sources/FluxTextEncoders/Model/MistralModel.swift:277-323 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:332-386 — 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/Flux2Core/Pipeline/Flux2Pipeline.swift:963— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:963-1001 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1006-1042 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1079-1117 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1122-1158 — 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/Flux2Core/Transformer/Flux2Attention.swift:442— Sources/Flux2Core/Transformer/Flux2Attention.swift:442-461 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:318-337 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:443-462 | Sources/Flux2Core/Transformer/Flux2RoPE.swift:208-241 — 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/FluxTextEncoders/Configuration/EncoderConfiguration.swift:61— Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:61-83 | Sources/FluxTextEncoders/Configuration/Qwen35Configuration.swift:79-105 | Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:51-70 | Sources/FluxTextEncoders/Configuration/Qwen3VLConfiguration.swift:65-89 — 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/FluxTextEncoders/Generation/MistralGenerator.swift:426— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:426-453 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:415-440 | Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:122-155 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35VLM.swift:254-279 — 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/FluxTextEncoders/Model/MistralAttention.swift:394— Sources/FluxTextEncoders/Model/MistralAttention.swift:394-474 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:92-163 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35Attention.swift:65-142 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLAttention.swift:62-126 — 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/FluxTextEncoders/Model/MistralModel.swift:99— Sources/FluxTextEncoders/Model/MistralModel.swift:99-148 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:58-105 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:62-111 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:403-429 — 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/FluxTextEncoders/Model/MistralModel.swift:277— Sources/FluxTextEncoders/Model/MistralModel.swift:277-323 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:332-386 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:218-289 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:298-371 — 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 (10 lines × 2) Sources/Flux2App/Views/ContentView.swift:214— Sources/Flux2App/Views/ContentView.swift:214-223 | Sources/Flux2App/Views/ContentView.swift:301-310 — both copies are in the same file, so extract the 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/Flux2App/Views/ContentView.swift:214` 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/Flux2Core/Loading/WeightLoader.swift:825— Sources/Flux2Core/Loading/WeightLoader.swift:825-834 | Sources/Flux2Core/Loading/WeightLoader.swift:851-860 — both copies are in the same file, so extract the block into 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/Flux2Core/Transformer/Flux2ParallelAttention.swift:75— Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:75-84 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:217-226 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:75` 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/FluxTextEncoders/Model/MistralModel.swift:152— Sources/FluxTextEncoders/Model/MistralModel.swift:152-161 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:534-543 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/MistralModel.swift:152` 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/FluxTextEncoders/Model/MistralModel.swift:309— Sources/FluxTextEncoders/Model/MistralModel.swift:309-318 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:365-374 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) Sources/Flux2App/ViewModels/ModelManager.swift:617— Sources/Flux2App/ViewModels/ModelManager.swift:617-626 | Sources/Flux2App/Views/ContentView.swift:789-798 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/Flux2App/Views/ContentView.swift:800` calls `formatDeltaBytesUI`, `formatBytesUI` and `Sources/Flux2App/ViewModels/ModelManager.swift:627` 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/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:73— Sources/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:73-82 | Sources/FluxTextEncoders/Embeddings/KleinConfig.swift:133-142 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (10 lines × 2) Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:31— Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:31-41 | Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift:30-39 — before extracting anything, compare `Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift` and `Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 first that the copies are not typed on the same thing: the declarations holding them bind `model` to `Qwen3ForCausalLM` in one and `Qwen3VLForCausalLM` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (15 lines × 2) Sources/Flux2App/Views/ContentView.swift:1994— Sources/Flux2App/Views/ContentView.swift:1994-2008 | Sources/Flux2App/Views/ContentView.swift:2095-2109 — both copies are in the same file, so extract the 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/Flux2App/Views/ContentView.swift:1994` 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/Flux2CLI/ProfileCommand.swift:99— Sources/Flux2CLI/ProfileCommand.swift:99-113 | Sources/Flux2CLI/ProfileCommand.swift:202-216 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2CLI/ProfileCommand.swift:99` 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/Flux2CLI/TrainLoRACommand.swift:970— Sources/Flux2CLI/TrainLoRACommand.swift:970-984 | Sources/Flux2CLI/TrainingConfigYAML.swift:622-636 — 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. 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 (15 lines × 2) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:987— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:987-1001 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1103-1117 — both copies are in the same file, so extract the 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/Flux2Core/Pipeline/Flux2Pipeline.swift:987` 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/FluxEncodersCLI/FluxEncodersCLI.swift:92— Sources/FluxEncodersCLI/FluxEncodersCLI.swift:92-106 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:156-170 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxEncodersCLI/FluxEncodersCLI.swift:92` 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/FluxTextEncoders/Generation/MistralGenerator.swift:197— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:197-211 | Sources/FluxTextEncoders/Generation/MistralGenerator.swift:329-343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Generation/MistralGenerator.swift:197` 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/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:254— Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:254-268 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:342-356 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:254` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Sources/Flux2Core/Loading/ModelDownloader.swift:365— Sources/Flux2Core/Loading/ModelDownloader.swift:365-371 | Sources/Flux2Core/Loading/ModelDownloader.swift:416-422 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Loading/ModelDownloader.swift:365` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Sources/Flux2Core/Pipeline/LatentUtils.swift:268— Sources/Flux2Core/Pipeline/LatentUtils.swift:268-274 | Sources/Flux2Core/Transformer/Flux2RoPE.swift:252-258 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (7 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2474— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2474-2480 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2485-2491 — both copies are in the same file, so extract the 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2474` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Sources/Flux2Core/Transformer/Flux2Attention.swift:320— Sources/Flux2Core/Transformer/Flux2Attention.swift:320-327 | Sources/Flux2Core/Transformer/Flux2Attention.swift:404-410 — both copies are in the same file, so extract the 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/Flux2Core/Transformer/Flux2Attention.swift:320` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) Sources/FluxTextEncoders/Loading/SafetensorsDirectory.swift:75— Sources/FluxTextEncoders/Loading/SafetensorsDirectory.swift:75-81 | Sources/FluxTextEncoders/Loading/SafetensorsDirectory.swift:136-142 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) Sources/FluxTextEncoders/Model/MistralAttention.swift:342— Sources/FluxTextEncoders/Model/MistralAttention.swift:342-348 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:21-27 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralAttention.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `base` to `Float = 10000.0` in one and `Float = 1_000_000.0` 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 (7 lines × 2) Sources/FluxTextEncoders/Model/MistralAttention.swift:350— Sources/FluxTextEncoders/Model/MistralAttention.swift:350-356 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:29-35 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralAttention.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
No assertions: testMemoryManagerCanRunCheck Tests/Flux2CoreTests/Flux2CoreTests.swift:860— 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*, in the test body and in the helpers it calls in the test and test-support code (a helper there that throws when its check fails counts as an assertion) — so verification routed through a callback object whose members hold the assertions, or through a harness in production code that fails by throwing, 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: testEnableThinkingParameterExists Tests/Flux2CoreTests/LoRATrainingSetupTests.swift:191— 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*, in the test body and in the helpers it calls in the test and test-support code (a helper there that throws when its check fails counts as an assertion) — so verification routed through a callback object whose members hold the assertions, or through a harness in production code that fails by throwing, 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: testIsModelLoadedInitiallyFalse Tests/FluxTextEncodersTests/FluxTextEncodersTests.swift:34— 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*, in the test body and in the helpers it calls in the test and test-support code (a helper there that throws when its check fails counts as an assertion) — so verification routed through a callback object whose members hold the assertions, or through a harness in production code that fails by throwing, 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: testIsVLMLoadedInitiallyFalse Tests/FluxTextEncodersTests/FluxTextEncodersTests.swift:41— 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*, in the test body and in the helpers it calls in the test and test-support code (a helper there that throws when its check fails counts as an assertion) — so verification routed through a callback object whose members hold the assertions, or through a harness in production code that fails by throwing, 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: testTextEncoderModelRegistryFindByVariantNotFound Tests/FluxTextEncodersTests/ModelRegistryTests.swift:132— 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*, in the test body and in the helpers it calls in the test and test-support code (a helper there that throws when its check fails counts as an assertion) — so verification routed through a callback object whose members hold the assertions, or through a harness in production code that fails by throwing, 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: testReconfigureHubApiDoesNotCrash Tests/FluxTextEncodersTests/TextEncoderModelDirectoryTests.swift:51— 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*, in the test body and in the helpers it calls in the test and test-support code (a helper there that throws when its check fails counts as an assertion) — so verification routed through a callback object whose members hold the assertions, or through a harness in production code that fails by throwing, 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.
D4 · Code Duplication· Edited copy of a member (14 corresponding lines) · ×6
Edited copy of a member (14 corresponding lines) Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:677— Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:677-697 | Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:699-712 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) Sources/Flux2Core/Training/Data/LatentCache.swift:446— Sources/Flux2Core/Training/Data/LatentCache.swift:446-459 | Sources/Flux2Core/Training/LoRATrainingHelper.swift:330-350 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) Sources/Flux2Core/Transformer/Flux2Attention.swift:422— Sources/Flux2Core/Transformer/Flux2Attention.swift:422-437 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:273-286 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) Sources/Flux2Core/Pipeline/LatentUtils.swift:460— Sources/Flux2Core/Pipeline/LatentUtils.swift:460-473 | Sources/Flux2Core/Pipeline/LatentUtils.swift:483-496 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) Sources/Flux2App/ViewModels/ModelManager.swift:129— Sources/Flux2App/ViewModels/ModelManager.swift:129-143 | Sources/Flux2App/ViewModels/ModelManager.swift:154-167 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) Sources/FluxTextEncoders/VLM/FluxVLMProvider.swift:79— Sources/FluxTextEncoders/VLM/FluxVLMProvider.swift:79-92 | Sources/FluxTextEncoders/VLM/FluxVLMProvider.swift:118-132 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (11 lines × 2) Sources/Flux2App/Views/ContentView.swift:2415— Sources/Flux2App/Views/ContentView.swift:2415-2425 | Sources/Flux2App/Views/TextToImageView.swift:148-158 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2App/Views/ContentView.swift:2415` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) Sources/Flux2CLI/InpaintCommand.swift:139— Sources/Flux2CLI/InpaintCommand.swift:139-149 | Sources/Flux2CLI/OutpaintCommand.swift:75-85 — before extracting anything, compare `Sources/Flux2CLI/InpaintCommand.swift` and `Sources/Flux2CLI/OutpaintCommand.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2CLI/InpaintCommand.swift:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/Flux2CLI/InpaintCommand.swift:150` calls `loadCGImage`, `ValidationError` and `Sources/Flux2CLI/OutpaintCommand.swift:86` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1439— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1439-1450 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1495-1505 — both copies are in the same file, so extract the 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1439` 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 lines × 2) Sources/Flux2Core/Transformer/Flux2Attention.swift:394— Sources/Flux2Core/Transformer/Flux2Attention.swift:394-404 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:252-262 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:352— Sources/FluxEncodersCLI/FluxEncodersCLI.swift:352-362 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:405-415 — both copies are in the same file, so extract the 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/FluxEncodersCLI/FluxEncodersCLI.swift:352` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11 lines × 2) scripts/fix_learning_curve.swift:87— scripts/fix_learning_curve.swift:87-97 | scripts/fix_learning_curve.swift:109-119 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Sources/Flux2App/Views/ContentView.swift:178— Sources/Flux2App/Views/ContentView.swift:178-186 | Sources/Flux2App/Views/ContentView.swift:373-381 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Sources/Flux2App/Views/ContentView.swift:2283— Sources/Flux2App/Views/ContentView.swift:2283-2291 | Sources/Flux2App/Views/ContentView.swift:2446-2454 — both copies are in the same file, so extract the 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/Flux2App/Views/ContentView.swift:2283` 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/Flux2CLI/CompareEncoders.swift:104— Sources/Flux2CLI/CompareEncoders.swift:104-112 | Sources/Flux2CLI/CompareEncoders.swift:134-142 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) Sources/Flux2Core/Pipeline/LatentUtils.swift:461— Sources/Flux2Core/Pipeline/LatentUtils.swift:461-469 | Sources/Flux2Core/Pipeline/LatentUtils.swift:484-492 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Pipeline/LatentUtils.swift:461` 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 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1406— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1406-1414 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1467-1475 — both copies are in the same file, so extract the 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1406` 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1416` calls `value` and `Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1476` 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 × 2) Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:407— Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:407-415 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:108-116 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (5 lines × 2) Sources/Flux2Core/Pipeline/Flux2Pipeline+ChainHelpers.swift:189— Sources/Flux2Core/Pipeline/Flux2Pipeline+ChainHelpers.swift:189-193 | Sources/Flux2Core/Pipeline/Flux2Pipeline+ChainHelpers.swift:225-229 — both copies are in the same file, so extract the 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/Flux2Core/Pipeline/Flux2Pipeline+ChainHelpers.swift:189` 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/Flux2Core/Pipeline/Flux2Pipeline.swift:2463— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2463-2467 | Sources/Flux2Core/Training/Data/LatentCache.swift:475-480 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2463` 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/FluxTextEncoders/FluxTextEncoders.swift:901— Sources/FluxTextEncoders/FluxTextEncoders.swift:901-905 | Sources/FluxTextEncoders/FluxTextEncoders.swift:1242-1246 — both copies are in the same file, so extract the 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/FluxTextEncoders/FluxTextEncoders.swift:901` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 2) Sources/FluxTextEncoders/FluxTextEncoders.swift:829— Sources/FluxTextEncoders/FluxTextEncoders.swift:829-833 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:580-584 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/FluxTextEncoders.swift:829` 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 × 2) Sources/Flux2CLI/TestQwen35.swift:164— Sources/Flux2CLI/TestQwen35.swift:164-169 | Sources/Flux2CLI/TestVLGeneration.swift:77-81 — 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) scripts/fix_learning_curve.swift:176— scripts/fix_learning_curve.swift:176-180 | scripts/fix_learning_curve.swift:182-186 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Low cohesion: FluxTextEncoders (LCOM4 14) Sources/FluxTextEncoders/FluxTextEncoders.swift:33— FluxTextEncoders's methods fall into 14 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 14 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: FlowMatchEulerScheduler (LCOM4 5) Sources/Flux2Core/Scheduler/FlowMatchEulerScheduler.swift:34— FlowMatchEulerScheduler'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: AutoencoderKLFlux2 (LCOM4 5) Sources/Flux2Core/VAE/AutoencoderKL.swift:46— AutoencoderKLFlux2'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: Flux2MemoryManager (LCOM4 4) Sources/Flux2Core/Utils/MemoryManager.swift:11— Flux2MemoryManager'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: TextEncoderModelRegistry (LCOM4 4) Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:441— TextEncoderModelRegistry'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: TextEncoderModelDownloader (LCOM4 4) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:17— TextEncoderModelDownloader'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.
ClassTooLong: SimpleLoRATrainer Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:172— ClassTooLong — 1482 significant lines (blank, comment-only and punctuation-only lines excluded), 34 methods. The bar is 400 significant lines; this is 1082 over it, 3.71× 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: Flux2Pipeline Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:99— ClassTooLong — 1364 significant lines (blank, comment-only and punctuation-only lines excluded), 35 methods. The bar is 400 significant lines; this is 964 over it, 3.41× 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: FluxTextEncoders Sources/FluxTextEncoders/FluxTextEncoders.swift:33— ClassTooLong — 743 significant lines (blank, comment-only and punctuation-only lines excluded), 50 methods. The bar is 400 significant lines; this is 343 over it, 1.86× 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: TrainLoRA Sources/Flux2CLI/TrainLoRACommand.swift:13— ClassTooLong — 610 significant lines (blank, comment-only and punctuation-only lines excluded), 6 methods. The bar is 400 significant lines; this is 210 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.
ClassTooLong: Flux2WeightLoader Sources/Flux2Core/Loading/WeightLoader.swift:10— ClassTooLong — 479 significant lines (blank, comment-only and punctuation-only lines excluded), 17 methods. The bar is 400 significant lines; this is 79 over it, 1.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication· Edited copy of a member (7 corresponding lines) · ×5
Edited copy of a member (7 corresponding lines) Sources/FluxTextEncoders/FluxTextEncoders.swift:827— Sources/FluxTextEncoders/FluxTextEncoders.swift:827-833 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:578-584 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) Sources/Flux2Core/Utils/Flux2Debug.swift:84— Sources/Flux2Core/Utils/Flux2Debug.swift:84-90 | Sources/Flux2Core/Utils/Flux2Debug.swift:93-99 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) Sources/FluxTextEncoders/Loading/SafetensorsDirectory.swift:22— Sources/FluxTextEncoders/Loading/SafetensorsDirectory.swift:22-28 | Sources/FluxTextEncoders/Loading/SafetensorsDirectory.swift:33-41 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) Sources/Flux2CLI/TestGemma4.swift:117— Sources/Flux2CLI/TestGemma4.swift:117-123 | Sources/Flux2Core/Training/LoRATrainingSetup.swift:64-73 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) Sources/Flux2Core/Configuration/ModelRegistry.swift:442— Sources/Flux2Core/Configuration/ModelRegistry.swift:442-448 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:43-49 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (4 corresponding lines) · ×5
Edited copy of a member (4 corresponding lines) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2586— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2586-2590 | scripts/fix_learning_curve.swift:28-31 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) Sources/Flux2Core/Transformer/Flux2Attention.swift:199— Sources/Flux2Core/Transformer/Flux2Attention.swift:199-202 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:290-293 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) Sources/Flux2Core/Transformer/Flux2Attention.swift:206— Sources/Flux2Core/Transformer/Flux2Attention.swift:206-209 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:295-298 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) Sources/Flux2App/ViewModels/ImageGenerationViewModel.swift:182— Sources/Flux2App/ViewModels/ImageGenerationViewModel.swift:182-185 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2313-2316 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) Sources/Flux2Core/Loading/KleinTextEncoder.swift:155— Sources/Flux2Core/Loading/KleinTextEncoder.swift:155-158 | Sources/Flux2Core/Loading/MistralEncoder.swift:399-402 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (12 lines × 2) Sources/Flux2App/Views/ContentView.swift:2355— Sources/Flux2App/Views/ContentView.swift:2355-2366 | Sources/Flux2App/Views/ContentView.swift:2418-2429 — both copies are in the same file, so extract the 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/Flux2App/Views/ContentView.swift:2355` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Sources/Flux2App/Views/ContentView.swift:2352— Sources/Flux2App/Views/ContentView.swift:2352-2363 | Sources/Flux2App/Views/TextToImageView.swift:126-137 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2App/Views/ContentView.swift:2352` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Sources/Flux2CLI/TrainLoRACommand.swift:440— Sources/Flux2CLI/TrainLoRACommand.swift:440-451 | Sources/Flux2CLI/TrainLoRACommand.swift:525-536 — both copies are in the same file, so extract the 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/Flux2CLI/TrainLoRACommand.swift:440` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1162— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1162-1173 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1216-1227 — both copies are in the same file, so extract the block into 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/Flux2Core/Pipeline/LatentUtils.swift:153— Sources/Flux2Core/Pipeline/LatentUtils.swift:153-164 | Sources/Flux2Core/Pipeline/LatentUtils.swift:187-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/Flux2Core/Pipeline/LatentUtils.swift:153` 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 (8 lines × 3) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:100— Sources/FluxEncodersCLI/FluxEncodersCLI.swift:100-107 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:164-171 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:365-372 — 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/FluxEncodersCLI/FluxEncodersCLI.swift:100` 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 × 3) Sources/FluxTextEncoders/FluxTextEncoders.swift:1038— Sources/FluxTextEncoders/FluxTextEncoders.swift:1038-1047 | Sources/FluxTextEncoders/Generation/MistralGenerator.swift:401-408 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:335-342 — before extracting anything, compare `Sources/FluxTextEncoders/Generation/MistralGenerator.swift` and `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/FluxTextEncoders.swift:1038` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8 lines × 3) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:86— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:86-93 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:378-385 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:532-539 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 3) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:561— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:561-572 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:633-640 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:646-653 — 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:561` 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 (8 lines × 3) Sources/Flux2Core/Configuration/ModelRegistry.swift:279— Sources/Flux2Core/Configuration/ModelRegistry.swift:279-286 | Sources/Flux2Core/Configuration/QuantizationConfig.swift:14-21 | Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:54-61 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
TooManyMethods: FluxTextEncoders Sources/FluxTextEncoders/FluxTextEncoders.swift:33— TooManyMethods — 50 methods. The bar is 30 methods; this is 20 over it, 1.67× 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: Flux2Pipeline Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:99— TooManyMethods — 35 methods, declared across 2 files: Pipeline/Flux2Pipeline.swift (30), Pipeline/Flux2Pipeline+ChainHelpers.swift (5). The bar is 30 methods; this is 5 over it, 1.17× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: SimpleLoRATrainer Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:172— TooManyMethods — 34 methods. The bar is 30 methods; this is 4 over it, 1.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TextEncoderModelDownloader Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:17— 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.
D4 · Code Duplication· Edited copy of a member (16 corresponding lines) · ×4
Edited copy of a member (16 corresponding lines) Sources/FluxTextEncoders/Model/MistralAttention.swift:374— Sources/FluxTextEncoders/Model/MistralAttention.swift:374-392 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:64-90 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) Sources/Flux2Core/Configuration/Flux2Config.swift:350— Sources/Flux2Core/Configuration/Flux2Config.swift:350-367 | Sources/Flux2Core/Configuration/VAEConfig.swift:99-114 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) Sources/Flux2App/ViewModels/ImageGenerationViewModel.swift:322— Sources/Flux2App/ViewModels/ImageGenerationViewModel.swift:322-337 | Sources/Flux2App/Views/ContentView.swift:1696-1711 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) Sources/Flux2Core/Transformer/Flux2SingleBlock.swift:171— Sources/Flux2Core/Transformer/Flux2SingleBlock.swift:171-186 | Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:334-349 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (11 corresponding lines) · ×4
Edited copy of a member (11 corresponding lines) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:630— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:630-640 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:643-653 — These two members are one piece of code written twice and then edited apart: 11 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.
Edited copy of a member (11 corresponding lines) Sources/FluxTextEncoders/FluxTextEncoders.swift:768— Sources/FluxTextEncoders/FluxTextEncoders.swift:768-778 | Sources/FluxTextEncoders/FluxTextEncoders.swift:800-810 — These two members are one piece of code written twice and then edited apart: 11 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.
Edited copy of a member (11 corresponding lines) Sources/FluxGemma4VLM/Gemma4VLMProvider.swift:93— Sources/FluxGemma4VLM/Gemma4VLMProvider.swift:93-103 | Sources/FluxGemma4VLM/Gemma4VLMProvider.swift:107-117 — These two members are one piece of code written twice and then edited apart: 11 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.
Edited copy of a member (11 corresponding lines) Sources/Flux2Core/Loading/DevTextEncoder.swift:136— Sources/Flux2Core/Loading/DevTextEncoder.swift:136-149 | Sources/Flux2Core/Loading/MistralEncoder.swift:484-494 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (8 corresponding lines) · ×4
Edited copy of a member (8 corresponding lines) Sources/Flux2Core/Pipeline/LatentUtils.swift:291— Sources/Flux2Core/Pipeline/LatentUtils.swift:291-298 | Sources/Flux2Core/Transformer/Flux2RoPE.swift:275-285 — These two members are one piece of code written twice and then edited apart: 8 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.
Edited copy of a member (8 corresponding lines) Sources/Flux2CLI/TrainLoRACommand.swift:987— Sources/Flux2CLI/TrainLoRACommand.swift:987-994 | Sources/Flux2CLI/TrainingConfigYAML.swift:638-645 — These two members are one piece of code written twice and then edited apart: 8 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.
Edited copy of a member (8 corresponding lines) Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:34— Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:34-41 | Sources/Flux2Core/Training/Optimizer/ResumableLion.swift:35-42 — These two members are one piece of code written twice and then edited apart: 8 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.
Edited copy of a member (8 corresponding lines) Sources/Flux2Core/Configuration/ModelRegistry.swift:300— Sources/Flux2Core/Configuration/ModelRegistry.swift:300-307 | Sources/Flux2Core/Loading/DevTextEncoder.swift:57-68 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (17 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:226— Sources/Flux2App/Views/ImageToImageView.swift:226-242 | Sources/Flux2App/Views/TextToImageView.swift:177-193 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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, `Sources/Flux2App/Views/ImageToImageView.swift:220` calls `frame` and `Sources/Flux2App/Views/TextToImageView.swift:171` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (17 lines × 2) Sources/Flux2CLI/CompareEncoders.swift:167— Sources/Flux2CLI/CompareEncoders.swift:167-183 | Sources/Flux2CLI/CompareEncoders.swift:188-204 — both copies are in the same file, so extract the block into 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/Flux2Core/Transformer/Flux2Transformer.swift:399— Sources/Flux2Core/Transformer/Flux2Transformer.swift:399-415 | Sources/Flux2Core/Transformer/Flux2Transformer.swift:504-520 — both copies are in the same file, so extract the 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/Flux2Core/Transformer/Flux2Transformer.swift:399` 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/Flux2Core/Transformer/Flux2Transformer.swift:396` calls `setDoubleStream` and `Sources/Flux2Core/Transformer/Flux2Transformer.swift:502` 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 (17 lines × 2) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:388— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:388-404 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:441-457 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:388` 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 × 2) Sources/Flux2App/Views/ContentView.swift:2052— Sources/Flux2App/Views/ContentView.swift:2052-2064 | Sources/Flux2App/Views/ContentView.swift:2160-2172 — both copies are in the same file, so extract the 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/Flux2App/Views/ContentView.swift:2052` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:111— Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:111-123 | Sources/FluxTextEncoders/Configuration/Qwen3VLConfiguration.swift:132-144 — before extracting anything, compare `Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift` and `Sources/FluxTextEncoders/Configuration/Qwen3VLConfiguration.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 45 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 2) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:232— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:232-244 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:329-341 — both copies are in the same file, so extract the 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:232` 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:247` calls `ensureTekkenJson` and `Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:343` 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 (13 lines × 2) Sources/FluxTextEncoders/Model/MistralModel.swift:325— Sources/FluxTextEncoders/Model/MistralModel.swift:325-337 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:388-400 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/MistralModel.swift:325` 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 × 3) Sources/Flux2CLI/InpaintCommand.swift:275— Sources/Flux2CLI/InpaintCommand.swift:275-279 | Sources/Flux2CLI/MaskSubjectCommand.swift:66-70 | Sources/Flux2CLI/OutpaintCommand.swift:137-141 — before extracting anything, compare `Sources/Flux2CLI/InpaintCommand.swift` and `Sources/Flux2CLI/OutpaintCommand.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 3) Sources/FluxTextEncoders/Model/MistralMLP.swift:39— Sources/FluxTextEncoders/Model/MistralMLP.swift:39-44 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3MLP.swift:42-47 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLMLP.swift:39-43 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (5 lines × 3) Sources/FluxTextEncoders/Model/MistralModel.swift:61— Sources/FluxTextEncoders/Model/MistralModel.swift:61-65 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:20-24 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:25-29 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 3) Sources/FluxTextEncoders/FluxTextEncoders.swift:929— Sources/FluxTextEncoders/FluxTextEncoders.swift:929-933 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:178-182 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:199-203 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Hotspot: Sources/Flux2Core/Pipeline/Flux2Pipeline.swift Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1215— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 93 in Flux2Pipeline.generateWithResult at line 1215. 6 of those changes were fix/bug commits, and the other 8 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-14..2026-09-12, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-14 11:04:31 +02:00' --until='2026-09-12 11:04:31 +02:00' --full-history --no-merges -- Sources/Flux2Core/Pipeline/Flux2Pipeline.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/Flux2CLI/Flux2CLI.swift Sources/Flux2CLI/Flux2CLI.swift:486— Sources/Flux2CLI/Flux2CLI.swift changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 67 in ImageToImage.run at line 486. 3 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-14..2026-09-12, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-14 11:04:31 +02:00' --until='2026-09-12 11:04:31 +02:00' --full-history --no-merges -- Sources/Flux2CLI/Flux2CLI.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/Flux2CLI/InpaintCommand.swift Sources/Flux2CLI/InpaintCommand.swift:139— Sources/Flux2CLI/InpaintCommand.swift changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in Inpaint.run at line 139. 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-14..2026-09-12, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-14 11:04:31 +02:00' --until='2026-09-12 11:04:31 +02:00' --full-history --no-merges -- Sources/Flux2CLI/InpaintCommand.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.
Repeated repair: Sources/Flux2Core/Loading/ModelDownloader.swift Sources/Flux2Core/Loading/ModelDownloader.swift:242— Sources/Flux2Core/Loading/ModelDownloader.swift changed 8 times in last 90 days and 7 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is Flux2ModelDownloader.download at line 242), AT OR UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(loading): sixth review pass — load only the verified series, protect in-place relocation”; “fix(loading): fourth review pass — one shared weight-directory inspector”; “fix(loading): third review pass — relocation guards everywhere, no resident garbage”; “fix(loading): harden path overrides after review — no regression for symlinked layouts”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-06-14..2026-09-12, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-14 11:04:31 +02:00' --until='2026-09-12 11:04:31 +02:00' --full-history --no-merges -- Sources/Flux2Core/Loading/ModelDownloader.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.
Repeated repair: Sources/Flux2Core/Configuration/ModelRegistry.swift Sources/Flux2Core/Configuration/ModelRegistry.swift:543— Sources/Flux2Core/Configuration/ModelRegistry.swift changed 7 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is ModelRegistry.localPath at line 543), AT OR UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(loading): third review pass — relocation guards everywhere, no resident garbage”; “fix(loading): harden path overrides after review — no regression for symlinked layouts”; “revert: descope ask #2 (pathOverrides) after two review rounds”; “fix: address code review findings on relocated-model storage PR”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-06-14..2026-09-12, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-14 11:04:31 +02:00' --until='2026-09-12 11:04:31 +02:00' --full-history --no-merges -- Sources/Flux2Core/Configuration/ModelRegistry.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.
Repeated repair: Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:733— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift changed 5 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is TextEncoderModelDownloaderError.errorDescription at line 733), AT OR UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(loading): sixth review pass — load only the verified series, protect in-place relocation”; “fix(loading): fourth review pass — one shared weight-directory inspector”; “fix(loading): third review pass — relocation guards everywhere, no resident garbage”; “fix(loading): harden path overrides after review — no regression for symlinked layouts”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-06-14..2026-09-12, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-06-14 11:04:31 +02:00' --until='2026-09-12 11:04:31 +02:00' --full-history --no-merges -- Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.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.
D4 · Code Duplication· Edited copy of a member (35 corresponding lines) · ×3
Edited copy of a member (35 corresponding lines) Sources/FluxTextEncoders/FluxTextEncoders.swift:189— Sources/FluxTextEncoders/FluxTextEncoders.swift:189-238 | Sources/FluxTextEncoders/FluxTextEncoders.swift:298-332 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (35 corresponding lines) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:74— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:74-108 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:518-553 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (35 corresponding lines) Sources/Flux2Core/Training/Data/TrainingDataset.swift:249— Sources/Flux2Core/Training/Data/TrainingDataset.swift:249-283 | Sources/Flux2Core/Training/Data/TrainingDataset.swift:286-334 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (5 corresponding lines) · ×3
Edited copy of a member (5 corresponding lines) Sources/FluxTextEncoders/Model/Qwen35/Qwen35MRoPE.swift:122— Sources/FluxTextEncoders/Model/Qwen35/Qwen35MRoPE.swift:122-126 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLMRoPE.swift:119-123 — These two members are one piece of code written twice and then edited apart: 5 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.
Edited copy of a member (5 corresponding lines) Sources/FluxTextEncoders/Vision/ImageProcessor.swift:242— Sources/FluxTextEncoders/Vision/ImageProcessor.swift:242-246 | Sources/FluxTextEncoders/Vision/VisionEncoder.swift:483-487 — These two members are one piece of code written twice and then edited apart: 5 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.
Edited copy of a member (5 corresponding lines) Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:293— Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:293-297 | Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:173-177 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (6 corresponding lines) · ×3
Edited copy of a member (6 corresponding lines) Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:299— Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:299-304 | Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:179-184 — These two members are one piece of code written twice and then edited apart: 6 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.
Edited copy of a member (6 corresponding lines) Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:874— Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:874-879 | Sources/Flux2Core/Training/Control/TrainingState.swift:249-255 — These two members are one piece of code written twice and then edited apart: 6 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.
Edited copy of a member (6 corresponding lines) Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:24— Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:24-32 | Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:23-28 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (34 lines × 2) Sources/Flux2App/Views/ContentView.swift:2010— Sources/Flux2App/Views/ContentView.swift:2010-2043 | Sources/Flux2App/Views/ContentView.swift:2118-2151 — both copies are in the same file, so extract the 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/Flux2App/Views/ContentView.swift:2010` 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 (34 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:288— Sources/Flux2App/Views/ImageToImageView.swift:288-321 | Sources/Flux2App/Views/TextToImageView.swift:256-289 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/Flux2App/Views/ImageToImageView.swift:288` 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/Flux2App/Views/TextToImageView.swift:290` calls `help` and `Sources/Flux2App/Views/ImageToImageView.swift:322` 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 (34 lines × 2) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1763— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1763-1796 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1997-2030 — both copies are in the same file, so extract the block into 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:466— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:466-489 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:568-591 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (24 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1794— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1794-1817 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1824-1847 — both copies are in the same file, so extract the block into 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/Flux2Core/Training/Optimizer/ResumableAdamW.swift:71— Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:71-101 | Sources/Flux2Core/Training/Optimizer/ResumableLion.swift:72-95 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/Flux2Core/Training/Optimizer/ResumableLion.swift:66` calls `MLXArray`, `Int32` and `Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift: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 (16–17 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:366— Sources/Flux2App/Views/ImageToImageView.swift:366-381 | Sources/Flux2App/Views/TextToImageView.swift:298-314 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/Flux2App/Views/ImageToImageView.swift:366` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–17 lines × 2) Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:47— Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:47-63 | Sources/Flux2Core/Training/Optimizer/ResumableLion.swift:48-63 — 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 `Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:47` 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/Flux2Core/Training/Optimizer/ResumableLion.swift:66` calls `MLXArray`, `Int32` and `Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:65` 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 (16–17 lines × 2) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:346— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:346-362 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:275-290 — before extracting anything, compare `Sources/FluxTextEncoders/Generation/MistralGenerator.swift` and `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/Generation/MistralGenerator.swift:346` 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–15 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:411— Sources/Flux2App/Views/ImageToImageView.swift:411-424 | Sources/Flux2App/Views/TextToImageView.swift:346-360 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/Flux2App/Views/ImageToImageView.swift:411` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–15 lines × 2) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1319— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1319-1333 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1355-1368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 2) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:103— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:103-117 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLAttention.swift:74-87 — before extracting anything, compare `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift` and `Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLAttention.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 77 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (14 lines × 2) Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:118— Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:118-134 | Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift:100-113 — before extracting anything, compare `Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift` and `Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:118` 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/FluxTextEncoders/Generation/Qwen3Generator.swift:134— Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:134-147 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:259-272 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) Sources/Flux2Core/Configuration/MemoryOptimizationConfig.swift:143— Sources/Flux2Core/Configuration/MemoryOptimizationConfig.swift:143-156 | Sources/FluxTextEncoders/Configuration/TextEncoderMemoryConfig.swift:57-70 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (12–13 lines × 2) Sources/Flux2Core/Loading/WeightLoader.swift:235— Sources/Flux2Core/Loading/WeightLoader.swift:235-247 | Sources/Flux2Core/Loading/WeightLoader.swift:278-289 — both copies are in the same file, so extract the 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/Flux2Core/Loading/WeightLoader.swift:235` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1276— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1276-1288 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1325-1336 — both copies are in the same file, so extract the 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1276` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12–13 lines × 2) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:426— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:426-438 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:415-426 — before extracting anything, compare `Sources/FluxTextEncoders/Generation/MistralGenerator.swift` and `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/Generation/MistralGenerator.swift:426` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1245— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1245-1254 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1270-1279 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1319-1328 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 3) Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:107— Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:107-116 | Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:110-119 | Sources/FluxTextEncoders/Configuration/Qwen3VLConfiguration.swift:131-140 — before extracting anything, compare `Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift` and `Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:107` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 3) Sources/FluxTextEncoders/FluxTextEncoders.swift:430— Sources/FluxTextEncoders/FluxTextEncoders.swift:430-439 | Sources/FluxTextEncoders/FluxTextEncoders.swift:469-478 | Sources/FluxTextEncoders/FluxTextEncoders.swift:496-505 — 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/FluxTextEncoders/FluxTextEncoders.swift:430` 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.
D4 · Code Duplication· Edited copy of a member (30 corresponding lines) · ×2
Edited copy of a member (30 corresponding lines) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:181— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:181-214 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:175-204 — These two members are one piece of code written twice and then edited apart: 30 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.
Edited copy of a member (30 corresponding lines) Sources/FluxTextEncoders/FluxTextEncoders.swift:246— Sources/FluxTextEncoders/FluxTextEncoders.swift:246-275 | Sources/FluxTextEncoders/FluxTextEncoders.swift:335-371 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (18 corresponding lines) · ×2
Edited copy of a member (18 corresponding lines) Sources/Flux2Core/Training/Model/LoRALinear.swift:368— Sources/Flux2Core/Training/Model/LoRALinear.swift:368-385 | Sources/Flux2Core/Training/Model/LoRALinear.swift:393-410 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (18 corresponding lines) Sources/Flux2Core/Loading/DevTextEncoder.swift:37— Sources/Flux2Core/Loading/DevTextEncoder.swift:37-54 | Sources/Flux2Core/Loading/MistralEncoder.swift:36-62 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (33 corresponding lines) · ×2
Edited copy of a member (33 corresponding lines) Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:107— Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:107-145 | Sources/FluxTextEncoders/Configuration/Qwen3VLConfiguration.swift:131-163 — These two members are one piece of code written twice and then edited apart: 33 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.
Edited copy of a member (33 corresponding lines) Sources/Flux2Chains/Flux2MaskedInpaintingChain.swift:250— Sources/Flux2Chains/Flux2MaskedInpaintingChain.swift:250-288 | Sources/Flux2Chains/Flux2OutpaintingChain.swift:136-168 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (22 corresponding lines) · ×2
Edited copy of a member (22 corresponding lines) Sources/Flux2Core/Pipeline/LatentUtils.swift:256— Sources/Flux2Core/Pipeline/LatentUtils.swift:256-286 | Sources/Flux2Core/Transformer/Flux2RoPE.swift:249-270 — 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.
Edited copy of a member (22 corresponding lines) Sources/Flux2Core/Loading/KleinTextEncoder.swift:123— Sources/Flux2Core/Loading/KleinTextEncoder.swift:123-144 | Sources/Flux2Core/Loading/MistralEncoder.swift:70-91 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 10+ corresponding lines) · ×2
Edited copies of one member (3 members, 10+ corresponding lines) Sources/FluxTextEncoders/Model/MistralModel.swift:21— Sources/FluxTextEncoders/Model/MistralModel.swift:21-30 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3DecoderLayer.swift:20-29 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLDecoderLayer.swift:25-34 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 10+ corresponding lines) Sources/FluxTextEncoders/FluxTextEncoders.swift:374— Sources/FluxTextEncoders/FluxTextEncoders.swift:374-383 | Sources/FluxTextEncoders/FluxTextEncoders.swift:751-760 | Sources/FluxTextEncoders/FluxTextEncoders.swift:783-792 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Duplicated block (25 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:249— Sources/Flux2App/Views/ImageToImageView.swift:249-273 | Sources/Flux2App/Views/TextToImageView.swift:198-222 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/Flux2App/Views/ImageToImageView.swift:249` 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 (25 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1915— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1915-1939 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1946-1970 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (19 lines × 2) Sources/Flux2App/Views/ContentView.swift:1494— Sources/Flux2App/Views/ContentView.swift:1494-1512 | Sources/Flux2App/Views/ContentView.swift:1624-1642 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (19 lines × 2) Sources/FluxTextEncoders/Model/MistralModel.swift:32— Sources/FluxTextEncoders/Model/MistralModel.swift:32-50 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3DecoderLayer.swift:31-49 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (17–18 lines × 2) Sources/Flux2App/ViewModels/ImageGenerationViewModel.swift:259— Sources/Flux2App/ViewModels/ImageGenerationViewModel.swift:259-275 | Sources/Flux2App/ViewModels/ImageGenerationViewModel.swift:284-301 — both copies are in the same file, so extract the 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/Flux2App/ViewModels/ImageGenerationViewModel.swift:259` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (17–18 lines × 2) Sources/Flux2Core/Transformer/Flux2Attention.swift:212— Sources/Flux2Core/Transformer/Flux2Attention.swift:212-229 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:300-316 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (14 lines × 3) Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:126— Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:126-139 | Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:125-138 | Sources/FluxTextEncoders/Configuration/Qwen3VLConfiguration.swift:147-160 — before extracting anything, compare `Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift` and `Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:126` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 3) Sources/FluxTextEncoders/Model/MistralAttention.swift:397— Sources/FluxTextEncoders/Model/MistralAttention.swift:397-410 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:95-108 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLAttention.swift:66-79 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralAttention.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/MistralAttention.swift:397` 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:112` calls `q_norm`, `k_norm` and `Sources/FluxTextEncoders/Model/MistralAttention.swift:413` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12–13 lines × 4) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1809— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1809-1820 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1839-1850 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1930-1942 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1961-1973 — 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1809` 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 × 4) Sources/FluxTextEncoders/Model/MistralModel.swift:286— Sources/FluxTextEncoders/Model/MistralModel.swift:286-298 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:342-354 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:225-236 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:306-317 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (10–12 lines × 2) Sources/FluxTextEncoders/Model/MistralAttention.swift:375— Sources/FluxTextEncoders/Model/MistralAttention.swift:375-384 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:65-76 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralAttention.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `MistralTextConfig` in one and `Qwen3TextConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (10–12 lines × 2) Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:242— Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:242-251 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:323-334 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:242` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 3) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:93— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:93-103 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:385-395 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:438-448 — 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:93` 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:397` calls `verifyShardedModel` and `Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:104` 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/FluxTextEncoders/Model/MistralModel.swift:127— Sources/FluxTextEncoders/Model/MistralModel.swift:127-137 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:84-94 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:412-422 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/MistralModel.swift:127` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) Sources/Flux2Chains/Flux2MaskedInpaintingChain.swift:488— Sources/Flux2Chains/Flux2MaskedInpaintingChain.swift:488-497 | Sources/Flux2Chains/Flux2OutpaintingChain.swift:283-293 — 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 `Sources/Flux2Chains/Flux2OutpaintingChain.swift:283` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) Sources/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:207— Sources/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:207-217 | Sources/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:285-294 — both copies are in the same file, so extract the 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, `Sources/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:219` calls `log` and `Sources/FluxTextEncoders/Embeddings/EmbeddingExtractor.swift:297` 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 × 3) Sources/Flux2CLI/Flux2CLI.swift:153— Sources/Flux2CLI/Flux2CLI.swift:153-161 | Sources/Flux2CLI/Flux2CLI.swift:512-520 | Sources/Flux2CLI/Flux2CLI.swift:877-885 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 3) Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:59— Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:59-69 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:188-197 | Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:48-56 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (8–9 lines × 2) Sources/Flux2App/Views/ContentView.swift:1873— Sources/Flux2App/Views/ContentView.swift:1873-1881 | Sources/Flux2App/Views/ContentView.swift:2482-2489 — both copies are in the same file, so extract the 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/Flux2App/Views/ContentView.swift:2482` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/Flux2App/Views/ContentView.swift:2480` calls `Spacer` and `Sources/Flux2App/Views/ContentView.swift:1871` 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 (8–9 lines × 2) Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:142— Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:142-150 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35VLM.swift:267-274 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:142` 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 × 4) Sources/Flux2Core/Loading/ModelDownloader.swift:177— Sources/Flux2Core/Loading/ModelDownloader.swift:177-184 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:93-100 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:385-392 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:438-445 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (8 lines × 4) Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:61— Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:61-68 | Sources/FluxTextEncoders/Configuration/Qwen35Configuration.swift:79-86 | Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift:51-58 | Sources/FluxTextEncoders/Configuration/Qwen3VLConfiguration.swift:65-72 — before extracting anything, compare `Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift` and `Sources/FluxTextEncoders/Configuration/Qwen3Configuration.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Configuration/EncoderConfiguration.swift:61` 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/FluxTextEncoders/Configuration/Qwen3Configuration.swift:59` calls `decode`, `decodeIfPresent` and `Sources/FluxTextEncoders/Configuration/Qwen35Configuration.swift:87` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) Sources/FluxTextEncoders/Model/MistralAttention.swift:413— Sources/FluxTextEncoders/Model/MistralAttention.swift:413-420 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:116-123 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralAttention.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:112` calls `q_norm`, `k_norm` and `Sources/FluxTextEncoders/Model/MistralAttention.swift:410` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1430— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1430-1437 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1486-1493 — both copies are in the same file, so extract the 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1430` 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.
Off the main sequence: FluxTextEncoders — FluxTextEncoders: abstractness 0.01, instability 0.00, distance 0.99 — zone of pain — concrete and depended on by 5 project(s), so it's rigid to change.
Off the main sequence: Flux2Core — Flux2Core: abstractness 0.03, instability 0.25, distance 0.72 — zone of pain — concrete and depended on by 3 project(s), so it's rigid to change.
SimpleLoRATrainer.train (cyclomatic 95) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:244— SimpleLoRATrainer.train has cyclomatic complexity 95 (threshold 15). Of this number, 89 points are the body's own statements and 6 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Flux2Pipeline.generateWithResult (cyclomatic 93) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1215— Flux2Pipeline.generateWithResult has cyclomatic complexity 93 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ImageToImage.run (cyclomatic 67) Sources/Flux2CLI/Flux2CLI.swift:486— ImageToImage.run has cyclomatic complexity 67 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TextToImage.run (cyclomatic 51) Sources/Flux2CLI/Flux2CLI.swift:125— TextToImage.run has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Flux2WeightLoader.mapBFLTransformerWeights (cyclomatic 43) Sources/Flux2Core/Loading/WeightLoader.swift:87— Flux2WeightLoader.mapBFLTransformerWeights has cyclomatic complexity 43 (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.
FluxToolsView.body (cyclomatic 33) Sources/Flux2App/Views/ContentView.swift:1231— FluxToolsView.body has cyclomatic complexity 33 (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.
TrainLoRA.runSimpleTrainer (cyclomatic 29) Sources/Flux2CLI/TrainLoRACommand.swift:638— TrainLoRA.runSimpleTrainer 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.
SimpleLoRATrainer.trainStep (cyclomatic 28) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:902— SimpleLoRATrainer.trainStep has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Flux2FusedKernels.applyRotaryEmb (cyclomatic 25) Sources/Flux2Core/Transformer/Flux2FusedKernels.swift:99— Flux2FusedKernels.applyRotaryEmb 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.
FluxToolsView.processAction (cyclomatic 23) Sources/Flux2App/Views/ContentView.swift:1456— FluxToolsView.processAction 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.
TrainLoRA.run (cyclomatic 23) Sources/Flux2CLI/TrainLoRACommand.swift:220— TrainLoRA.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.
SimpleLoRATrainer.findLoRALayer (cyclomatic 23) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1686— SimpleLoRATrainer.findLoRALayer 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.
SimpleLoRATrainer.scoreValidationImagesWithVLM (cyclomatic 22) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2072— SimpleLoRATrainer.scoreValidationImagesWithVLM 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.
Flux2Pipeline.preprocessImageForVAE (cyclomatic 20) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2323— Flux2Pipeline.preprocessImageForVAE 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.
MistralVLM.loadWeights (cyclomatic 20) Sources/FluxTextEncoders/Vision/MistralVLM.swift:704— MistralVLM.loadWeights 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.
LoRALoader.mapBFLPathToSwiftPath (cyclomatic 19) Sources/Flux2Core/LoRA/LoRALoader.swift:343— LoRALoader.mapBFLPathToSwiftPath 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.
Inpaint.run (cyclomatic 18) Sources/Flux2CLI/InpaintCommand.swift:139— Inpaint.run has cyclomatic complexity 18 (threshold 15). Of this number, 17 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TrainLoRA.printConfigSummary (cyclomatic 18) Sources/Flux2CLI/TrainLoRACommand.swift:552— TrainLoRA.printConfigSummary 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.
Flux2SubjectMask.renderInvertedMask (cyclomatic 18) Sources/Flux2Chains/Flux2SubjectMask.swift:156— Flux2SubjectMask.renderInvertedMask 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.
LoRALoader.parseAndMapWeights (cyclomatic 18) Sources/Flux2Core/LoRA/LoRALoader.swift:104— LoRALoader.parseAndMapWeights 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.
Flux2WeightLoader.mergeLoRAWeights (cyclomatic 18) Sources/Flux2Core/Loading/WeightLoader.swift:760— Flux2WeightLoader.mergeLoRAWeights 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.
Flux2Pipeline.loadTransformer (cyclomatic 17) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:483— Flux2Pipeline.loadTransformer has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Flux2Transformer2DModel.getLoRAParameters (cyclomatic 17) Sources/Flux2Core/Training/Model/LoRALinear.swift:210— Flux2Transformer2DModel.getLoRAParameters has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (Flux2Transformer2DModel.unfreezeLoRAParameters) 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.
Flux2Transformer2DModel.unfreezeLoRAParameters (cyclomatic 17) Sources/Flux2Core/Training/Model/LoRALinear.swift:304— Flux2Transformer2DModel.unfreezeLoRAParameters has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (Flux2Transformer2DModel.getLoRAParameters) 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.
Flux2TransformerBlock.callAsFunction (cyclomatic 17) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:80— Flux2TransformerBlock.callAsFunction has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: 2 other methods here (Flux2TransformerBlock.callWithKVExtraction, Flux2TransformerBlock.callWithKVCached) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
Flux2TransformerBlock.callWithKVExtraction (cyclomatic 17) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:173— Flux2TransformerBlock.callWithKVExtraction has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: 2 other methods here (Flux2TransformerBlock.callAsFunction, Flux2TransformerBlock.callWithKVCached) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
Flux2TransformerBlock.callWithKVCached (cyclomatic 17) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:253— Flux2TransformerBlock.callWithKVCached has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: 2 other methods here (Flux2TransformerBlock.callAsFunction, Flux2TransformerBlock.callWithKVExtraction) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
SimpleLoRATrainer.addGradients (cyclomatic 17) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1460— SimpleLoRATrainer.addGradients has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 3 of the 17 points are its own statements and the rest belongs to one function item inside it that branches (addRecursively). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
SimpleLoRATrainer.parseVLMScores (cyclomatic 17) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2223— SimpleLoRATrainer.parseVLMScores has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
ModelStatusBar.mistralStatusBar (cyclomatic 16) Sources/Flux2App/Views/ContentView.swift:149— ModelStatusBar.mistralStatusBar 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.
ModelStatusBar.qwen3StatusBar (cyclomatic 16) Sources/Flux2App/Views/ContentView.swift:247— ModelStatusBar.qwen3StatusBar 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.
Flux2OutpaintingChain.buildSmartMask (cyclomatic 16) Sources/Flux2Chains/Flux2OutpaintingChain.swift:398— Flux2OutpaintingChain.buildSmartMask has cyclomatic complexity 16 (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.
Flux2Pipeline.exportPrequantizedTransformer (cyclomatic 16) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:774— Flux2Pipeline.exportPrequantizedTransformer 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.
LoRATrainingConfig.estimateMemoryGB (cyclomatic 16) Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:931— LoRATrainingConfig.estimateMemoryGB has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
SimpleLoRATrainer.combineGradients::combineRecursively (cyclomatic 16) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1405— SimpleLoRATrainer.combineGradients::combineRecursively 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.
Upsample.run (cyclomatic 16) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:517— Upsample.run has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Qwen3Generator.chat (cyclomatic 16) Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:170— Qwen3Generator.chat 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.
TekkenTokenizer.loadTekkenTokenizerFromFile (cyclomatic 16) Sources/FluxTextEncoders/Tokenizer/TekkenTokenizer.swift:115— TekkenTokenizer.loadTekkenTokenizerFromFile 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.
TodoComment Sources/Flux2Core/LoRA/LoRAAdapter.swift:127— // TODO: Make scale mutable in LoRAConfig — 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.
Flux2Pipeline.generateWithResult (cognitive 194) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1215— Flux2Pipeline.generateWithResult has cognitive complexity 194 (threshold 15). Drivers by points: if/else 63 (143 pts), boolean chains 27, match/switch 4 (9 pts), ternaries 4 (8 pts), loops 3 (7 pts) (nesting depth added 93). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SimpleLoRATrainer.train (cognitive 176) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:244— SimpleLoRATrainer.train has cognitive complexity 176 (threshold 15). Drivers by points: if/else 57 (129 pts), boolean chains 27, loops 5 (8 pts), error handling 1 (5 pts), ternaries 4 (5 pts), match/switch 2 (nesting depth added 80). Of this number, 169 points are the body's own statements and 7 belong to 2 function items inside it that branch. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
ImageToImage.run (cognitive 107) Sources/Flux2CLI/Flux2CLI.swift:486— ImageToImage.run has cognitive complexity 107 (threshold 15). Drivers by points: if/else 50 (81 pts), boolean chains 11, error handling 3 (6 pts), ternaries 3 (6 pts), loops 2, match/switch 1 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TextToImage.run (cognitive 86) Sources/Flux2CLI/Flux2CLI.swift:125— TextToImage.run has cognitive complexity 86 (threshold 15). Drivers by points: if/else 35 (64 pts), boolean chains 6, error handling 3 (6 pts), loops 3 (6 pts), ternaries 2 (3 pts), match/switch 1 (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Flux2WeightLoader.mapBFLTransformerWeights (cognitive 55) Sources/Flux2Core/Loading/WeightLoader.swift:87— Flux2WeightLoader.mapBFLTransformerWeights has cognitive complexity 55 (threshold 15). Drivers by points: if/else 35 (43 pts), loops 6 (8 pts), boolean chains 4 (nesting depth added 10). 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.
TrainLoRA.runSimpleTrainer (cognitive 49) Sources/Flux2CLI/TrainLoRACommand.swift:638— TrainLoRA.runSimpleTrainer has cognitive complexity 49 (threshold 15). Drivers by points: if/else 24 (40 pts), loops 3, ternaries 1 (3 pts), match/switch 2, boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FluxToolsView.processAction (cognitive 47) Sources/Flux2App/Views/ContentView.swift:1456— FluxToolsView.processAction has cognitive complexity 47 (threshold 15). Drivers by points: if/else 9 (21 pts), ternaries 6 (18 pts), boolean chains 5, match/switch 1 (2 pts), error handling 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.
Flux2WeightLoader.mergeLoRAWeights (cognitive 47) Sources/Flux2Core/Loading/WeightLoader.swift:760— Flux2WeightLoader.mergeLoRAWeights has cognitive complexity 47 (threshold 15). Drivers by points: if/else 12 (34 pts), loops 6 (13 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.
SimpleLoRATrainer.scoreValidationImagesWithVLM (cognitive 43) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2072— SimpleLoRATrainer.scoreValidationImagesWithVLM has cognitive complexity 43 (threshold 15). Drivers by points: if/else 9 (23 pts), ternaries 4 (11 pts), boolean chains 6, loops 1 (2 pts), error handling 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FluxToolsView.body (cognitive 39) Sources/Flux2App/Views/ContentView.swift:1231— FluxToolsView.body has cognitive complexity 39 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 11, ternaries 8 (9 pts), match/switch 1 (2 pts) (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
TrainLoRA.run (cognitive 39) Sources/Flux2CLI/TrainLoRACommand.swift:220— TrainLoRA.run has cognitive complexity 39 (threshold 15). Drivers by points: if/else 13 (20 pts), ternaries 8 (16 pts), loops 1 (2 pts), error handling 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SimpleLoRATrainer.trainStep (cognitive 37) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:902— SimpleLoRATrainer.trainStep has cognitive complexity 37 (threshold 15). Drivers by points: if/else 21 (30 pts), boolean chains 6, ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LoRALoader.parseAndMapWeights (cognitive 36) Sources/Flux2Core/LoRA/LoRALoader.swift:104— LoRALoader.parseAndMapWeights has cognitive complexity 36 (threshold 15). Drivers by points: if/else 16 (28 pts), loops 3 (6 pts), boolean chains 1, ternaries 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CaptionParser.validateDataset (cognitive 34) Sources/Flux2Core/Training/Data/CaptionParser.swift:195— CaptionParser.validateDataset has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (6 pts), boolean chains 1, error handling 1 (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
Flux2Pipeline.preprocessImageForVAE (cognitive 32) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2323— Flux2Pipeline.preprocessImageForVAE has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 9, ternaries 1 (4 pts), loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MistralVLM.loadWeights (cognitive 31) Sources/FluxTextEncoders/Vision/MistralVLM.swift:704— MistralVLM.loadWeights has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 5, boolean chains 3 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Flux2FusedKernels.applyRotaryEmb (cognitive 30) Sources/Flux2Core/Transformer/Flux2FusedKernels.swift:99— Flux2FusedKernels.applyRotaryEmb has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 11 (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.
Flux2Transformer2DModel.getLoRAParameters (cognitive 30) Sources/Flux2Core/Training/Model/LoRALinear.swift:210— Flux2Transformer2DModel.getLoRAParameters has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (28 pts), loops 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Flux2Transformer2DModel.unfreezeLoRAParameters) 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.
Flux2Transformer2DModel.unfreezeLoRAParameters (cognitive 30) Sources/Flux2Core/Training/Model/LoRALinear.swift:304— Flux2Transformer2DModel.unfreezeLoRAParameters has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (28 pts), loops 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Flux2Transformer2DModel.getLoRAParameters) 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.
Flux2SubjectMask.renderInvertedMask (cognitive 29) Sources/Flux2Chains/Flux2SubjectMask.swift:156— Flux2SubjectMask.renderInvertedMask has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 3 (8 pts), boolean chains 4, match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Flux2OutpaintingChain.buildSmartMask (cognitive 28) Sources/Flux2Chains/Flux2OutpaintingChain.swift:398— Flux2OutpaintingChain.buildSmartMask has cognitive complexity 28 (threshold 15). Drivers by points: loops 10 (23 pts), if/else 5 (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.
Upsample.run (cognitive 27) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:517— Upsample.run has cognitive complexity 27 (threshold 15). Drivers by points: if/else 18 (24 pts), boolean chains 2, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Flux2InpaintCompositing.maskBoundingBox (cognitive 26) Sources/Flux2Chains/Flux2InpaintCompositing.swift:27— Flux2InpaintCompositing.maskBoundingBox has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 2 (3 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.
Flux2WeightLoader.mapDiffusersTransformerWeights (cognitive 26) Sources/Flux2Core/Loading/WeightLoader.swift:315— Flux2WeightLoader.mapDiffusersTransformerWeights has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (21 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.
SimpleLoRATrainer.findLoRALayer (cognitive 26) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1686— SimpleLoRATrainer.findLoRALayer has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (20 pts), match/switch 2 (4 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SimpleLoRATrainer.generateBaselineImages (cognitive 26) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1750— SimpleLoRATrainer.generateBaselineImages has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (18 pts), ternaries 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (SimpleLoRATrainer.generateValidationImages) 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.
SimpleLoRATrainer.generateValidationImages (cognitive 26) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1863— SimpleLoRATrainer.generateValidationImages has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (18 pts), ternaries 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (SimpleLoRATrainer.generateBaselineImages) 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.
Flux2Transformer2DModel.callAsFunction (cognitive 25) Sources/Flux2Core/Transformer/Flux2Transformer.swift:123— Flux2Transformer2DModel.callAsFunction has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 4, loops 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SimpleLoRATrainer.combineGradients::combineRecursively (cognitive 24) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1405— SimpleLoRATrainer.combineGradients::combineRecursively has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 4 (10 pts), if/else 4 (9 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Embed.run (cognitive 23) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:288— Embed.run has cognitive complexity 23 (threshold 15). Drivers by points: if/else 16 (23 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.
Qwen3Generator.chat (cognitive 23) Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:170— Qwen3Generator.chat has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 5, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TekkenTokenizer.encodeBPEChunk (cognitive 23) Sources/FluxTextEncoders/Tokenizer/TekkenTokenizer.swift:320— TekkenTokenizer.encodeBPEChunk has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 3 (5 pts), ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen35VLM.generateMultiImage (cognitive 23) Sources/FluxTextEncoders/Model/Qwen35/Qwen35VLM.swift:124— Qwen35VLM.generateMultiImage has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Flux2MaskedInpaintingChain.run (cognitive 22) Sources/Flux2Chains/Flux2MaskedInpaintingChain.swift:301— Flux2MaskedInpaintingChain.run has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 4, ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LoRALoader.mapBFLPathToSwiftPath (cognitive 22) Sources/Flux2Core/LoRA/LoRALoader.swift:343— LoRALoader.mapBFLPathToSwiftPath has cognitive complexity 22 (threshold 15). Drivers by points: if/else 18 (22 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
Flux2Transformer2DModel.setAllLoRAScales (cognitive 22) Sources/Flux2Core/Training/Model/LoRALinear.swift:368— Flux2Transformer2DModel.setAllLoRAScales has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Flux2Transformer2DModel.restoreLoRAScales) 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.
Flux2Transformer2DModel.restoreLoRAScales (cognitive 22) Sources/Flux2Core/Training/Model/LoRALinear.swift:393— Flux2Transformer2DModel.restoreLoRAScales has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Flux2Transformer2DModel.setAllLoRAScales) 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.
SimpleLoRATrainer.addGradients::addRecursively (cognitive 22) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1466— SimpleLoRATrainer.addGradients::addRecursively has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 4 (10 pts), if/else 3 (7 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
TekkenTokenizer.loadTekkenTokenizerFromFile (cognitive 22) Sources/FluxTextEncoders/Tokenizer/TekkenTokenizer.swift:115— TekkenTokenizer.loadTekkenTokenizerFromFile has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (5 pts), match/switch 1 (4 pts), error handling 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Inpaint.run (cognitive 21) Sources/Flux2CLI/InpaintCommand.swift:139— Inpaint.run has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (17 pts), ternaries 2, boolean chains 1, loops 1 (nesting depth added 4). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ProfileCompare.run (cognitive 21) Sources/Flux2CLI/ProfileCommand.swift:334— ProfileCompare.run has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 4 (6 pts), boolean chains 3, ternaries 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FluxTextEncoders.sampleToken (cognitive 21) Sources/FluxTextEncoders/FluxTextEncoders.swift:1027— FluxTextEncoders.sampleToken has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MistralGenerator.chat (cognitive 21) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:233— MistralGenerator.chat has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 4, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Flux2TransformerBlock.callAsFunction (cognitive 20) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:80— Flux2TransformerBlock.callAsFunction has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12, boolean chains 8. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: 2 other methods here (Flux2TransformerBlock.callWithKVExtraction, Flux2TransformerBlock.callWithKVCached) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
Flux2TransformerBlock.callWithKVExtraction (cognitive 20) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:173— Flux2TransformerBlock.callWithKVExtraction has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12, boolean chains 8. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: 2 other methods here (Flux2TransformerBlock.callAsFunction, Flux2TransformerBlock.callWithKVCached) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
Flux2TransformerBlock.callWithKVCached (cognitive 20) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:253— Flux2TransformerBlock.callWithKVCached has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12, boolean chains 8. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: 2 other methods here (Flux2TransformerBlock.callAsFunction, Flux2TransformerBlock.callWithKVExtraction) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
SimpleLoRATrainer.parseVLMScores (cognitive 20) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2223— SimpleLoRATrainer.parseVLMScores has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 10, if/else 8 (10 pts) (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
Chat.run (cognitive 20) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:156— Chat.run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MistralVLM.load (cognitive 20) Sources/FluxTextEncoders/Vision/MistralVLM.swift:590— MistralVLM.load has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 6, loops 2 (3 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImageGenerationViewModel.generate (cognitive 19) Sources/Flux2App/ViewModels/ImageGenerationViewModel.swift:202— ImageGenerationViewModel.generate has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 4 (12 pts), if/else 4 (6 pts), error handling 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Flux2InpaintCompositing.composite (cognitive 19) Sources/Flux2Chains/Flux2InpaintCompositing.swift:121— Flux2InpaintCompositing.composite has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 7, loops 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Flux2Pipeline.loadTransformer (cognitive 19) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:483— Flux2Pipeline.loadTransformer has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 2, error handling 1 (2 pts), match/switch 1 (2 pts), ternaries 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Qwen3Generator.generate (cognitive 19) Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:40— Qwen3Generator.generate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TekkenTokenizer.decode (cognitive 19) Sources/FluxTextEncoders/Tokenizer/TekkenTokenizer.swift:394— TekkenTokenizer.decode has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (16 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.
TrainLoRA.printConfigSummary (cognitive 18) Sources/Flux2CLI/TrainLoRACommand.swift:552— TrainLoRA.printConfigSummary has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12, ternaries 6. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
VLMProviderOptions.loadIfRequested (cognitive 18) Sources/Flux2CLI/VLMProviderOptions.swift:65— VLMProviderOptions.loadIfRequested has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), ternaries 1 (2 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AutoencoderKLFlux2.decodeTiled (cognitive 18) Sources/Flux2Core/VAE/AutoencoderKL.swift:176— AutoencoderKLFlux2.decodeTiled has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 4 (12 pts), loops 4 (6 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CaptionParser.parseJSONLine (cognitive 18) Sources/Flux2Core/Training/Data/CaptionParser.swift:44— CaptionParser.parseJSONLine has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 3, loops 1, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
MLXProfiler.generateReport (cognitive 18) Sources/Flux2Core/Utils/Flux2Profiler.swift:18— MLXProfiler.generateReport has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 2 (4 pts), loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen3VLGenerator.generate (cognitive 18) Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:31— Qwen3VLGenerator.generate has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen3VLForCausalLM.load (cognitive 18) Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:298— Qwen3VLForCausalLM.load has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModelStatusBar.mistralStatusBar (cognitive 17) Sources/Flux2App/Views/ContentView.swift:149— ModelStatusBar.mistralStatusBar has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 8, if/else 7, boolean chains 2. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LoRATrainingConfig.suggestAdjustments (cognitive 17) Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:984— LoRATrainingConfig.suggestAdjustments 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.
MistralGenerator.generate (cognitive 17) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:94— MistralGenerator.generate has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen35VLM.load (cognitive 17) Sources/FluxTextEncoders/Model/Qwen35/Qwen35VLM.swift:286— Qwen35VLM.load has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (7 pts), loops 3 (5 pts), ternaries 1 (3 pts), error handling 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen3ChatView.body (cognitive 16) Sources/Flux2App/Views/ContentView.swift:2472— Qwen3ChatView.body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 3 (6 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CompareEncoders.run (cognitive 16) Sources/Flux2CLI/CompareEncoders.swift:57— CompareEncoders.run has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (10 pts), ternaries 4 (5 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.
LatentCache.preEncodeDataset (cognitive 16) Sources/Flux2Core/Training/Data/LatentCache.swift:192— LatentCache.preEncodeDataset has cognitive complexity 16 (threshold 15). Drivers by points: loops 6 (13 pts), if/else 2 (3 pts) (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
LatentCache.preEncodeControlImages (cognitive 16) Sources/Flux2Core/Training/Data/LatentCache.swift:340— LatentCache.preEncodeControlImages has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2, boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FluxTextEncoders.analyzeImage (cognitive 16) Sources/FluxTextEncoders/FluxTextEncoders.swift:843— FluxTextEncoders.analyzeImage has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 2, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D4 · Code Duplication· Near-duplicate member family (4 members, 46 shared lines) · ×1
Near-duplicate member family (4 members, 46 shared lines) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:94— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:94-225 | Sources/FluxTextEncoders/Generation/MistralGenerator.swift:233-362 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:40-161 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:170-290 — These 4 members are variants of one another: a block of 46 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.
Near-duplicate member pair (101 shared lines) Sources/Flux2CLI/Flux2CLI.swift:125— Sources/Flux2CLI/Flux2CLI.swift:125-373 | Sources/Flux2CLI/Flux2CLI.swift:486-825 — These two members are variants of one another: 101 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (52 shared lines) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1750— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1750-1856 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1863-1989 — These two members are variants of one another: 52 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (34 shared lines) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1398— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1398-1457 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1460-1512 — These two members are variants of one another: 34 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (5 members, 50+ identical tokens) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:92— Sources/FluxEncodersCLI/FluxEncodersCLI.swift:92-140 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:156-249 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:288-455 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:517-649 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:671-730 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Edited copy of a member (76 corresponding lines) · ×1
Edited copy of a member (76 corresponding lines) Sources/Flux2App/Views/ImageToImageView.swift:249— Sources/Flux2App/Views/ImageToImageView.swift:249-324 | Sources/Flux2App/Views/TextToImageView.swift:198-293 — These two members are one piece of code written twice and then edited apart: 76 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (93 corresponding lines) · ×1
Edited copy of a member (93 corresponding lines) Sources/Flux2App/Views/ImageToImageView.swift:129— Sources/Flux2App/Views/ImageToImageView.swift:129-221 | Sources/Flux2App/Views/TextToImageView.swift:61-172 — These two members are one piece of code written twice and then edited apart: 93 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (68 corresponding lines) · ×1
Edited copy of a member (68 corresponding lines) Sources/Flux2Core/Transformer/Flux2Attention.swift:245— Sources/Flux2Core/Transformer/Flux2Attention.swift:245-334 | Sources/Flux2Core/Transformer/Flux2Attention.swift:347-414 — These two members are one piece of code written twice and then edited apart: 68 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 75+ corresponding lines) · ×1
Edited copies of one member (3 members, 75+ corresponding lines) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:80— Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:80-168 | Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:173-250 | Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:253-327 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 75 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (58 corresponding lines) · ×1
Edited copy of a member (58 corresponding lines) Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:138— Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:138-200 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:212-269 — These two members are one piece of code written twice and then edited apart: 58 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (79 corresponding lines) · ×1
Edited copy of a member (79 corresponding lines) Sources/Flux2App/Views/ContentView.swift:149— Sources/Flux2App/Views/ContentView.swift:149-242 | Sources/Flux2App/Views/ContentView.swift:247-325 — These two members are one piece of code written twice and then edited apart: 79 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (72 corresponding lines) · ×1
Edited copy of a member (72 corresponding lines) Sources/Flux2App/Views/ImageToImageView.swift:411— Sources/Flux2App/Views/ImageToImageView.swift:411-487 | Sources/Flux2App/Views/TextToImageView.swift:346-417 — These two members are one piece of code written twice and then edited apart: 72 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (40 corresponding lines) · ×1
Edited copy of a member (40 corresponding lines) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1268— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1268-1313 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1318-1357 — These two members are one piece of code written twice and then edited apart: 40 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (88 corresponding lines) · ×1
Edited copy of a member (88 corresponding lines) Sources/Flux2Core/Transformer/Flux2Transformer.swift:346— Sources/Flux2Core/Transformer/Flux2Transformer.swift:346-443 | Sources/Flux2Core/Transformer/Flux2Transformer.swift:459-546 — These two members are one piece of code written twice and then edited apart: 88 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (70 corresponding lines) · ×1
Edited copy of a member (70 corresponding lines) Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:50— Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:50-134 | Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift:44-113 — These two members are one piece of code written twice and then edited apart: 70 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (59 corresponding lines) · ×1
Edited copy of a member (59 corresponding lines) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:109— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:109-179 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:115-173 — These two members are one piece of code written twice and then edited apart: 59 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (50 corresponding lines) · ×1
Edited copy of a member (50 corresponding lines) Sources/Flux2App/Views/ContentView.swift:1994— Sources/Flux2App/Views/ContentView.swift:1994-2043 | Sources/Flux2App/Views/ContentView.swift:2095-2151 — These two members are one piece of code written twice and then edited apart: 50 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 38+ corresponding lines) · ×1
Edited copies of one member (3 members, 38+ corresponding lines) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:205— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:205-253 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:304-347 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:467-504 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 38 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (29 corresponding lines) · ×1
Edited copy of a member (29 corresponding lines) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2446— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2446-2478 | Sources/Flux2Core/Training/Data/LatentCache.swift:462-490 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (34 corresponding lines) · ×1
Edited copy of a member (34 corresponding lines) Sources/Flux2Core/Pipeline/Flux2Pipeline+ChainHelpers.swift:164— Sources/Flux2Core/Pipeline/Flux2Pipeline+ChainHelpers.swift:164-197 | Sources/Flux2Core/Pipeline/Flux2Pipeline+ChainHelpers.swift:199-236 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (23 corresponding lines) · ×1
Edited copy of a member (23 corresponding lines) Sources/FluxTextEncoders/Model/Qwen35/Qwen35Attention.swift:35— Sources/FluxTextEncoders/Model/Qwen35/Qwen35Attention.swift:35-63 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLAttention.swift:38-60 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (41 corresponding lines) · ×1
Edited copy of a member (41 corresponding lines) Sources/Flux2App/Views/ImageToImageView.swift:366— Sources/Flux2App/Views/ImageToImageView.swift:366-406 | Sources/Flux2App/Views/TextToImageView.swift:298-341 — These two members are one piece of code written twice and then edited apart: 41 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (32 corresponding lines) · ×1
Edited copy of a member (32 corresponding lines) Sources/Flux2App/Views/ContentView.swift:2052— Sources/Flux2App/Views/ContentView.swift:2052-2083 | Sources/Flux2App/Views/ContentView.swift:2160-2200 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (27 corresponding lines) · ×1
Edited copy of a member (27 corresponding lines) Sources/Flux2CLI/TrainLoRACommand.swift:438— Sources/Flux2CLI/TrainLoRACommand.swift:438-464 | Sources/Flux2CLI/TrainLoRACommand.swift:506-550 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (28 corresponding lines) · ×1
Edited copy of a member (28 corresponding lines) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:912— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:912-941 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1048-1075 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (25 corresponding lines) · ×1
Edited copy of a member (25 corresponding lines) Sources/Flux2Core/Loading/KleinTextEncoder.swift:165— Sources/Flux2Core/Loading/KleinTextEncoder.swift:165-189 | Sources/Flux2Core/Loading/MistralEncoder.swift:409-433 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 31+ corresponding lines) · ×1
Edited copies of one member (3 members, 31+ corresponding lines) Sources/Flux2App/ViewModels/ModelManager.swift:221— Sources/Flux2App/ViewModels/ModelManager.swift:221-251 | Sources/Flux2App/ViewModels/ModelManager.swift:326-356 | Sources/Flux2App/ViewModels/ModelManager.swift:552-582 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 31 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 16+ corresponding lines) · ×1
Edited copies of one member (3 members, 16+ corresponding lines) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2297— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2297-2320 | Sources/FluxTextEncoders/FluxTextEncoders.swift:711-729 | Sources/FluxTextEncoders/FluxTextEncoders.swift:731-746 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 16 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 30+ corresponding lines) · ×1
Edited copies of one member (3 members, 30+ corresponding lines) Sources/Flux2Core/Transformer/Flux2SingleBlock.swift:59— Sources/Flux2Core/Transformer/Flux2SingleBlock.swift:59-98 | Sources/Flux2Core/Transformer/Flux2SingleBlock.swift:135-164 | Sources/Flux2Core/Transformer/Flux2SingleBlock.swift:253-288 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 30 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (15 corresponding lines) · ×1
Edited copy of a member (15 corresponding lines) Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:127— Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:127-141 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:532-554 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (6 members, 17+ corresponding lines) · ×1
Edited copies of one member (6 members, 17+ corresponding lines) Sources/Flux2Core/Pipeline/LatentUtils.swift:119— Sources/Flux2Core/Pipeline/LatentUtils.swift:119-142 | Sources/Flux2Core/Pipeline/LatentUtils.swift:152-177 | Sources/Flux2Core/Pipeline/LatentUtils.swift:186-212 | Sources/Flux2Core/Pipeline/LatentUtils.swift:223-246 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1225-1241 | Sources/Flux2Core/VAE/AutoencoderKL.swift:333-362 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 17 lines, 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 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. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (20 corresponding lines) · ×1
Edited copy of a member (20 corresponding lines) Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:47— Sources/Flux2Core/Training/Optimizer/ResumableAdamW.swift:47-66 | Sources/Flux2Core/Training/Optimizer/ResumableLion.swift:48-69 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 18+ corresponding lines) · ×1
Edited copies of one member (3 members, 18+ corresponding lines) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:240— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:240-272 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:161-178 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:224-242 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 18 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (39 corresponding lines) · ×1
Edited copy of a member (39 corresponding lines) Sources/Flux2App/Views/ImageToImageView.swift:20— Sources/Flux2App/Views/ImageToImageView.swift:20-68 | Sources/Flux2App/Views/TextToImageView.swift:18-56 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (4 members, 17+ corresponding lines) · ×1
Edited copies of one member (4 members, 17+ corresponding lines) Sources/FluxTextEncoders/FluxTextEncoders.swift:428— Sources/FluxTextEncoders/FluxTextEncoders.swift:428-446 | Sources/FluxTextEncoders/FluxTextEncoders.swift:449-465 | Sources/FluxTextEncoders/FluxTextEncoders.swift:468-485 | Sources/FluxTextEncoders/FluxTextEncoders.swift:494-512 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 17 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (12 corresponding lines) · ×1
Edited copy of a member (12 corresponding lines) Sources/FluxTextEncoders/Model/Qwen35/Qwen35MRoPE.swift:28— Sources/FluxTextEncoders/Model/Qwen35/Qwen35MRoPE.swift:28-39 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLMRoPE.swift:31-43 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 12+ corresponding lines) · ×1
Edited copies of one member (3 members, 12+ corresponding lines) Sources/FluxTextEncoders/Model/MistralMLP.swift:25— Sources/FluxTextEncoders/Model/MistralMLP.swift:25-37 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3MLP.swift:27-40 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLMLP.swift:26-37 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 12 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (21 corresponding lines) · ×1
Edited copy of a member (21 corresponding lines) Sources/FluxTextEncoders/Model/MistralModel.swift:325— Sources/FluxTextEncoders/Model/MistralModel.swift:325-347 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:373-393 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 22+ corresponding lines) · ×1
Edited copies of one member (3 members, 22+ corresponding lines) Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:748— Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:748-769 | Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:772-793 | Sources/Flux2Core/Training/Configuration/LoRATrainingConfig.swift:796-817 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 22 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (19 corresponding lines) · ×1
Edited copy of a member (19 corresponding lines) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:365— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:365-383 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:297-317 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (4 members, 16+ corresponding lines) · ×1
Edited copies of one member (4 members, 16+ corresponding lines) Sources/FluxTextEncoders/Model/MistralModel.swift:82— Sources/FluxTextEncoders/Model/MistralModel.swift:82-97 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:41-56 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:59-74 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:45-60 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 16 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (13 corresponding lines) · ×1
Edited copy of a member (13 corresponding lines) Sources/FluxGemma4VLM/FluxGemma4VLM.swift:26— Sources/FluxGemma4VLM/FluxGemma4VLM.swift:26-39 | Sources/FluxGemma4VLM/FluxGemma4VLM.swift:45-57 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 20+ corresponding lines) · ×1
Edited copies of one member (3 members, 20+ corresponding lines) Sources/FluxTextEncoders/Model/MistralModel.swift:220— Sources/FluxTextEncoders/Model/MistralModel.swift:220-239 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:275-294 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:244-265 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 20 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (17 corresponding lines) · ×1
Edited copy of a member (17 corresponding lines) Sources/Flux2Core/Pipeline/LatentUtils.swift:23— Sources/Flux2Core/Pipeline/LatentUtils.swift:23-42 | Sources/Flux2Core/Pipeline/LatentUtils.swift:52-68 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (10 corresponding lines) · ×1
Edited copy of a member (10 corresponding lines) Sources/FluxTextEncoders/FluxTextEncoders.swift:100— Sources/FluxTextEncoders/FluxTextEncoders.swift:100-109 | Sources/FluxTextEncoders/FluxTextEncoders.swift:156-165 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 4+ corresponding lines) · ×1
Edited copies of one member (3 members, 4+ corresponding lines) Sources/FluxTextEncoders/Model/MistralModel.swift:242— Sources/FluxTextEncoders/Model/MistralModel.swift:242-245 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:297-300 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:267-270 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (3 corresponding lines) · ×1
Edited copy of a member (3 corresponding lines) Sources/Flux2Core/Loading/ModelDownloader.swift:232— Sources/Flux2Core/Loading/ModelDownloader.swift:232-237 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:200-202 — These two members are one piece of code written twice and then edited apart: 3 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (59–61 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:129— Sources/Flux2App/Views/ImageToImageView.swift:129-187 | Sources/Flux2App/Views/TextToImageView.swift:61-121 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/Flux2App/Views/ImageToImageView.swift:129` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `spacing` to `12` in one and `16` 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 (48–55 lines × 3) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:110— Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:110-164 | Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:199-247 | Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:277-324 — 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/Flux2Core/Transformer/Flux2TransformerBlock.swift:110` 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 (52–55 lines × 2) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1684— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1684-1735 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1806-1860 — both copies are in the same file, so extract the 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/Flux2Core/Pipeline/Flux2Pipeline.swift:1684` 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 (48–50 lines × 2) Sources/Flux2CLI/Flux2CLI.swift:145— Sources/Flux2CLI/Flux2CLI.swift:145-194 | Sources/Flux2CLI/Flux2CLI.swift:504-551 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (44–50 lines × 2) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:110— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:110-159 | Sources/FluxTextEncoders/Generation/MistralGenerator.swift:248-291 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Generation/MistralGenerator.swift:110` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (45 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:492— Sources/Flux2App/Views/ImageToImageView.swift:492-536 | Sources/Flux2App/Views/TextToImageView.swift:422-466 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (42–44 lines × 2) Sources/FluxTextEncoders/Model/MistralModel.swift:99— Sources/FluxTextEncoders/Model/MistralModel.swift:99-142 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:58-99 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/MistralModel.swift:99` 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 (38–41 lines × 2) Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:58— Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:58-98 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:187-224 — both copies are in the same file, so extract the 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/FluxTextEncoders/Generation/Qwen3Generator.swift:58` 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 (25–37 lines × 4) Sources/FluxTextEncoders/Model/MistralAttention.swift:434— Sources/FluxTextEncoders/Model/MistralAttention.swift:434-470 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:129-159 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35Attention.swift:109-133 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLAttention.swift:95-122 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralAttention.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. 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 (33–35 lines × 2) Sources/Flux2Core/Transformer/Flux2Attention.swift:251— Sources/Flux2Core/Transformer/Flux2Attention.swift:251-285 | Sources/Flux2Core/Transformer/Flux2Attention.swift:353-385 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (35 lines × 2) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:388— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:388-422 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:322-356 — before extracting anything, compare `Sources/FluxTextEncoders/Generation/MistralGenerator.swift` and `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (32–34 lines × 2) Sources/Flux2Core/Loading/MistralEncoder.swift:107— Sources/Flux2Core/Loading/MistralEncoder.swift:107-140 | Sources/Flux2Core/Loading/MistralEncoder.swift:338-369 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Loading/MistralEncoder.swift:107` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (28–34 lines × 2) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:146— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:146-179 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:146-173 — before extracting anything, compare `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` and `Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 195 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:146` 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (33 lines × 2) Sources/Flux2CLI/Flux2CLI.swift:269— Sources/Flux2CLI/Flux2CLI.swift:269-301 | Sources/Flux2CLI/Flux2CLI.swift:690-722 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (32 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:442— Sources/Flux2App/Views/ImageToImageView.swift:442-473 | Sources/Flux2App/Views/TextToImageView.swift:372-403 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/Flux2App/Views/ImageToImageView.swift:442` 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/Flux2App/Views/TextToImageView.swift:370` calls `help` and `Sources/Flux2App/Views/ImageToImageView.swift:440` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (21–29 lines × 3) Sources/FluxTextEncoders/Model/MistralModel.swift:165— Sources/FluxTextEncoders/Model/MistralModel.swift:165-193 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:193-214 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:184-204 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/MistralModel.swift:165` 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (15–29 lines × 3) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:240— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:240-268 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift:161-176 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:224-238 — before extracting anything, compare `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` and `Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 195 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:240` 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 (26–29 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1765— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1765-1793 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1889-1914 — both copies are in the same file, so extract the 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1765` 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 (49–53 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2494— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2494-2546 | scripts/fix_learning_curve.swift:189-237 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2494` 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 (25–26 lines × 4) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:168— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:168-193 | Sources/FluxTextEncoders/Generation/MistralGenerator.swift:300-325 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:105-130 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:231-255 — before extracting anything, compare `Sources/FluxTextEncoders/Generation/MistralGenerator.swift` and `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/Generation/MistralGenerator.swift:168` 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 (21–25 lines × 4) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:128— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:128-152 | Sources/FluxTextEncoders/Generation/MistralGenerator.swift:264-285 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:70-91 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:198-218 — before extracting anything, compare `Sources/FluxTextEncoders/Generation/MistralGenerator.swift` and `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/Generation/MistralGenerator.swift:128` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–25 lines × 2) Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:50— Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:50-74 | Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift:44-65 — before extracting anything, compare `Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift` and `Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:50` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:75` calls `log` and `Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift:66` 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 (23–24 lines × 2) Sources/Flux2App/Views/ImageToImageView.swift:384— Sources/Flux2App/Views/ImageToImageView.swift:384-406 | Sources/Flux2App/Views/TextToImageView.swift:318-341 — before extracting anything, compare `Sources/Flux2App/Views/ImageToImageView.swift` and `Sources/Flux2App/Views/TextToImageView.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 270 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/Flux2App/Views/ImageToImageView.swift:384` 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 (18–23 lines × 3) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1698— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1698-1715 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1821-1840 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2055-2077 — 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/Flux2Core/Pipeline/Flux2Pipeline.swift:1698` 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/Flux2Core/Pipeline/Flux2Pipeline.swift:2078` calls `verbose` and `Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1716` 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 (23 lines × 2) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:118— Sources/FluxEncodersCLI/FluxEncodersCLI.swift:118-140 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:708-730 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxEncodersCLI/FluxEncodersCLI.swift:118` 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 (17–23 lines × 2) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:119— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:119-141 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:127-143 — before extracting anything, compare `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` and `Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 195 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:119` 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/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:125` calls `textOnlyPositionIds` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:116` 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 (16–21 lines × 3) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1681— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1681-1696 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1803-1819 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2033-2053 — 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/Flux2Core/Pipeline/Flux2Pipeline.swift:1681` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20 lines × 2) Sources/Flux2CLI/Flux2CLI.swift:197— Sources/Flux2CLI/Flux2CLI.swift:197-216 | Sources/Flux2CLI/Flux2CLI.swift:652-671 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (37–38 lines × 2) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1568— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1568-1604 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1936-1973 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16–20 lines × 2) Sources/Flux2Core/Training/LoRATrainingHelper.swift:160— Sources/Flux2Core/Training/LoRATrainingHelper.swift:160-179 | Sources/Flux2Core/Training/LoRATrainingHelper.swift:530-545 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Training/LoRATrainingHelper.swift:160` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–20 lines × 2) Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:104— Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:104-123 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:256-269 — both copies are in the same file, so extract the 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/Flux2Core/Transformer/Flux2ParallelAttention.swift:104` 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16–19 lines × 2) Sources/Flux2Core/Loading/WeightLoader.swift:605— Sources/Flux2Core/Loading/WeightLoader.swift:605-623 | Sources/Flux2Core/Loading/WeightLoader.swift:673-688 — both copies are in the same file, so extract the 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/Flux2Core/Loading/WeightLoader.swift:605` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–18 lines × 3) Sources/FluxTextEncoders/Model/MistralModel.swift:131— Sources/FluxTextEncoders/Model/MistralModel.swift:131-148 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:88-105 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:95-111 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/MistralModel.swift:131` 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (16–18 lines × 2) Sources/FluxTextEncoders/Vision/Qwen35ImageProcessor.swift:58— Sources/FluxTextEncoders/Vision/Qwen35ImageProcessor.swift:58-75 | Sources/FluxTextEncoders/Vision/Qwen35ImageProcessor.swift:122-137 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16–17 lines × 3) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:366— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:366-382 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:419-435 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:521-536 — 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:366` 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 (3–17 lines × 3) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1297— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1297-1313 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1341-1357 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1522-1524 — 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:1297` 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. 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–17 lines × 2) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:400— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:400-416 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:381-393 — before extracting anything, compare `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` and `Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 195 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:400` 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 × 3) Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:80— Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:80-101 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:149-170 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:222-243 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10–16 lines × 3) Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:89— Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:89-104 | Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:182-192 | Sources/Flux2Core/Transformer/Flux2TransformerBlock.swift:262-271 — 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/Flux2Core/Transformer/Flux2TransformerBlock.swift:89` 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–16 lines × 3) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:404— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:404-418 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:338-352 | Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:132-147 — before extracting anything, compare `Sources/FluxTextEncoders/Generation/MistralGenerator.swift` and `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/Generation/MistralGenerator.swift:404` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. 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 (16 lines × 3) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:215— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:215-230 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:312-327 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:474-489 — 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:215` 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:214` calls `ensureTekkenJson` and `Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:311` 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 × 4) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1716— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1716-1730 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1841-1855 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1873-1887 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:2081-2095 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (15 lines × 3) Sources/Flux2CLI/InpaintCommand.swift:281— Sources/Flux2CLI/InpaintCommand.swift:281-295 | Sources/Flux2CLI/MaskSubjectCommand.swift:72-86 | Sources/Flux2CLI/OutpaintCommand.swift:143-157 — before extracting anything, compare `Sources/Flux2CLI/InpaintCommand.swift` and `Sources/Flux2CLI/OutpaintCommand.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (12–14 lines × 2) Sources/Flux2Core/Training/Data/LatentCache.swift:447— Sources/Flux2Core/Training/Data/LatentCache.swift:447-458 | Sources/Flux2Core/Training/LoRATrainingHelper.swift:332-345 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (13–14 lines × 2) Sources/Flux2Core/Transformer/Flux2Attention.swift:424— Sources/Flux2Core/Transformer/Flux2Attention.swift:424-437 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:274-286 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:274` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11–13 lines × 2) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:414— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:414-426 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:557-567 — both copies are in the same file, so extract the 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:414` 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 × 4) Sources/Flux2Core/Transformer/Flux2Attention.swift:445— Sources/Flux2Core/Transformer/Flux2Attention.swift:445-456 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:321-332 | Sources/Flux2Core/Transformer/Flux2ParallelAttention.swift:446-457 | Sources/Flux2Core/Transformer/Flux2RoPE.swift:220-231 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (12 lines × 3) Sources/FluxTextEncoders/Model/MistralModel.swift:111— Sources/FluxTextEncoders/Model/MistralModel.swift:111-127 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:70-84 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift:80-91 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxTextEncoders/Model/MistralModel.swift:111` 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 (19–20 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2235— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2235-2253 | Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2261-2280 — both copies are in the same file, so extract the 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/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2235` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2255` calls `log` and `Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2280` 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 × 4) Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:966— Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:966-976 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1009-1019 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1082-1092 | Sources/Flux2Core/Pipeline/Flux2Pipeline.swift:1125-1135 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7–11 lines × 3) Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:108— Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift:108-118 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35Attention.swift:93-99 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLAttention.swift:79-88 — before extracting anything, compare `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Attention.swift` and `Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLAttention.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 77 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (2–11 lines × 3) Sources/Flux2Core/LoRA/LoRALoader.swift:259— Sources/Flux2Core/LoRA/LoRALoader.swift:259-267 | Sources/Flux2Core/Loading/WeightLoader.swift:404-414 | Sources/Flux2Core/Loading/WeightLoader.swift:508-509 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (9–11 lines × 2) Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2551— Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2551-2561 | scripts/fix_learning_curve.swift:239-247 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (7–10 lines × 2) Sources/Flux2Core/Training/Data/LatentCache.swift:308— Sources/Flux2Core/Training/Data/LatentCache.swift:308-314 | Sources/Flux2Core/Training/Data/LatentCache.swift:414-423 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8–9 lines × 4) Sources/Flux2Core/Loading/WeightLoader.swift:31— Sources/Flux2Core/Loading/WeightLoader.swift:31-39 | Sources/FluxTextEncoders/Loading/TextEncoderWeightLoader.swift:30-37 | Sources/FluxTextEncoders/Model/MistralModel.swift:307-314 | Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:363-370 — before extracting anything, compare `Sources/FluxTextEncoders/Model/MistralModel.swift` and `Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 169 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/Flux2Core/Loading/WeightLoader.swift:31` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–8 lines × 4) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:364— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:364-371 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:519-525 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:631-636 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:644-649 — 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:364` 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 × 7) Sources/FluxEncodersCLI/FluxEncodersCLI.swift:106— Sources/FluxEncodersCLI/FluxEncodersCLI.swift:106-112 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:170-176 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:310-316 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:371-377 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:547-553 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:561-567 | Sources/FluxEncodersCLI/FluxEncodersCLI.swift:691-697 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/FluxEncodersCLI/FluxEncodersCLI.swift:106` 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 (3–7 lines × 3) Sources/FluxTextEncoders/Model/Qwen3/Qwen3MLP.swift:28— Sources/FluxTextEncoders/Model/Qwen3/Qwen3MLP.swift:28-36 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35MLP.swift:20-22 | Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLMLP.swift:27-33 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `Qwen3TextConfig` in one and `Qwen3VLTextConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/FluxTextEncoders/Model/Qwen3/Qwen3MLP.swift:37` calls `ModuleInfo`, `Linear` and `Sources/FluxTextEncoders/Model/Qwen35/Qwen35MLP.swift:23` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 6) Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:366— Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:366-375 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:419-428 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:521-529 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:561-569 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:633-638 | Sources/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:646-651 — 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/FluxTextEncoders/Loading/TextEncoderModelDownloader.swift:366` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (6 lines × 3) Sources/FluxTextEncoders/Vision/MistralVLM.swift:267— Sources/FluxTextEncoders/Vision/MistralVLM.swift:267-272 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:273-278 | Sources/FluxTextEncoders/Vision/MistralVLM.swift:279-284 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 4) Sources/FluxTextEncoders/Generation/MistralGenerator.swift:438— Sources/FluxTextEncoders/Generation/MistralGenerator.swift:438-453 | Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:426-440 | Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift:151-155 | Sources/FluxTextEncoders/Model/Qwen35/Qwen35VLM.swift:275-279 — before extracting anything, compare `Sources/FluxTextEncoders/Generation/MistralGenerator.swift` and `Sources/FluxTextEncoders/Generation/Qwen3Generator.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 158 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `Sources/FluxTextEncoders/Generation/MistralGenerator.swift:438` 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 `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (8 lines × 6) Sources/Flux2Core/Configuration/ModelRegistry.swift:260— Sources/Flux2Core/Configuration/ModelRegistry.swift:260-272 | Sources/Flux2Core/Configuration/QuantizationConfig.swift:23-30 | Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:35-42 | Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:44-51 | Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:63-70 | Sources/FluxTextEncoders/Configuration/TextEncoderModelRegistry.swift:73-84 — 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.
Duplicated block (16 lines × 2) Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:143— Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift:143-162 | Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift:116-131 — before extracting anything, compare `Sources/FluxTextEncoders/Embeddings/KleinEmbeddingExtractor.swift` and `Sources/FluxTextEncoders/Embeddings/KleinVLEmbeddingExtractor.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
No structured logging — No logging or diagnostics emission found. This repository ships a binary its users launch rather than a service you operate, so there is no operator to page — but when a run fails on a user's machine, neither they nor you have anything to read.
Duplicated predicate Sources/FluxTextEncoders/FluxTextEncoders.swift:828— `FluxProfiler.shared.isEnabled || ProcessInfo.processInfo.environment["VLM_DEBUG"] != nil` appears character-identically in 2 files — Sources/FluxTextEncoders/FluxTextEncoders.swift, Sources/FluxTextEncoders/Vision/MistralVLM.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift:149— `layerSet.contains(layerIdx) || (memoryConfig.evalFrequency > 0 && (i + 1) % memoryConfig.evalFrequency == 0)` appears character-identically in 2 files — Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift, Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Sources/FluxTextEncoders/Model/MistralModel.swift:131— `memoryConfig.evalFrequency > 0 && (i + 1) % memoryConfig.evalFrequency == 0` appears character-identically in 6 files — Sources/FluxTextEncoders/Model/MistralModel.swift, Sources/FluxTextEncoders/Model/Qwen3/Qwen3Model.swift, Sources/FluxTextEncoders/Model/Qwen35/Qwen35Model.swift, Sources/FluxTextEncoders/Model/Qwen3VL/Qwen3VLModel.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Sources/FluxTextEncoders/Generation/Qwen3Generator.swift:94— `nextToken == eosTokenId || nextToken == padTokenId` appears character-identically in 2 files — Sources/FluxTextEncoders/Generation/Qwen3Generator.swift, Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Sources/FluxTextEncoders/Generation/MistralGenerator.swift:399— `repetitionPenalty != 1.0 && !generatedTokens.isEmpty` appears character-identically in 3 files — Sources/FluxTextEncoders/Generation/MistralGenerator.swift, Sources/FluxTextEncoders/Generation/Qwen3Generator.swift, Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Sources/FluxTextEncoders/Generation/MistralGenerator.swift:328— `stream && hasCallback && !pendingTokens.isEmpty` appears character-identically in 2 files — Sources/FluxTextEncoders/Generation/MistralGenerator.swift, Sources/FluxTextEncoders/Generation/Qwen3Generator.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Sources/FluxTextEncoders/FluxTextEncoders.swift:1046— `tokenId >= 0 && tokenId < logitsArray.count` appears character-identically in 4 files — Sources/FluxTextEncoders/FluxTextEncoders.swift, Sources/FluxTextEncoders/Generation/MistralGenerator.swift, Sources/FluxTextEncoders/Generation/Qwen3Generator.swift, Sources/FluxTextEncoders/Generation/Qwen3VLGenerator.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Sources/Flux2App/Views/ImageToImageView.swift:168— `viewModel.selectedModel != .klein9B || quant == .bf16` appears character-identically in 2 files — Sources/Flux2App/Views/ImageToImageView.swift, Sources/Flux2App/Views/TextToImageView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate Sources/Flux2App/Views/ImageToImageView.swift:447— `viewModel.showCheckpoints && !viewModel.checkpointImages.isEmpty` appears character-identically in 2 files — Sources/Flux2App/Views/ImageToImageView.swift, Sources/Flux2App/Views/TextToImageView.swift. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Silent fallback default in catch Sources/Flux2Core/Loading/ModelDownloader.swift:574— `sizeOfItem` turns every thrown error into `0` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Sources/Flux2Core/Loading/PrequantizedCheckpoint.swift:120— `sourceFingerprint` turns every thrown error into `"unknown"` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
Silent fallback default in catch Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:2050— `selectVLMReferenceImages` turns every thrown error into `[]` — a data error becomes a silent behavior change with no trail. Log the error or let it propagate (`throws`). If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment at the `catch`, `guard` or `??`, or in the doc comment, and the row stops firing.
D21 · Naming Consistency· `runtimeID` spells `ID` where 58 names in the project spell it `Id` · ×1
`runtimeID` spells `ID` where 58 names in the project spell it `Id` Sources/Flux2Core/Utils/RuntimeBeacon.swift:55— 58 of 59 names in project Flux2App spell the token `Id` (58 of 59; unit: names in project Flux2App containing `Id`). Peers: ModelManager.currentLoadedModelId (Sources/Flux2App/ViewModels/ModelManager.swift:38); Flux2ModelDownloader.repoId (Sources/Flux2Core/Loading/ModelDownloader.swift:208); Flux2ModelDownloader.fetchFileList(repoId) (Sources/Flux2Core/Loading/ModelDownloader.swift:358); Flux2ModelDownloader.downloadFile(repoId) (Sources/Flux2Core/Loading/ModelDownloader.swift:412); SimpleLoRATrainer.positionIdCache (Sources/Flux2Core/Training/Loop/SimpleLoRATrainer.swift:202). Rename to `runtimeId`. [rule N6]
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) — this repository has no CI pipeline yet, so run it locally to clear the existing findings, then make it a step of the first workflow you add so a regression fails the build. What was searched, so you can tell an absence from a miss: the 0 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
No changelog — No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
none (dependency manifest found, not scanned for vulnerabilities here)
—
none (dependency manifest found, not scanned for vulnerabilities here): not applicable — Not scored — no dependency manifest in a supported ecosystem was read for this repository. A gap in the analyzer's language coverage, NOT a finding that the repository is free of vulnerable dependencies (a Swift Package.swift/Package.resolved — not scanned yet).
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 11 file(s) — `Sources/Flux2App/Views/ContentView.swift`, `Sources/Flux2App/Views/ImageToImageView.swift`, `Sources/Flux2App/Views/TextToImageView.swift`, `Sources/Flux2Core/Loading/ModelDownloader.swift`, `Sources/Flux2Core/Transformer/Flux2FeedForward.swift`, … (+6 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
provenance: not applicable — No CI/build pipeline found (.github/.forgejo/.gitea workflows, .circleci, .buildkite, .woodpecker, .teamcity, .gitlab-ci.yml, .travis.yml, bitbucket-pipelines.yml, .drone.yml, .cirrus.yml, .woodpecker.yml, appveyor.yml, azure-pipelines*.yml, .pipelines/, .vsts-ci/, .azuredevops/, Jenkinsfile); there is no build to attest provenance for.
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.
none (dependency manifest found, not scanned for vulnerabilities here)
—
none (dependency manifest found, not scanned for vulnerabilities here): not applicable — Not scored — no dependency manifest in a supported ecosystem was read for this repository. A gap in the analyzer's language coverage, NOT a finding that the repository is free of vulnerable dependencies (a Swift Package.swift/Package.resolved — not scanned yet).
0
—
Run 01a1e5c6-f48d-78db-8ac5-b6976185f711 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Warnings: 451 · Recommendations: 15 — Appendix A · all findings · full markdown report.
Generated by the Canine Code Analyzer: deterministic code-health analysis. 16-11-2026 @ 19:13 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.